-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
449 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pulumi/providertest/pulumitest" | ||
"github.com/pulumi/providertest/pulumitest/opttest" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConfigMapAndSecretImmutability(t *testing.T) { | ||
t.Parallel() | ||
|
||
test := pulumitest.NewPulumiTest(t, | ||
"testdata/immutability", | ||
opttest.SkipInstall(), | ||
) | ||
t.Cleanup(func() { | ||
test.Destroy() | ||
}) | ||
|
||
// Create the secrets/configmaps. | ||
up := test.Up() | ||
|
||
// We will detect update/replacement behavior by observing effects on our | ||
// downstream dependencies. | ||
secret := up.Outputs["secret"].Value.(string) | ||
configmap := up.Outputs["configmap"].Value.(string) | ||
autonamedSecret := up.Outputs["autonamedSecret"].Value.(string) | ||
autonamedConfigmap := up.Outputs["autonamedConfigmap"].Value.(string) | ||
mutableSecret := up.Outputs["mutableSecret"].Value.(string) | ||
mutableConfigmap := up.Outputs["mutableConfigmap"].Value.(string) | ||
|
||
// Update the data of all our secrets and configmaps. | ||
test.UpdateSource("testdata/immutability/step2") | ||
up = test.Up() | ||
|
||
// Only the mutable configmap and secret should have been updated -- so no | ||
// impact on those two downstreams. | ||
assert.Equal(t, mutableConfigmap, up.Outputs["mutableConfigmap"].Value.(string)) | ||
assert.Equal(t, mutableSecret, up.Outputs["mutableSecret"].Value.(string)) | ||
// All others should have been replaced, which should have regenerated our | ||
// random pets. | ||
assert.NotEqual(t, secret, up.Outputs["secret"].Value.(string)) | ||
assert.NotEqual(t, configmap, up.Outputs["configmap"].Value.(string)) | ||
assert.NotEqual(t, autonamedSecret, up.Outputs["autonamedSecret"].Value.(string)) | ||
assert.NotEqual(t, autonamedConfigmap, up.Outputs["autonamedConfigmap"].Value.(string)) | ||
// Record the new outputs. | ||
secret = up.Outputs["secret"].Value.(string) | ||
configmap = up.Outputs["configmap"].Value.(string) | ||
autonamedSecret = up.Outputs["autonamedSecret"].Value.(string) | ||
autonamedConfigmap = up.Outputs["autonamedConfigmap"].Value.(string) | ||
|
||
// The final step only touches annotations. All resources should have been | ||
// updated. | ||
test.UpdateSource("testdata/immutability/step3") | ||
up = test.Up() | ||
assert.Equal(t, secret, up.Outputs["secret"].Value.(string)) | ||
assert.Equal(t, configmap, up.Outputs["configmap"].Value.(string)) | ||
assert.Equal(t, autonamedSecret, up.Outputs["autonamedSecret"].Value.(string)) | ||
assert.Equal(t, autonamedConfigmap, up.Outputs["autonamedConfigmap"].Value.(string)) | ||
assert.Equal(t, mutableConfigmap, up.Outputs["mutableConfigmap"].Value.(string)) | ||
assert.Equal(t, mutableSecret, up.Outputs["mutableSecret"].Value.(string)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: immutability | ||
runtime: yaml | ||
description: | | ||
Test mutability and immutability for Secrets and ConfigMaps, as well as | ||
replacement interactions with downstream dependencies. | ||
resources: | ||
ns: | ||
type: kubernetes:core/v1:Namespace | ||
|
||
provider: | ||
type: pulumi:providers:kubernetes | ||
properties: | ||
enableSecretMutable: true | ||
enableConfigMapMutable: true | ||
namespace: ${ns.metadata.name} | ||
|
||
secret: | ||
type: kubernetes:core/v1:Secret | ||
options: | ||
provider: ${provider} | ||
properties: | ||
metadata: | ||
name: secret | ||
immutable: true | ||
stringData: | ||
foo: "foo" | ||
|
||
configmap: | ||
type: kubernetes:core/v1:ConfigMap | ||
options: | ||
provider: ${provider} | ||
properties: | ||
metadata: | ||
name: configmap | ||
immutable: true | ||
data: | ||
foo: "foo" | ||
|
||
autonamed-secret: | ||
type: kubernetes:core/v1:Secret | ||
options: | ||
provider: ${provider} | ||
properties: | ||
immutable: true | ||
stringData: | ||
foo: "foo" | ||
|
||
autonamed-configmap: | ||
type: kubernetes:core/v1:ConfigMap | ||
options: | ||
provider: ${provider} | ||
properties: | ||
immutable: true | ||
data: | ||
foo: "foo" | ||
|
||
mutable-secret: | ||
type: kubernetes:core/v1:Secret | ||
options: | ||
provider: ${provider} | ||
properties: | ||
stringData: | ||
foo: "foo" | ||
|
||
mutable-configmap: | ||
type: kubernetes:core/v1:ConfigMap | ||
options: | ||
provider: ${provider} | ||
properties: | ||
data: | ||
foo: "foo" | ||
|
||
# Downstreams should not be impacted by updates but should be updated when | ||
# upstreams are replaced. | ||
|
||
secret-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${secret.metadata.name} | ||
|
||
configmap-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${configmap.metadata.name} | ||
|
||
autonamed-secret-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${autonamed-secret.metadata.name} | ||
|
||
autonamed-configmap-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${autonamed-configmap.metadata.name} | ||
|
||
mutable-secret-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${mutable-secret.metadata.name} | ||
|
||
mutable-configmap-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${mutable-configmap.metadata.name} | ||
|
||
outputs: | ||
secret: ${secret-downstream.id} | ||
configmap: ${configmap-downstream.id} | ||
autonamedSecret: ${autonamed-secret-downstream.id} | ||
autonamedConfigmap: ${autonamed-configmap-downstream.id} | ||
mutableSecret: ${mutable-secret-downstream.id} | ||
mutableConfigmap: ${mutable-configmap-downstream.id} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
name: immutability | ||
runtime: yaml | ||
description: | | ||
Test mutability and immutability for Secrets and ConfigMaps, as well as | ||
replacement interactions with downstream dependencies. | ||
resources: | ||
ns: | ||
type: kubernetes:core/v1:Namespace | ||
|
||
provider: | ||
type: pulumi:providers:kubernetes | ||
properties: | ||
enableSecretMutable: true | ||
enableConfigMapMutable: true | ||
namespace: ${ns.metadata.name} | ||
|
||
secret: | ||
type: kubernetes:core/v1:Secret | ||
options: | ||
provider: ${provider} | ||
properties: | ||
metadata: | ||
name: secret | ||
immutable: true | ||
stringData: | ||
# foo -> bar | ||
bar: "bar" | ||
|
||
configmap: | ||
type: kubernetes:core/v1:ConfigMap | ||
options: | ||
provider: ${provider} | ||
properties: | ||
metadata: | ||
name: configmap | ||
immutable: true | ||
data: | ||
# foo -> bar | ||
bar: "bar" | ||
|
||
autonamed-secret: | ||
type: kubernetes:core/v1:Secret | ||
options: | ||
provider: ${provider} | ||
properties: | ||
immutable: true | ||
stringData: | ||
# foo -> bar | ||
bar: "bar" | ||
|
||
autonamed-configmap: | ||
type: kubernetes:core/v1:ConfigMap | ||
options: | ||
provider: ${provider} | ||
properties: | ||
immutable: true | ||
data: | ||
# foo -> bar | ||
bar: "bar" | ||
|
||
mutable-secret: | ||
type: kubernetes:core/v1:Secret | ||
options: | ||
provider: ${provider} | ||
properties: | ||
stringData: | ||
# foo -> bar | ||
bar: "bar" | ||
|
||
mutable-configmap: | ||
type: kubernetes:core/v1:ConfigMap | ||
options: | ||
provider: ${provider} | ||
properties: | ||
data: | ||
# foo -> bar | ||
bar: "bar" | ||
|
||
# Downstreams should not be impacted by updates but should be updated when | ||
# upstreams are replaced. | ||
|
||
secret-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${secret.metadata.name} | ||
|
||
configmap-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${configmap.metadata.name} | ||
|
||
autonamed-secret-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${autonamed-secret.metadata.name} | ||
|
||
autonamed-configmap-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${autonamed-configmap.metadata.name} | ||
|
||
mutable-secret-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${mutable-secret.metadata.name} | ||
|
||
mutable-configmap-downstream: | ||
type: random:RandomPet | ||
properties: | ||
keepers: | ||
upstream: ${mutable-configmap.metadata.name} | ||
|
||
outputs: | ||
secret: ${secret-downstream.id} | ||
configmap: ${configmap-downstream.id} | ||
autonamedSecret: ${autonamed-secret-downstream.id} | ||
autonamedConfigmap: ${autonamed-configmap-downstream.id} | ||
mutableSecret: ${mutable-secret-downstream.id} | ||
mutableConfigmap: ${mutable-configmap-downstream.id} |
Oops, something went wrong.