From 8a0c1a49d44ff8bbb1bc08541e9e5b6b4c4b9796 Mon Sep 17 00:00:00 2001 From: Florian Stadler Date: Fri, 17 Jan 2025 16:19:51 +0100 Subject: [PATCH] Revert "Ignore username/password changes in registryAuth config (#1327)" (#1341) This reverts commit 8d722c60bec7fabac0c14ce73c44b7edad4a25e7. Revert in order to fix preview with refresh regression (https://github.com/pulumi/pulumi-docker/issues/1339) introduced in #1327 Fixes #1339 --- examples/examples_nodejs_test.go | 76 +--- examples/examples_test.go | 25 -- examples/go.mod | 7 +- examples/go.sum | 28 -- .../test-ignore-auth-changes/ts/Pulumi.yaml | 3 - examples/test-ignore-auth-changes/ts/index.ts | 15 - .../test-ignore-auth-changes/ts/package.json | 10 - .../test-ignore-auth-changes/yaml/Pulumi.yaml | 17 - examples/test-registry-image/.gitignore | 2 - examples/test-registry-image/Pulumi.yaml | 3 - examples/test-registry-image/app/Dockerfile | 3 - examples/test-registry-image/index.ts | 48 -- examples/test-registry-image/package.json | 11 - examples/test-registry-image/tsconfig.json | 18 - .../ts/index.ts | 10 - provider/hybrid.go | 79 +--- provider/hybrid_test.go | 425 ------------------ provider/serve.go | 3 - 18 files changed, 7 insertions(+), 776 deletions(-) delete mode 100644 examples/test-ignore-auth-changes/ts/Pulumi.yaml delete mode 100644 examples/test-ignore-auth-changes/ts/index.ts delete mode 100644 examples/test-ignore-auth-changes/ts/package.json delete mode 100644 examples/test-ignore-auth-changes/yaml/Pulumi.yaml delete mode 100644 examples/test-registry-image/.gitignore delete mode 100644 examples/test-registry-image/Pulumi.yaml delete mode 100644 examples/test-registry-image/app/Dockerfile delete mode 100644 examples/test-registry-image/index.ts delete mode 100644 examples/test-registry-image/package.json delete mode 100644 examples/test-registry-image/tsconfig.json delete mode 100644 provider/hybrid_test.go diff --git a/examples/examples_nodejs_test.go b/examples/examples_nodejs_test.go index 145683baa..e55fe1aa5 100644 --- a/examples/examples_nodejs_test.go +++ b/examples/examples_nodejs_test.go @@ -29,7 +29,6 @@ import ( "testing" "github.com/pulumi/pulumi/pkg/v3/testing/integration" - "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/crypto/ssh" @@ -201,21 +200,12 @@ func TestSecretsInExplicitProviderNode(t *testing.T) { "Unexpected panic recorded in engine events") } }) - - t.Run("providerWithRandomPassword", func(t *testing.T) { - pw := stack.Outputs["randomPassword"].(string) - realPW, err := base64.StdEncoding.DecodeString(pw) - assert.NoError(t, err) - assert.NotContainsf(t, string(deploymentJSON), string(realPW), - "Secret properties like RegistryAuth.Password should not be stored in the plain") - }) } test := getJsOptions(t).With(integration.ProgramTestOptions{ - Dir: path.Join(getCwd(t), "test-secrets-in-explicit-provider", "ts"), - // Changes to registry username or password should not trigger a diff - AllowEmptyPreviewChanges: false, - SkipEmptyPreviewUpdate: false, - ExtraRuntimeValidation: check, + Dir: path.Join(getCwd(t), "test-secrets-in-explicit-provider", "ts"), + Quick: true, + SkipRefresh: true, + ExtraRuntimeValidation: check, }) integration.ProgramTest(t, &test) } @@ -298,64 +288,6 @@ func TestLocalRepoDigestNode(t *testing.T) { integration.ProgramTest(t, &test) } -func TestRegistryImage(t *testing.T) { - region := os.Getenv("AWS_REGION") - if region == "" { - t.Skipf("Skipping test due to missing AWS_REGION environment variable") - } - test := getJsOptions(t). - With(integration.ProgramTestOptions{ - Dir: path.Join(getCwd(t), "test-registry-image"), - Config: map[string]string{ - "aws:region": region, - }, - ExtraRuntimeValidation: assertHasRepoDigest, - }) - integration.ProgramTest(t, &test) -} - -// TestIgnoreAuthChangesTs tests that changes to username and password do not trigger a diff for runtimes -// that receive json-encoded data for nested provider config. Nodejs is one such runtime. -func TestIgnoreAuthChangesTs(t *testing.T) { - t.Parallel() - - ptest := pulumiTest(t, path.Join(getCwd(t), "test-ignore-auth-changes", "ts")) - ptest.SetConfig(t, "address", "some-address") - ptest.SetConfig(t, "username", "some-user") - ptest.SetConfig(t, "password", "some-password") - ptest.Up(t) - - // Changes to username and password should not trigger a diff. - ptest.SetConfig(t, "username", "some-other-user") - ptest.SetConfig(t, "password", "some-other-password") - ptest.Preview(t, optpreview.ExpectNoChanges()) - - // Changes to address should still trigger a diff. - ptest.SetConfig(t, "address", "some-other-address") - previewResult := ptest.Preview(t) - AssertHasChanges(t, previewResult) -} - -// TestIgnoreAuthChangesYaml tests that changes to username and password do not trigger a diff for runtimes -// that receive regular GRPC structs for nested provider config. YAML is one such runtime. -func TestIgnoreAuthChangesYaml(t *testing.T) { - ptest := pulumiTest(t, path.Join(getCwd(t), "test-ignore-auth-changes", "yaml")) - ptest.SetConfig(t, "address", "some-address") - ptest.SetConfig(t, "username", "some-user") - ptest.SetConfig(t, "password", "some-password") - ptest.Up(t) - - // Changes to username and password should not trigger a diff. - ptest.SetConfig(t, "username", "some-other-user") - ptest.SetConfig(t, "password", "some-other-password") - ptest.Preview(t, optpreview.ExpectNoChanges()) - - // Changes to address should trigger a diff. - ptest.SetConfig(t, "address", "some-other-address") - previewResult := ptest.Preview(t) - AssertHasChanges(t, previewResult) -} - func getJsOptions(t *testing.T) integration.ProgramTestOptions { base := getBaseOptions() baseJs := base.With(integration.ProgramTestOptions{ diff --git a/examples/examples_test.go b/examples/examples_test.go index 06a29d9e5..2fe8b0433 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -16,15 +16,9 @@ package examples import ( "os" - "path/filepath" "testing" - "github.com/pulumi/providertest/pulumitest" - "github.com/pulumi/providertest/pulumitest/changesummary" - "github.com/pulumi/providertest/pulumitest/opttest" "github.com/pulumi/pulumi/pkg/v3/testing/integration" - "github.com/pulumi/pulumi/sdk/v3/go/auto" - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" "github.com/stretchr/testify/assert" ) @@ -48,22 +42,3 @@ func assertHasRepoDigest(t *testing.T, stack integration.RuntimeValidationStackI assert.True(t, ok, "expected repoDigest output") assert.NotEmpty(t, repoDigest) } - -func pulumiTest(t *testing.T, dir string, opts ...opttest.Option) *pulumitest.PulumiTest { - cwd, err := os.Getwd() - if err != nil { - t.Error(err) - } - opts = append(opts, opttest.LocalProviderPath("docker", filepath.Join(cwd, "..", "bin"))) - ptest := pulumitest.NewPulumiTest(t, dir, opts...) - return ptest -} - -func AssertHasChanges(t *testing.T, preview auto.PreviewResult) { - t.Helper() - - convertedMap := changesummary.ChangeSummary(preview.ChangeSummary) - expectedOps := convertedMap.WhereOpEquals(apitype.OpDelete, apitype.OpDeleteReplaced, apitype.OpReplace, apitype.OpUpdate) - - assert.NotEmpty(t, expectedOps, "expected changes, but preview returned no changes: %s", preview.StdOut) -} diff --git a/examples/go.mod b/examples/go.mod index 1b3dd23cd..7ef480376 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -4,9 +4,7 @@ go 1.21 require ( github.com/docker/docker v27.0.3+incompatible - github.com/pulumi/providertest v0.1.3 github.com/pulumi/pulumi/pkg/v3 v3.145.0 - github.com/pulumi/pulumi/sdk/v3 v3.145.0 github.com/stretchr/testify v1.9.0 golang.org/x/crypto v0.31.0 ) @@ -68,7 +66,6 @@ require ( github.com/edsrzf/mmap-go v1.1.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-git/go-git/v5 v5.12.0 // indirect @@ -101,7 +98,6 @@ require ( github.com/hashicorp/hcl/v2 v2.22.0 // indirect github.com/hashicorp/vault/api v1.12.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/iwdgo/sigintwindows v0.2.2 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -125,7 +121,6 @@ require ( github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/termenv v0.15.2 // indirect github.com/natefinch/atomic v1.0.1 // indirect - github.com/nxadm/tail v1.4.11 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.2 // indirect github.com/opentracing/basictracer-go v1.1.0 // indirect @@ -139,6 +134,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect github.com/pulumi/esc v0.10.0 // indirect + github.com/pulumi/pulumi/sdk/v3 v3.145.0 // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect @@ -184,7 +180,6 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/grpc v1.67.1 // indirect google.golang.org/protobuf v1.35.1 // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect diff --git a/examples/go.sum b/examples/go.sum index e721fd9f7..14e3f2149 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -147,15 +147,6 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gkampitakis/ciinfo v0.3.0 h1:gWZlOC2+RYYttL0hBqcoQhM7h1qNkVqvRCV1fOvpAv8= -github.com/gkampitakis/ciinfo v0.3.0/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo= -github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M= -github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk= -github.com/gkampitakis/go-snaps v0.4.9 h1:x6+GEQeYWC+cnLNsHK5uXXgEQADmlH/1EqMrjfXjzk8= -github.com/gkampitakis/go-snaps v0.4.9/go.mod h1:8HW4KX3JKV8M0GSw69CvT+Jqhd1AlBPMPpBfjBI3bdY= github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= @@ -262,8 +253,6 @@ github.com/hashicorp/vault/api v1.12.0 h1:meCpJSesvzQyao8FCOgk2fGdoADAnbDu2WPJN1 github.com/hashicorp/vault/api v1.12.0/go.mod h1:si+lJCYO7oGkIoNPAN8j3azBLTn9SjMGS+jFaHd1Cck= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/iwdgo/sigintwindows v0.2.2 h1:P6oWzpvV7MrEAmhUgs+zmarrWkyL77ycZz4v7+1gYAE= -github.com/iwdgo/sigintwindows v0.2.2/go.mod h1:70wPb8oz8OnxPvsj2QMUjgIVhb8hMu5TUgX8KfFl7QY= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -330,8 +319,6 @@ github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A= github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM= -github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= -github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= @@ -362,8 +349,6 @@ github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 h1:vkHw5I/plNdTr435 github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231/go.mod h1:murToZ2N9hNJzewjHBgfFdXhZKjY3z5cYC1VXk+lbFE= github.com/pulumi/esc v0.10.0 h1:jzBKzkLVW0mePeanDRfqSQoCJ5yrkux0jIwAkUxpRKE= github.com/pulumi/esc v0.10.0/go.mod h1:2Bfa+FWj/xl8CKqRTWbWgDX0SOD4opdQgvYSURTGK2c= -github.com/pulumi/providertest v0.1.3 h1:GpNKRy/haNjRHiUA9bi4diU4Op2zf3axYXbga5AepHg= -github.com/pulumi/providertest v0.1.3/go.mod h1:GcsqEGgSngwaNOD+kICJPIUQlnA911fGBU8HDlJvVL0= github.com/pulumi/pulumi/pkg/v3 v3.145.0 h1:hAhFLieunnCKuMd3GbLqE5uWQ1hpNLdl6+bCDFSF4YQ= github.com/pulumi/pulumi/pkg/v3 v3.145.0/go.mod h1:N19IsMJ3GyYO5N2JfpsCAVk0eH1NKkF05fZGn5dnhBE= github.com/pulumi/pulumi/sdk/v3 v3.145.0 h1:r5iOgz67RElFXJt4GVVY2SBGh5sR24mL9NOcKBiBi/k= @@ -390,8 +375,6 @@ github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -414,14 +397,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/texttheater/golang-levenshtein v1.0.1 h1:+cRNoVrfiwufQPhoMzB6N0Yf/Mqajr6t1lOv8GyGE2U= github.com/texttheater/golang-levenshtein v1.0.1/go.mod h1:PYAKrbF5sAiq9wd+H82hs7gNaen0CplQ9uvm6+enD/8= -github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= -github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= -github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= -github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o= github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= @@ -540,7 +515,6 @@ golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -634,8 +608,6 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/examples/test-ignore-auth-changes/ts/Pulumi.yaml b/examples/test-ignore-auth-changes/ts/Pulumi.yaml deleted file mode 100644 index a86780523..000000000 --- a/examples/test-ignore-auth-changes/ts/Pulumi.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: test-ignore-auth-changes -runtime: nodejs -description: A minimal TypeScript Pulumi program diff --git a/examples/test-ignore-auth-changes/ts/index.ts b/examples/test-ignore-auth-changes/ts/index.ts deleted file mode 100644 index 5b658a2a6..000000000 --- a/examples/test-ignore-auth-changes/ts/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as pulumi from "@pulumi/pulumi"; -import * as docker from "@pulumi/docker"; - -const config = new pulumi.Config(); - -// Changes to username and password should not trigger a diff, but changes to address should. -const provider = new docker.Provider("docker", { - registryAuth: [ - { - address: config.require("address"), - username: config.require("username"), - password: config.require("password"), - }, - ], -}); diff --git a/examples/test-ignore-auth-changes/ts/package.json b/examples/test-ignore-auth-changes/ts/package.json deleted file mode 100644 index 1c3fda009..000000000 --- a/examples/test-ignore-auth-changes/ts/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "test-ignore-auth-changes", - "devDependencies": { - "@types/node": "^14.0.0" - }, - "dependencies": { - "@pulumi/docker": "^4.5.8", - "@pulumi/pulumi": "^3.144.1" - } -} diff --git a/examples/test-ignore-auth-changes/yaml/Pulumi.yaml b/examples/test-ignore-auth-changes/yaml/Pulumi.yaml deleted file mode 100644 index 8b48c7210..000000000 --- a/examples/test-ignore-auth-changes/yaml/Pulumi.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: docker-provider-config -runtime: yaml -config: - username: - type: string - password: - type: string - address: - type: string -resources: - dockerProvider: - type: pulumi:providers:docker - properties: - registryAuth: - - address: ${address} - username: ${username} - password: ${password} diff --git a/examples/test-registry-image/.gitignore b/examples/test-registry-image/.gitignore deleted file mode 100644 index c6958891d..000000000 --- a/examples/test-registry-image/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin/ -/node_modules/ diff --git a/examples/test-registry-image/Pulumi.yaml b/examples/test-registry-image/Pulumi.yaml deleted file mode 100644 index 0d80c5d1b..000000000 --- a/examples/test-registry-image/Pulumi.yaml +++ /dev/null @@ -1,3 +0,0 @@ -name: test-registry-image -runtime: nodejs -description: A minimal AWS TypeScript Pulumi program diff --git a/examples/test-registry-image/app/Dockerfile b/examples/test-registry-image/app/Dockerfile deleted file mode 100644 index c3e1241d8..000000000 --- a/examples/test-registry-image/app/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM nginx -RUN echo "

Hi from Pulumi!

" > \ - /usr/share/nginx/html/index.html diff --git a/examples/test-registry-image/index.ts b/examples/test-registry-image/index.ts deleted file mode 100644 index ac0e1de73..000000000 --- a/examples/test-registry-image/index.ts +++ /dev/null @@ -1,48 +0,0 @@ -import * as aws from "@pulumi/aws"; -import * as docker from "@pulumi/docker"; - -// Create a private ECR registry. -const repo = new aws.ecr.Repository("my-repo",{ - forceDelete: true, -}); - -// Get registry info (creds and endpoint) so we can build/publish to it. -const registryInfo = repo.registryId.apply(async id => { - const credentials = await aws.ecr.getCredentials({ registryId: id }); - const decodedCredentials = Buffer.from(credentials.authorizationToken, "base64").toString(); - const [username, password] = decodedCredentials.split(":"); - if (!password || !username) { - throw new Error("Invalid credentials"); - } - return { - address: credentials.proxyEndpoint, - username: username, - password: password, - }; -}); - - -// Build and publish the image. -const image = new docker.Image("my-image", { - build: { - context: "app", - }, - imageName: repo.repositoryUrl, - skipPush: true -}); - -const ecrProvider = new docker.Provider("ecr-provider", { - registryAuth: [registryInfo], -}); - -// Publish the image to the registry -const registryImage = new docker.RegistryImage("my-registry-image", - { - name: repo.repositoryUrl, - }, - { provider: ecrProvider, dependsOn: [image] }, -); - -// Export the resulting image name -export const imageName = registryImage.name; -export const repoDigest = registryImage.sha256Digest; \ No newline at end of file diff --git a/examples/test-registry-image/package.json b/examples/test-registry-image/package.json deleted file mode 100644 index b8f86c436..000000000 --- a/examples/test-registry-image/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "test-registry-image", - "devDependencies": { - "@types/node": "^14.0.0" - }, - "dependencies": { - "@pulumi/aws": "^6.10.0", - "@pulumi/pulumi": "^3.0.0", - "@pulumi/docker": "^4.5.0" - } -} diff --git a/examples/test-registry-image/tsconfig.json b/examples/test-registry-image/tsconfig.json deleted file mode 100644 index ab65afa61..000000000 --- a/examples/test-registry-image/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "outDir": "bin", - "target": "es2016", - "module": "commonjs", - "moduleResolution": "node", - "sourceMap": true, - "experimentalDecorators": true, - "pretty": true, - "noFallthroughCasesInSwitch": true, - "noImplicitReturns": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.ts" - ] -} diff --git a/examples/test-secrets-in-explicit-provider/ts/index.ts b/examples/test-secrets-in-explicit-provider/ts/index.ts index b3f945dc4..044ac18ee 100644 --- a/examples/test-secrets-in-explicit-provider/ts/index.ts +++ b/examples/test-secrets-in-explicit-provider/ts/index.ts @@ -29,15 +29,5 @@ const providerWithSecretPassword = new docker.Provider("provider-with-password", }], }) -const randomPw = "secret-password-" + Math.random().toString(36).slice(2, 7); -const providerWithRandomPassword = new docker.Provider("provider-with-random-password", { - registryAuth: [{ - address: "some-address", - username: passwordResource.result, - password: randomPw, - }], -}) - export const password = pulumi.unsecret(passwordResource.result) .apply(x => Buffer.from(x).toString('base64')); -export const randomPassword = Buffer.from(randomPw).toString('base64'); diff --git a/provider/hybrid.go b/provider/hybrid.go index 30d7153bd..7d3b259e9 100644 --- a/provider/hybrid.go +++ b/provider/hybrid.go @@ -5,14 +5,11 @@ import ( "fmt" "github.com/golang/protobuf/ptypes/empty" - structpb "github.com/golang/protobuf/ptypes/struct" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" "github.com/pulumi/pulumi/sdk/v3/go/common/util/logging" rpc "github.com/pulumi/pulumi/sdk/v3/proto/go" @@ -28,11 +25,9 @@ type dockerHybridProvider struct { rpc.UnimplementedResourceProviderServer schemaBytes []byte - name string version string bridgedProvider rpc.ResourceProviderServer nativeProvider rpc.ResourceProviderServer - configEncoding *tfbridge.ConfigEncoding } // Track a list of native resource tokens @@ -70,78 +65,8 @@ func (dp dockerHybridProvider) CheckConfig(ctx context.Context, request *rpc.Che } func (dp dockerHybridProvider) DiffConfig(ctx context.Context, request *rpc.DiffRequest) (*rpc.DiffResponse, error) { - urn := resource.URN(request.GetUrn()) - label := fmt.Sprintf("%s.DiffConfig(%s)", dp.name, urn) - logging.V(9).Infof("%s executing", label) - - var err error - request.Olds, err = dp.unwrapJSONConfig(label, request.GetOlds()) - if err != nil { - return nil, fmt.Errorf("error unwrapping old config: %w", err) - } - request.News, err = dp.unwrapJSONConfig(label, request.GetNews()) - if err != nil { - return nil, fmt.Errorf("error unwrapping new config: %w", err) - } - request.OldInputs, err = dp.unwrapJSONConfig(label, request.GetOldInputs()) - if err != nil { - return nil, fmt.Errorf("error unwrapping old inputs: %w", err) - } - - ignoreChanges := []string{"registryAuth[*].password", "registryAuth[*].username"} - ignoreChanges = append(ignoreChanges, request.IgnoreChanges...) - request.IgnoreChanges = ignoreChanges - - res, err := dp.bridgedProvider.DiffConfig(ctx, request) - if err != nil { - return nil, err - } - - // if the diff is empty, it means it only contained changes to username and password which we ignored - if res != nil && len(res.Diffs) == 0 && len(res.Replaces) == 0 && len(res.DetailedDiff) == 0 { - res.Changes = rpc.DiffResponse_DIFF_NONE - } - return res, err -} - -// unwrapJSONConfig handles nested provider configuration data that can be in two formats: -// 1. A JSON-encoded string containing the nested configuration (used by default providers and explicit providers -// for TypeScript, Python, .NET, Java) -// 2. A regular gRPC struct (used by explicit providers for Go and YAML) -// -// For JSON-encoded strings, it decodes the nested config. For gRPC structs, it returns the config unchanged. -// Under the hood, this is implemented by unmarshalling the grpc struct, unfolding the properties, -// and then marshalling them back to a grpc struct. -// -// This dual format support is needed because different language runtimes serialize their -// provider configs differently when sending them over gRPC. -// -// Note that this function does not preserve secrets, as this provider does not accept secrets. The provider relies on -// the engine to handle secrets. -func (dp dockerHybridProvider) unwrapJSONConfig(label string, config *structpb.Struct) (*structpb.Struct, error) { - unmarshalled, err := plugin.UnmarshalProperties(config, plugin.MarshalOptions{ - Label: label, - KeepUnknowns: true, - SkipNulls: true, - // the provider does not accept secrets, so we should never receive them here. There's e2e tests ensuring that - // secrets in provider config are handled correctly. If this assumption changes, those tests will catch it. - KeepSecrets: false, - }) - if err != nil { - return nil, err - } - - unwrappedConfig, err := dp.configEncoding.UnfoldProperties(unmarshalled) - if err != nil { - return nil, err - } - - return plugin.MarshalProperties(unwrappedConfig, plugin.MarshalOptions{ - Label: label, - KeepUnknowns: true, - SkipNulls: true, - KeepSecrets: false, - }) + // Delegate to the bridged provider, as native Provider does not implement it. + return dp.bridgedProvider.DiffConfig(ctx, request) } func (dp dockerHybridProvider) Configure( diff --git a/provider/hybrid_test.go b/provider/hybrid_test.go deleted file mode 100644 index cbe1ce9df..000000000 --- a/provider/hybrid_test.go +++ /dev/null @@ -1,425 +0,0 @@ -package provider - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" - rpc "github.com/pulumi/pulumi/sdk/v3/proto/go" - - "github.com/pulumi/pulumi-docker/provider/v4/pkg/version" -) - -type diffConfig struct { - oldInputs resource.PropertyMap - olds resource.PropertyMap - news resource.PropertyMap - ignoreChanges []string -} - -type diffExpected struct { - Replaces []string - Stables []string - Changes rpc.DiffResponse_DiffChanges - Diffs []string - DetailedDiff map[string]*propDiff -} - -type propDiff struct { - Kind rpc.PropertyDiff_Kind - InputDiff bool -} - -func TestDiffConfig(t *testing.T) { - tests := []struct { - name string - input diffConfig - expected diffExpected - }{ - { - name: "empty config", - input: diffConfig{ - oldInputs: resource.PropertyMap{}, - olds: resource.PropertyMap{}, - news: resource.PropertyMap{}, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_NONE, - Replaces: []string{}, - Diffs: []string{}, - Stables: nil, - DetailedDiff: nil, - }, - }, - { - name: "ignores credential diff in nested json", - input: diffConfig{ - oldInputs: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - olds: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - news: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"alice\", \"password\":\"moresecret\"}]"), - }, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_NONE, - Replaces: []string{}, - Diffs: []string{}, - Stables: nil, - DetailedDiff: nil, - }, - }, - { - name: "ignores credential diff", - input: diffConfig{ - oldInputs: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("bob"), - "password": resource.NewStringProperty("supersecret"), - }, - }, - })}, - olds: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("bob"), - "password": resource.NewStringProperty("supersecret"), - }, - }, - })}, - news: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("alice"), - "password": resource.NewStringProperty("moresecret"), - }, - }, - })}, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_NONE, - Replaces: []string{}, - Diffs: []string{}, - Stables: nil, - DetailedDiff: nil, - }, - }, - { - name: "keeps address diff in nested json", - input: diffConfig{ - oldInputs: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - olds: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - news: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"ShinyPrivateGHCR\", \"username\":\"alice\", \"password\":\"moresecret\"}]"), - }, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_SOME, - Replaces: nil, - Diffs: []string{"registryAuth[0].address"}, - Stables: nil, - DetailedDiff: map[string]*propDiff{ - "registryAuth[0].address": { - Kind: rpc.PropertyDiff_UPDATE, - InputDiff: true, - }, - }, - }, - }, - { - name: "keeps address diff", - input: diffConfig{ - oldInputs: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("bob"), - "password": resource.NewStringProperty("supersecret"), - }, - }, - })}, - olds: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("bob"), - "password": resource.NewStringProperty("supersecret"), - }, - }, - })}, - news: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("ShinyPrivateGHCR"), - "username": resource.NewStringProperty("alice"), - "password": resource.NewStringProperty("moresecret"), - }, - }, - })}, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_SOME, - Replaces: nil, - Diffs: []string{"registryAuth[0].address"}, - Stables: nil, - DetailedDiff: map[string]*propDiff{ - "registryAuth[0].address": { - Kind: rpc.PropertyDiff_UPDATE, - InputDiff: true, - }, - }, - }, - }, - { - name: "handles secrets in nested json", - input: diffConfig{ - oldInputs: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - olds: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - news: resource.PropertyMap{ - "registryAuth": resource.MakeSecret(resource.NewStringProperty( - "[{\"address\":\"ShinyPrivateGHCR\", \"username\":\"alice\", \"password\":\"moresecret\"}]")), - }, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_SOME, - Replaces: nil, - Diffs: []string{"registryAuth[0].address"}, - Stables: nil, - DetailedDiff: map[string]*propDiff{ - "registryAuth[0].address": { - Kind: rpc.PropertyDiff_UPDATE, - InputDiff: true, - }, - }, - }, - }, - { - name: "handles nested secrets in nested json", - input: diffConfig{ - oldInputs: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - olds: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - news: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"ShinyPrivateGHCR\",\"username\":\"alice\"," + - "\"password\":{\"4dabf18193072939515e22adb298388d\": " + - "\"1b47061264138c4ac30d75fd1eb44270\",\"value\": \"moresecret\"}}]"), - }, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_SOME, - Replaces: nil, - Diffs: []string{"registryAuth[0].address"}, - Stables: nil, - DetailedDiff: map[string]*propDiff{ - "registryAuth[0].address": { - Kind: rpc.PropertyDiff_UPDATE, - InputDiff: true, - }, - }, - }, - }, - { - name: "supports ignore changes", - input: diffConfig{ - oldInputs: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("bob"), - "password": resource.NewStringProperty("supersecret"), - }, - }, - })}, - olds: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("bob"), - "password": resource.NewStringProperty("supersecret"), - }, - }, - })}, - news: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("ShinyPrivateGHCR"), - "username": resource.NewStringProperty("alice"), - "password": resource.NewStringProperty("moresecret"), - }, - }, - })}, - ignoreChanges: []string{"registryAuth"}, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_NONE, - Replaces: []string{}, - Diffs: []string{}, - Stables: nil, - DetailedDiff: nil, - }, - }, - { - name: "handles unknowns", - input: diffConfig{ - oldInputs: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("bob"), - "password": resource.NewStringProperty("supersecret"), - }, - }, - })}, - olds: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("bob"), - "password": resource.NewStringProperty("supersecret"), - }, - }, - })}, - news: resource.PropertyMap{"registryAuth": resource.NewArrayProperty([]resource.PropertyValue{ - { - V: resource.PropertyMap{ - "address": resource.NewStringProperty("dockerhub"), - "username": resource.NewStringProperty("alice"), - "password": resource.NewComputedProperty(resource.Computed{ - Element: resource.NewStringProperty(""), - }), - }, - }, - })}, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_NONE, - Replaces: []string{}, - Diffs: []string{}, - Stables: nil, - DetailedDiff: nil, - }, - }, - { - name: "handles unknowns in nested json", - input: diffConfig{ - oldInputs: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - olds: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"bob\", \"password\":\"supersecret\"}]"), - }, - news: resource.PropertyMap{ - "registryAuth": resource.NewStringProperty( - "[{\"address\":\"dockerhub\", \"username\":\"alice\"," + - "\"password\":\"04da6b54-80e4-46f7-96ec-b56ff0331ba9\"}]"), - }, - }, - expected: diffExpected{ - Changes: rpc.DiffResponse_DIFF_NONE, - Replaces: []string{}, - Diffs: []string{}, - Stables: nil, - DetailedDiff: nil, - }, - }, - } - - version.Version = "v4.0.0" - prov := Provider() - configEncoding := tfbridge.NewConfigEncoding(prov.P.Schema(), prov.Config) - - dp := dockerHybridProvider{ - name: "test", - bridgedProvider: tfbridge.NewProvider(context.TODO(), nil, "docker", version.Version, prov.P, prov, []byte("{}")), - configEncoding: configEncoding, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - inputOlds, err := plugin.MarshalProperties(tt.input.olds, plugin.MarshalOptions{ - Label: "test", - KeepUnknowns: true, - SkipNulls: true, - KeepSecrets: true, - }) - require.NoError(t, err) - inputNews, err := plugin.MarshalProperties(tt.input.news, plugin.MarshalOptions{ - Label: "test", - KeepUnknowns: true, - SkipNulls: true, - KeepSecrets: true, - }) - require.NoError(t, err) - oldInputs, err := plugin.MarshalProperties(tt.input.oldInputs, plugin.MarshalOptions{ - Label: "test", - KeepUnknowns: true, - SkipNulls: true, - KeepSecrets: true, - }) - require.NoError(t, err) - - res, err := dp.DiffConfig(context.TODO(), &rpc.DiffRequest{ - Urn: "urn:pulumi:test::test::pulumi:providers:docker::prov", - Olds: inputOlds, - News: inputNews, - OldInputs: oldInputs, - IgnoreChanges: tt.input.ignoreChanges, - }) - require.NoError(t, err) - - assert.Equal(t, tt.expected.Changes, res.Changes, "Changes") - assert.Equal(t, tt.expected.Diffs, res.Diffs, "Diffs") - assert.Equal(t, tt.expected.Replaces, res.Replaces, "Replaces") - assert.Equal(t, tt.expected.Stables, res.Stables, "Stables") - - if tt.expected.DetailedDiff == nil { - assert.Nil(t, res.DetailedDiff, "DetailedDiff") - } else { - actualDetailedDiff := make(map[string]*propDiff, len(res.DetailedDiff)) - for k, v := range res.DetailedDiff { - actualDetailedDiff[k] = &propDiff{ - Kind: v.GetKind(), - InputDiff: v.GetInputDiff(), - } - } - assert.Equal(t, tt.expected.DetailedDiff, actualDetailedDiff, "DetailedDiff") - } - }) - } -} diff --git a/provider/serve.go b/provider/serve.go index 6af6bc276..57336ef62 100644 --- a/provider/serve.go +++ b/provider/serve.go @@ -32,13 +32,10 @@ func makeProvider(host *provider.HostClient, name, version string, schemaBytes [ prov := Provider() bridgedProvider := tfbridge.NewProvider(context.Background(), host, name, version, prov.P, prov, schemaBytes) - configEncoding := tfbridge.NewConfigEncoding(prov.P.Schema(), prov.Config) return &dockerHybridProvider{ schemaBytes: schemaBytes, version: version, - name: name, bridgedProvider: bridgedProvider, nativeProvider: nativeProvider, - configEncoding: configEncoding, }, nil }