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

Jazzyfresh/codegen python nonstring secrets #11494

Merged
merged 1 commit into from Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: pkg
description: Fixes codegen/python generation of non-string secrets in provider properties
10 changes: 8 additions & 2 deletions pkg/codegen/python/gen.go
Expand Up @@ -1301,11 +1301,17 @@ func (mod *modContext) genResource(res *schema.Resource) (string, error) {
// If this resource is a provider then, regardless of the schema of the underlying provider
// type, we must project all properties as strings. For all properties that are not strings,
// we'll marshal them to JSON and use the JSON string as a string input.
handledSecret := false
if res.IsProvider && !isStringType(prop.Type) {
arg = fmt.Sprintf("pulumi.Output.from_input(%s).apply(pulumi.runtime.to_json) if %s is not None else None", arg, arg)
if prop.Secret {
arg = fmt.Sprintf("pulumi.Output.secret(%s).apply(pulumi.runtime.to_json) if %s is not None else None", arg, arg)
handledSecret = true
} else {
arg = fmt.Sprintf("pulumi.Output.from_input(%s).apply(pulumi.runtime.to_json) if %s is not None else None", arg, arg)
}
}
name := PyName(prop.Name)
if prop.Secret {
if prop.Secret && !handledSecret {
fmt.Fprintf(w, " __props__.__dict__[%[1]q] = None if %[2]s is None else pulumi.Output.secret(%[2]s)\n", name, arg)
} else {
fmt.Fprintf(w, " __props__.__dict__[%q] = %s\n", name, arg)
Expand Down
7 changes: 4 additions & 3 deletions pkg/codegen/testing/test/sdk_driver.go
Expand Up @@ -151,9 +151,10 @@ var PulumiPulumiSDKTests = []*SDKTest{
Description: "Simple schema encoded using YAML",
},
{
Directory: "provider-config-schema",
Description: "Simple provider config schema",
SkipCompileCheck: codegen.NewStringSet(dotnet),
Directory: "provider-config-schema",
Description: "Simple provider config schema",
// For golang skip check, see https://github.com/pulumi/pulumi/issues/11567
SkipCompileCheck: codegen.NewStringSet(dotnet, golang),
},
{
Directory: "replace-on-change",
Expand Down
@@ -1,6 +1,6 @@
---
title: "configstation"
title_tag: "configstation.configstation"
title_tag: "configstation Package"
meta_desc: ""
layout: api
no_edit_this_page: true
Expand All @@ -11,6 +11,11 @@ no_edit_this_page: true



<h2 id="modules">Modules</h2>
<ul class="api">
<li><a href="config/" title="config"><span class="api-symbol api-symbol--module"></span>config</a></li>
</ul>

<h2 id="resources">Resources</h2>
<ul class="api">
<li><a href="provider" title="Provider"><span class="api-symbol api-symbol--resource"></span>Provider</a></li>
Expand Down
@@ -1,6 +1,7 @@
{
"emittedFiles": [
"_index.md",
"config/_index.md",
"funcwithalloptionalinputs/_index.md",
"provider/_index.md"
]
Expand Down
@@ -0,0 +1,23 @@
---
title: "config"
title_tag: "configstation.config"
meta_desc: "Explore the resources and functions of the configstation.config module."
layout: api
no_edit_this_page: true
---

<!-- WARNING: this file was generated by test. -->
<!-- Do not edit by hand unless you're certain you know what you are doing! -->

Explore the resources and functions of the configstation.config module.

<h2 id="package-details">Package Details</h2>
<dl class="package-details">
<dt>Repository</dt>
<dd><a href=""></a></dd>
<dt>License</dt>
<dd></dd>
<dt>Version</dt>
<dd>0.0.1</dd>
</dl>

Expand Up @@ -32,7 +32,8 @@ no_edit_this_page: true
<div class="highlight"><pre class="chroma"><code class="language-python" data-lang="python"><span class=nd>@overload</span>
<span class="k">def </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">resource_name</span><span class="p">:</span> <span class="nx">str</span><span class="p">,</span>
<span class="nx">opts</span><span class="p">:</span> <span class="nx"><a href="/docs/reference/pkg/python/pulumi/#pulumi.ResourceOptions">Optional[ResourceOptions]</a></span> = None<span class="p">,</span>
<span class="nx">favorite_color</span><span class="p">:</span> <span class="nx">Optional[Union[str, Color]]</span> = None<span class="p">)</span>
<span class="nx">favorite_color</span><span class="p">:</span> <span class="nx">Optional[Union[str, Color]]</span> = None<span class="p">,</span>
<span class="nx">secret_sandwiches</span><span class="p">:</span> <span class="nx">Optional[Sequence[_config.SandwichArgs]]</span> = None<span class="p">)</span>
<span class=nd>@overload</span>
<span class="k">def </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">resource_name</span><span class="p">:</span> <span class="nx">str</span><span class="p">,</span>
<span class="nx">args</span><span class="p">:</span> <span class="nx"><a href="#inputs">Optional[ProviderArgs]</a></span> = None<span class="p">,</span>
Expand Down Expand Up @@ -228,6 +229,15 @@ The Provider resource accepts the following [input](/docs/intro/concepts/inputs-
<span class="property-type">string | <a href="#color">Configstation.<wbr>Pulumi.<wbr>Configstation.<wbr>Color</a></span>
</dt>
<dd><p>this is a relaxed string enum which can also be set via env var It can also be sourced from the following environment variable: <code>FAVE_COLOR</code></p>
</dd><dt class="property-optional"
title="Optional">
<span id="secretsandwiches_csharp">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#secretsandwiches_csharp" style="color: inherit; text-decoration: inherit;">Secret<wbr>Sandwiches</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#sandwich">List&lt;Configstation.<wbr>Pulumi.<wbr>Configstation.<wbr>Config.<wbr>Inputs.<wbr>Sandwich<wbr>Args&gt;</a></span>
</dt>
<dd><p>Super duper secret sandwiches.</p>
</dd></dl>
</pulumi-choosable>
</div>
Expand All @@ -243,6 +253,15 @@ The Provider resource accepts the following [input](/docs/intro/concepts/inputs-
<span class="property-type">string | <a href="#color">Color</a></span>
</dt>
<dd><p>this is a relaxed string enum which can also be set via env var It can also be sourced from the following environment variable: <code>FAVE_COLOR</code></p>
</dd><dt class="property-optional"
title="Optional">
<span id="secretsandwiches_go">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#secretsandwiches_go" style="color: inherit; text-decoration: inherit;">Secret<wbr>Sandwiches</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#sandwich">Sandwich<wbr>Args</a></span>
</dt>
<dd><p>Super duper secret sandwiches.</p>
</dd></dl>
</pulumi-choosable>
</div>
Expand All @@ -258,6 +277,15 @@ The Provider resource accepts the following [input](/docs/intro/concepts/inputs-
<span class="property-type">String | <a href="#color">Color</a></span>
</dt>
<dd><p>this is a relaxed string enum which can also be set via env var It can also be sourced from the following environment variable: <code>FAVE_COLOR</code></p>
</dd><dt class="property-optional"
title="Optional">
<span id="secretsandwiches_java">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#secretsandwiches_java" style="color: inherit; text-decoration: inherit;">secret<wbr>Sandwiches</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#sandwich">List&lt;Sandwich<wbr>Args&gt;</a></span>
</dt>
<dd><p>Super duper secret sandwiches.</p>
</dd></dl>
</pulumi-choosable>
</div>
Expand All @@ -273,6 +301,15 @@ The Provider resource accepts the following [input](/docs/intro/concepts/inputs-
<span class="property-type">string | <a href="#color">Color</a></span>
</dt>
<dd><p>this is a relaxed string enum which can also be set via env var It can also be sourced from the following environment variable: <code>FAVE_COLOR</code></p>
</dd><dt class="property-optional"
title="Optional">
<span id="secretsandwiches_nodejs">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#secretsandwiches_nodejs" style="color: inherit; text-decoration: inherit;">secret<wbr>Sandwiches</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#sandwich">config<wbr>Sandwich<wbr>Args[]</a></span>
</dt>
<dd><p>Super duper secret sandwiches.</p>
</dd></dl>
</pulumi-choosable>
</div>
Expand All @@ -288,6 +325,15 @@ The Provider resource accepts the following [input](/docs/intro/concepts/inputs-
<span class="property-type">str | <a href="#color">Color</a></span>
</dt>
<dd><p>this is a relaxed string enum which can also be set via env var It can also be sourced from the following environment variable: <code>FAVE_COLOR</code></p>
</dd><dt class="property-optional"
title="Optional">
<span id="secret_sandwiches_python">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#secret_sandwiches_python" style="color: inherit; text-decoration: inherit;">secret_<wbr>sandwiches</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#sandwich">Sandwich<wbr>Args]</a></span>
</dt>
<dd><p>Super duper secret sandwiches.</p>
</dd></dl>
</pulumi-choosable>
</div>
Expand All @@ -303,6 +349,15 @@ The Provider resource accepts the following [input](/docs/intro/concepts/inputs-
<span class="property-type">String | <a href="#color">&#34;blue&#34; | &#34;red&#34;</a></span>
</dt>
<dd><p>this is a relaxed string enum which can also be set via env var It can also be sourced from the following environment variable: <code>FAVE_COLOR</code></p>
</dd><dt class="property-optional"
title="Optional">
<span id="secretsandwiches_yaml">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#secretsandwiches_yaml" style="color: inherit; text-decoration: inherit;">secret<wbr>Sandwiches</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#sandwich">List&lt;Property Map&gt;</a></span>
</dt>
<dd><p>Super duper secret sandwiches.</p>
</dd></dl>
</pulumi-choosable>
</div>
Expand Down Expand Up @@ -464,6 +519,140 @@ All [input](#inputs) properties are implicitly available as output properties. A
</pulumi-choosable>
</div>

<h4 id="sandwich">Sandwich</h4>

<div>
<pulumi-choosable type="language" values="csharp">
<dl class="resources-properties"><dt class="property-optional"
title="Optional">
<span id="bread_csharp">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#bread_csharp" style="color: inherit; text-decoration: inherit;">Bread</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
</dt>
<dd></dd><dt class="property-optional"
title="Optional">
<span id="veggies_csharp">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#veggies_csharp" style="color: inherit; text-decoration: inherit;">Veggies</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">List&lt;string&gt;</span>
</dt>
<dd></dd></dl>
</pulumi-choosable>
</div>

<div>
<pulumi-choosable type="language" values="go">
<dl class="resources-properties"><dt class="property-optional"
title="Optional">
<span id="bread_go">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#bread_go" style="color: inherit; text-decoration: inherit;">Bread</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
</dt>
<dd></dd><dt class="property-optional"
title="Optional">
<span id="veggies_go">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#veggies_go" style="color: inherit; text-decoration: inherit;">Veggies</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">[]string</span>
</dt>
<dd></dd></dl>
</pulumi-choosable>
</div>

<div>
<pulumi-choosable type="language" values="java">
<dl class="resources-properties"><dt class="property-optional"
title="Optional">
<span id="bread_java">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#bread_java" style="color: inherit; text-decoration: inherit;">bread</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">String</span>
</dt>
<dd></dd><dt class="property-optional"
title="Optional">
<span id="veggies_java">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#veggies_java" style="color: inherit; text-decoration: inherit;">veggies</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">List&lt;String&gt;</span>
</dt>
<dd></dd></dl>
</pulumi-choosable>
</div>

<div>
<pulumi-choosable type="language" values="javascript,typescript">
<dl class="resources-properties"><dt class="property-optional"
title="Optional">
<span id="bread_nodejs">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#bread_nodejs" style="color: inherit; text-decoration: inherit;">bread</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
</dt>
<dd></dd><dt class="property-optional"
title="Optional">
<span id="veggies_nodejs">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#veggies_nodejs" style="color: inherit; text-decoration: inherit;">veggies</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string[]</span>
</dt>
<dd></dd></dl>
</pulumi-choosable>
</div>

<div>
<pulumi-choosable type="language" values="python">
<dl class="resources-properties"><dt class="property-optional"
title="Optional">
<span id="bread_python">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#bread_python" style="color: inherit; text-decoration: inherit;">bread</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">str</span>
</dt>
<dd></dd><dt class="property-optional"
title="Optional">
<span id="veggies_python">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#veggies_python" style="color: inherit; text-decoration: inherit;">veggies</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">Sequence[str]</span>
</dt>
<dd></dd></dl>
</pulumi-choosable>
</div>

<div>
<pulumi-choosable type="language" values="yaml">
<dl class="resources-properties"><dt class="property-optional"
title="Optional">
<span id="bread_yaml">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#bread_yaml" style="color: inherit; text-decoration: inherit;">bread</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">String</span>
</dt>
<dd></dd><dt class="property-optional"
title="Optional">
<span id="veggies_yaml">
<a data-swiftype-name="resource-property" data-swiftype-type="text" href="#veggies_yaml" style="color: inherit; text-decoration: inherit;">veggies</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">List&lt;String&gt;</span>
</dt>
<dd></dd></dl>
</pulumi-choosable>
</div>


<h2 id="package-details">Package Details</h2>
<dl class="package-details">
Expand Down
Expand Up @@ -46,6 +46,22 @@ public sealed class ProviderArgs : global::Pulumi.ResourceArgs
[Input("favoriteColor", json: true)]
public InputUnion<string, Configstation.Pulumi.Configstation.Color>? FavoriteColor { get; set; }

[Input("secretSandwiches", json: true)]
private InputList<Configstation.Pulumi.Configstation.Config.Inputs.SandwichArgs>? _secretSandwiches;

/// <summary>
/// Super duper secret sandwiches.
/// </summary>
public InputList<Configstation.Pulumi.Configstation.Config.Inputs.SandwichArgs> SecretSandwiches
{
get => _secretSandwiches ?? (_secretSandwiches = new InputList<Configstation.Pulumi.Configstation.Config.Inputs.SandwichArgs>());
set
{
var emptySecret = Output.CreateSecret(ImmutableArray.Create<Configstation.Pulumi.Configstation.Config.Inputs.SandwichArgs>());
_secretSandwiches = Output.All(value, emptySecret).Apply(v => v[0]);
}
}

public ProviderArgs()
{
FavoriteColor = Utilities.GetEnv("FAVE_COLOR");
Expand Down