Quick one. I have an args property of `Input<s...
# dotnet
r
Quick one. I have an args property of
Input<string>
and I need to assign it to an
object
type in my values object map, but implicit typing doesn't kick in so the assigned value is Input<T>. See below... the
args.DatadogApiKey
is `Input<string>`:
Copy code
var datadogChart = new Chart("datadog-chart",
                new ChartArgs
                {
                    Chart = "datadog",
                    Version = args.DatadogChartVersion,
                    Namespace = "default",
                    Values = new Dictionary<string, object>
                    {
                        ["datadog"] = new Dictionary<string, object>
                        {
                            ["apiKey"] = args.DatadogApiKey,
                            ["site"] = "<http://datadoghq.eu|datadoghq.eu>"
                        },
                    }
                });
t
You may need something like
args.DatadogApiKey.Apply(v => (object)v)
r
I need the string. This is the best I can do, which is horrendous on the eyes:
Copy code
string datadogApiKey;
args.DatadogApiKey.Apply(x =>
{
    datadogApiKey = x;
    return x;
});
t
What is the problem with your original code? Does it fail at runtime?
r
Yes, because the value of ["apiKey"] is Input<string> and not string, I assume
t
What’s the error?
r
The helm chart fails because of an invalid API key value
Copy code
Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="invocation of kubernetes:helm:template returned an error: failed to generate YAML for specified Helm chart: failed to create chart from template: template: datadog/templates/NOTES.txt:1:56: executing "datadog/templates/NOTES.txt" at <eq .Values.datadog.apiKey "<DATADOG_API_KEY>">: error calling eq: uncomparable type map[string]interface {}: map[]", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1632296140.606362300","description":"Error received from peer ipv4:127.0.0.1:38555","file":"/var/local/git/grpc/src/core/lib/surface/call.cc","file_line":1068,"grpc_message":"invocation of kubernetes:helm:template returned an error: failed to generate YAML for specified Helm chart: failed to create chart from template: template: datadog/templates/NOTES.txt:1:56: executing "datadog/templates/NOTES.txt" at <eq .Values.datadog.apiKey "<DATADOG_API_KEY>">: error calling eq: uncomparable type map[string]interface {}: map[]","grpc_status":2}")
t
I see. You can’t get string from Input<string>, so you may need an Apply like
Copy code
Values = args.DatadogApiKey.Apply(apiKey => new Dictionary<string, object>
                    {
                        ["datadog"] = new Dictionary<string, object>
                        {
                            ["apiKey"] = apiKey,
                            ["site"] = "<http://datadoghq.eu|datadoghq.eu>"
                        },
                    })
1
r
Thanks. I suppose Values will then be an
Output<T>
Let me play around