-
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.
fix: ensure data is not dropped when normalizing Secrets (#2514)
Co-authored-by: Levi Blackstone <[email protected]>
- Loading branch information
1 parent
26ddf79
commit 3dc1233
Showing
5 changed files
with
126 additions
and
16 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
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
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
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
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,69 @@ | ||
// Copyright 2016-2022, Pulumi Corporation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import * as pulumi from "@pulumi/pulumi"; | ||
import * as k8s from "@pulumi/kubernetes"; | ||
|
||
const config = new pulumi.Config(); | ||
|
||
const pw = config.requireSecret("message"); | ||
const rawPW = config.require("message")+"updated"; // Add suffix | ||
|
||
const provider = new k8s.Provider("k8s"); | ||
|
||
const cmData = new k8s.core.v1.ConfigMap("cmdata", { | ||
data: { | ||
password: pw, | ||
} | ||
}, {provider}); | ||
|
||
const cmBinaryData = new k8s.core.v1.ConfigMap("cmbinarydata", { | ||
binaryData: { | ||
password: pw.apply(d => Buffer.from(d).toString("base64")), | ||
} | ||
}, {provider}); | ||
|
||
const ssStringData = new k8s.core.v1.Secret("ssstringdata", { | ||
stringData: { | ||
password: rawPW, | ||
} | ||
}, {provider}); | ||
|
||
const ssData = new k8s.core.v1.Secret("ssdata", { | ||
data: { | ||
password: Buffer.from(rawPW).toString("base64"), | ||
} | ||
}, {provider}); | ||
|
||
const randSuffix = Math.random().toString(36).substring(7); | ||
const name = `test-${randSuffix}`; | ||
|
||
const secretYaml = ` | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: ${name} | ||
stringData: | ||
password: ${rawPW} | ||
` | ||
const cg = new k8s.yaml.ConfigGroup("example", { | ||
yaml: secretYaml, | ||
}, {provider}); | ||
|
||
export const cmDataData = cmData.data; | ||
export const cmBinaryDataData = cmBinaryData.binaryData; | ||
export const ssStringDataData = ssStringData.data; | ||
export const ssStringDataStringData = ssStringData.stringData; | ||
export const ssDataData = ssData.data; | ||
export const cgSecret = cg.getResource("v1/Secret", name).stringData; |