Has anyone got a neater/cleaner way of providing V...
# kubernetes
w
Has anyone got a neater/cleaner way of providing Values to a Helm chart in C#? mine just looks ugly, and when it gets bigger, even worse..
Copy code
Values = new Dictionary<string, object> {
                ["environment"] = new [] {
                    new Dictionary<string, object> {
                        ["name"] = "REFINERY_HONEYCOMB_API_KEY",
                        ["valueFrom"] = new Dictionary<string, object> {
                            ["secretKeyRef"] = new Dictionary<string, object> {
                                ["name"] = secretApiKey.Id.Apply(a => a.Split("/")[1]),
                                ["key"] = "honeycomb-api-key"
                            }
                        }
                    }
                },
                ["RulesConfigMapName"] = refineryRulesConfigMap.Metadata.Apply(m => m.Name)
            }
c
TIL: C# does not have macros like C/C++ 😞
w
in what context? I could absolutely abstract that into a method, or a property, but the ugly code would still exist?
c
yeah, in my mind I was conceiving of a set of C preprocessor macros that could produce the output and save your eyes - at the expense of additional complexity. But C# doesn’t have preprocessor macros apparently https://stackoverflow.com/questions/709463/c-sharp-macro-definitions-in-preprocessor
s
w
Except for the top-level key name and then depending on nested key names you can use anonymous types like I do here: https://github.com/gitfool/Pulumi.Dungeon/blob/cd3927c294c32848076cd6f52ce97183b532464a/K8s/K8sStack.cs#L147