Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import resources with provider default tags #4169

Merged
merged 18 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding test for .get methods
Upgrade pu/pu to 3.124.0
  • Loading branch information
corymhall committed Jul 18, 2024
commit 185f434d2fa986449fdf2d260637dfd8999c99e3
18 changes: 17 additions & 1 deletion examples/examples_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (st tagsState) validateStateResult(phase int) func(
return func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
for k, v := range stack.Outputs {
switch k {
case "bucket-name", "legacy-bucket-name", "appconfig-app-arn", "appconfig-env-arn":
case "bucket-name", "legacy-bucket-name", "appconfig-app-arn", "appconfig-env-arn", "get-appconfig-env":
continue
}

Expand All @@ -251,12 +251,16 @@ func (st tagsState) validateStateResult(phase int) func(
t.Logf("key=%s tags are as expected: %v", k, actualTagsJSON)

if k == "bucket" {
// getTags := stack.Outputs["get-bucket"].(string)
// assert.Equal(t, v.(string), getTags)
bucketName := stack.Outputs["bucket-name"].(string)
st.assertTagsEqualWithRetry(t,
fetchBucketTags(bucketName),
"bad bucket tags")
}
if k == "legacy-bucket" {
// getTags := stack.Outputs["get-legacy-bucket"].(string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these comments still useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added another comment with link to the issue. When the issue is fixed the code can be uncommented.

// assert.Equal(t, v.(string), getTags)
bucketName := stack.Outputs["legacy-bucket-name"].(string)
st.assertTagsEqualWithRetry(t,
fetchBucketTags(bucketName),
Expand All @@ -269,6 +273,8 @@ func (st tagsState) validateStateResult(phase int) func(
"bad appconfig app tags")
}
if k == "appconfig-env" {
getTags := stack.Outputs["get-appconfig-env"].(string)
isEqual(t, v.(string), getTags)
arn := stack.Outputs["appconfig-env-arn"].(string)
st.assertTagsEqualWithRetry(t,
fetchAppConfigTags(arn),
Expand All @@ -278,6 +284,16 @@ func (st tagsState) validateStateResult(phase int) func(
}
}

func isEqual(t *testing.T, a, b string) {
if a == "null" {
a = "{}"
}
if b == "null" {
b = "{}"
}
assert.Equal(t, a, b)
}

func fetchBucketTags(awsBucket string) tagsFetcher {
return func() (map[string]string, error) {
sess := session.Must(session.NewSessionWithOptions(session.Options{
Expand Down
28 changes: 28 additions & 0 deletions examples/tags-combinations-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,40 @@ func main() {
return err
}

env, err := appconfig.NewEnvironment(ctx, "testappconfigenv"+testIdent, &appconfig.EnvironmentArgs{
ApplicationId: app.ID(),
Tags: tagsMap,
}, pulumi.Provider(p))
if err != nil {
return err
}

getEnv, err := appconfig.GetEnvironment(ctx, "get-testappconfigenv"+testIdent, env.ID(), &appconfig.EnvironmentState{}, pulumi.Provider(p))
if err != nil {
return err
}

// refresh doesn't work for `forceDelete` & `acl` uncomment when fixed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting, is this something worth linking a ticket to? Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added another comment with link to the issue.

// getBucket, err := s3.GetBucketV2(ctx, "get-bucketv2"+testIdent, bucket.ID(), &s3.BucketV2State{}, pulumi.Provider(p), pulumi.IgnoreChanges([]string{"forceDestroy", "acl"}))
// if err != nil {
// return err
// }
// getLegacyBucket, err := s3.GetBucket(ctx, "get-legacybucket"+testIdent, legacyBucket.ID(), &s3.BucketState{}, pulumi.Provider(p), pulumi.IgnoreChanges([]string{"forceDestroy", "acl"}))
// if err != nil {
// return err
// }

ctx.Export("bucket", exportTags(bucket.Tags))
// ctx.Export("get-bucket", exportTags(getBucket.Tags))
ctx.Export("legacy-bucket", exportTags(legacyBucket.Tags))
// ctx.Export("get-legacy-bucket", exportTags(getLegacyBucket.Tags))
ctx.Export("bucket-name", bucket.Bucket)
ctx.Export("legacy-bucket-name", legacyBucket.Bucket)
ctx.Export("appconfig-app", exportTags(app.Tags))
ctx.Export("appconfig-app-arn", app.Arn)
ctx.Export("appconfig-env", exportTags(env.Tags))
ctx.Export("get-appconfig-env", exportTags(getEnv.Tags))
ctx.Export("appconfig-env-arn", env.Arn)

return nil
})
Expand Down
28 changes: 28 additions & 0 deletions examples/tags-combinations-go/step1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,40 @@ func main() {
return err
}

env, err := appconfig.NewEnvironment(ctx, "testappconfigenv"+testIdent, &appconfig.EnvironmentArgs{
ApplicationId: app.ID(),
Tags: tagsMap,
}, pulumi.Provider(p))
if err != nil {
return err
}

getEnv, err := appconfig.GetEnvironment(ctx, "get-testappconfigenv"+testIdent, env.ID(), &appconfig.EnvironmentState{}, pulumi.Provider(p))
if err != nil {
return err
}

// refresh doesn't work for `forceDelete` & `acl` uncomment when fixed
// getBucket, err := s3.GetBucketV2(ctx, "get-bucketv2"+testIdent, bucket.ID(), &s3.BucketV2State{}, pulumi.Provider(p))
// if err != nil {
// return err
// }
// getLegacyBucket, err := s3.GetBucket(ctx, "get-legacybucket"+testIdent, legacyBucket.ID(), &s3.BucketState{}, pulumi.Provider(p))
// if err != nil {
// return err
// }

ctx.Export("bucket", exportTags(bucket.Tags))
// ctx.Export("get-bucket", exportTags(getBucket.Tags))
ctx.Export("legacy-bucket", exportTags(legacyBucket.Tags))
// ctx.Export("get-legacy-bucket", exportTags(getLegacyBucket.Tags))
ctx.Export("bucket-name", bucket.Bucket)
ctx.Export("legacy-bucket-name", legacyBucket.Bucket)
ctx.Export("appconfig-app", exportTags(app.Tags))
ctx.Export("appconfig-app-arn", app.Arn)
ctx.Export("appconfig-env", exportTags(env.Tags))
ctx.Export("get-appconfig-env", exportTags(getEnv.Tags))
ctx.Export("appconfig-env-arn", env.Arn)

return nil
})
Expand Down
14 changes: 7 additions & 7 deletions provider/cmd/pulumi-resource-aws/schema.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ require (
github.com/pulumi/providertest v0.0.11
github.com/pulumi/pulumi-terraform-bridge/pf v0.39.0
github.com/pulumi/pulumi-terraform-bridge/v3 v3.86.0
github.com/pulumi/pulumi/pkg/v3 v3.121.0
github.com/pulumi/pulumi/sdk/v3 v3.121.0
github.com/pulumi/pulumi/pkg/v3 v3.124.0
github.com/pulumi/pulumi/sdk/v3 v3.124.0
github.com/stretchr/testify v1.9.0
pgregory.net/rapid v0.6.1
)
Expand Down Expand Up @@ -332,7 +332,7 @@ require (
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.8 // indirect
Expand Down Expand Up @@ -408,7 +408,7 @@ require (
github.com/pulumi/inflector v0.1.1 // indirect
github.com/pulumi/pulumi-java/pkg v0.11.0 // indirect
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.8 // indirect
github.com/pulumi/pulumi-yaml v1.8.0 // indirect
github.com/pulumi/pulumi-yaml v1.9.1 // indirect
github.com/pulumi/schema-tools v0.1.2 // indirect
github.com/pulumi/terraform-diff-reader v0.0.2 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
Expand Down
16 changes: 8 additions & 8 deletions provider/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2033,8 +2033,8 @@ github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9
github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY=
github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A=
github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI=
github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M=
github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
Expand Down Expand Up @@ -2363,12 +2363,12 @@ github.com/pulumi/pulumi-terraform-bridge/v3 v3.86.0 h1:55ydBXwbNpL+eAPExJSfL1pS
github.com/pulumi/pulumi-terraform-bridge/v3 v3.86.0/go.mod h1:jyywJUc4gFP5vWOar8qSQWzSrpwht7XDrYQtVvneza4=
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.8 h1:mav2tSitA9BPJPLLahKgepHyYsMzwaTm4cvp0dcTMYw=
github.com/pulumi/pulumi-terraform-bridge/x/muxer v0.0.8/go.mod h1:qUYk2c9i/yqMGNj9/bQyXpS39BxNDSXYjVN1njnq0zY=
github.com/pulumi/pulumi-yaml v1.8.0 h1:bhmidiCMMuzsJao5FE0UR69iF3WVKPCFrRkzjotFNn4=
github.com/pulumi/pulumi-yaml v1.8.0/go.mod h1:pCfYHSRmdl+5dM/7eT2uDQS528YOhAhiqbn9pwRzW20=
github.com/pulumi/pulumi/pkg/v3 v3.121.0 h1:cLUQJYGJKfgCY0ubJo8dVwmsIm2WcgTprb9Orc/yiFg=
github.com/pulumi/pulumi/pkg/v3 v3.121.0/go.mod h1:aaRixfKOh4DhGtuDJcI56dTPkb7oJBgRgH1aMF1FzbU=
github.com/pulumi/pulumi/sdk/v3 v3.121.0 h1:UsnFKIVOtJN/hQKPkWHL9cZktewPVQRbNUXbXQY/qrk=
github.com/pulumi/pulumi/sdk/v3 v3.121.0/go.mod h1:p1U24en3zt51agx+WlNboSOV8eLlPWYAkxMzVEXKbnY=
github.com/pulumi/pulumi-yaml v1.9.1 h1:JPeI80M23SPactxgnCFS1casZlSr7ZhAXwSx4H55QQ4=
github.com/pulumi/pulumi-yaml v1.9.1/go.mod h1:OH0R34yJxA5u6zjYBN4JXcWoEvfkRoOVWi6viu8buoA=
github.com/pulumi/pulumi/pkg/v3 v3.124.0 h1:JgUePx6Ga9geBJ1dku6K8GXTrsBYzXMhKIsk+cxeKo8=
github.com/pulumi/pulumi/pkg/v3 v3.124.0/go.mod h1:/XUDPNoIikS3lcQe1HpGuKs73cO5HqBvOdxXFeC3UHM=
github.com/pulumi/pulumi/sdk/v3 v3.124.0 h1:f9Rb2AhLSaacKTaBPbKXPCfviHxTuhEXafhT4E095Y0=
github.com/pulumi/pulumi/sdk/v3 v3.124.0/go.mod h1:p1U24en3zt51agx+WlNboSOV8eLlPWYAkxMzVEXKbnY=
github.com/pulumi/schema-tools v0.1.2 h1:Fd9xvUjgck4NA+7/jSk7InqCUT4Kj940+EcnbQKpfZo=
github.com/pulumi/schema-tools v0.1.2/go.mod h1:62lgj52Tzq11eqWTIaKd+EVyYAu5dEcDJxMhTjvMO/k=
github.com/pulumi/terraform-diff-reader v0.0.2 h1:kTE4nEXU3/SYXESvAIem+wyHMI3abqkI3OhJ0G04LLI=
Expand Down
14 changes: 9 additions & 5 deletions sdk/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading