diff --git a/CHANGELOG.md b/CHANGELOG.md index 67d2f060b1..e9218e0863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Improvements - Update nodejs SDK to use optional chaining in constructor. (https://github.com/pulumi/pulumi-kubernetes/pull/959). +- Automatically set Secret inputs as pulumi.secret. (https://github.com/pulumi/pulumi-kubernetes/pull/961). ## 1.4.5 (January 22, 2020) diff --git a/pkg/gen/python-templates/kind.py.mustache b/pkg/gen/python-templates/kind.py.mustache index cc95d0423e..dc4ffe8955 100644 --- a/pkg/gen/python-templates/kind.py.mustache +++ b/pkg/gen/python-templates/kind.py.mustache @@ -68,10 +68,10 @@ class {{Kind}}(pulumi.CustomResource): {{#RequiredInputProperties}} if {{LanguageName}} is None: raise TypeError('Missing required property {{LanguageName}}') - __props__['{{Name}}'] = {{LanguageName}} + __props__['{{Name}}'] = {{DefaultValue}} {{/RequiredInputProperties}} {{#OptionalInputProperties}} - __props__['{{Name}}'] = {{LanguageName}} + __props__['{{Name}}'] = {{DefaultValue}} {{/OptionalInputProperties}} __props__['status'] = None diff --git a/pkg/gen/typegen.go b/pkg/gen/typegen.go index 7f3be67a29..ee2015280a 100644 --- a/pkg/gen/typegen.go +++ b/pkg/gen/typegen.go @@ -1020,6 +1020,7 @@ func createGroups(definitionsJSON map[string]interface{}, opts groupOpts) []*Gro languageName = propName case python: languageName = pycodegen.PyName(propName) + defaultValue = languageName case dotnet: name := propName if name[0] == '$' { @@ -1037,6 +1038,18 @@ func createGroups(definitionsJSON map[string]interface{}, opts groupOpts) []*Gro panic(fmt.Sprintf("Unsupported language '%s'", opts.language)) } + // Set Secret input fields to pulumi.secret + if d.gvk.Kind == "Secret" && (propName == "stringData" || propName == "data") { + switch opts.language { + case typescript: + defaultValue = fmt.Sprintf( + "args?.%s === undefined ? undefined : pulumi.secret(args?.%s)", propName, propName) + case python: + defaultValue = fmt.Sprintf("pulumi.Output.secret(%s) if %s is not None else None", + languageName, languageName) + } + } + return &Property{ comment: fmtComment(prop["description"], prefix, false, opts, d.gvk), pythonConstructorComment: fmtComment(prop["description"], prefix+prefix+" ", true, opts, d.gvk), diff --git a/sdk/nodejs/core/v1/Secret.ts b/sdk/nodejs/core/v1/Secret.ts index 49d96bb849..3b77ab27d3 100755 --- a/sdk/nodejs/core/v1/Secret.ts +++ b/sdk/nodejs/core/v1/Secret.ts @@ -105,10 +105,10 @@ import { getVersion } from "../../version"; const props: pulumi.Inputs = {}; props["apiVersion"] = "v1"; - props["data"] = args?.data; + props["data"] = args?.data === undefined ? undefined : pulumi.secret(args?.data); props["kind"] = "Secret"; props["metadata"] = args?.metadata; - props["stringData"] = args?.stringData; + props["stringData"] = args?.stringData === undefined ? undefined : pulumi.secret(args?.stringData); props["type"] = args?.type; props["status"] = undefined; diff --git a/sdk/python/pulumi_kubernetes/core/v1/Secret.py b/sdk/python/pulumi_kubernetes/core/v1/Secret.py index 0b0c4d051f..a840d083f4 100755 --- a/sdk/python/pulumi_kubernetes/core/v1/Secret.py +++ b/sdk/python/pulumi_kubernetes/core/v1/Secret.py @@ -102,9 +102,9 @@ def __init__(self, resource_name, opts=None, data=None, metadata=None, string_da __props__['apiVersion'] = 'v1' __props__['kind'] = 'Secret' - __props__['data'] = data + __props__['data'] = pulumi.Output.secret(data) if data is not None else None __props__['metadata'] = metadata - __props__['stringData'] = string_data + __props__['stringData'] = pulumi.Output.secret(string_data) if string_data is not None else None __props__['type'] = type __props__['status'] = None