https://pulumi.com logo
#kubernetes
Title
# kubernetes
w

worried-knife-31967

08/09/2023, 8:45 PM
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

curved-kitchen-24115

08/09/2023, 10:56 PM
TIL: C# does not have macros like C/C++ 😞
w

worried-knife-31967

08/10/2023, 10:43 AM
in what context? I could absolutely abstract that into a method, or a property, but the ugly code would still exist?
c

curved-kitchen-24115

08/10/2023, 7:36 PM
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

silly-match-22314

08/14/2023, 7:28 PM
w

worried-city-86458

08/25/2023, 8:25 PM
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
2 Views