sparse-intern-71089
02/08/2022, 2:10 AMchilly-plastic-75584
02/08/2022, 2:11 AMOnlyyaml bool `yaml:"onlyyaml"`
ConfigMountPath string `yaml:"configmountpath"`
Configdatamapname string `yaml:"configdatamapname"`
Dapr struct {
Enabled bool `yaml:"enabled"`
AppID string `yaml:"appid"`
AppPort int `yaml:"appport"`
EnableMetrics bool `yaml:"enablemetrics"`
MetricsPort int `yaml:"metricsport"`
SidecarCPULimit string `yaml:"sidecarcpulimit"`
SidecarCPURequest string `yaml:"sidecarcpurequest"`
SidecarMemoryLimit string `yaml:"sidecarmemorylimit"`
SidecarMemoryRequest string `yaml:"sidecarmemory-request"`
} `yaml:"dapr"`
Datadog struct {
Enabled bool `yaml:"enabled"`
} `yaml:"datadog"`
Deployment string `yaml:"deployment"`
Environment string `yaml:"environment"`
Image struct {
Pullpolicy string `yaml:"pullpolicy"`
Repository string `yaml:"repository"`
Tag string `yaml:"tag"`
Secretname string `yaml:"secretname"`
} `yaml:"image"`
}
and i'm so confused š after hours of debugging.
In the example above say Dapr
is loaded fine by cfg.RequireObject("data", &configData)
However, despite Dapr struct loaded the nested values from pulumi config and the cli returning the pulumi get config --path 'data.problemstruct
when loaded by pulumi it only pulls in 3 values and all the rest are empty. I have tried inline
modifier and moved to it's own config path at the same level as data
, and nothing changes.
I never see the values populated at any stage despite the cli being able to load and my yaml mapping being correct (i believe).
Any hints?bored-table-20691
02/08/2022, 2:22 AMbored-table-20691
02/08/2022, 2:23 AMchilly-plastic-75584
02/08/2022, 2:23 AMRedisHost string `yaml:"redis_host,omitempty"`
I want the yaml tag to be redis_host
when I unmarshal and also later when I marshal back to a string. However, it seems to be unable to match that until I changed to redisHost
.I have no idea why as I thought the tag was independent of the name.chilly-plastic-75584
02/08/2022, 2:24 AMbored-table-20691
02/08/2022, 2:24 AMchilly-plastic-75584
02/08/2022, 2:24 AMAPIHost `yaml:"APIHost"`
chilly-plastic-75584
02/08/2022, 2:24 AMchilly-plastic-75584
02/08/2022, 2:24 AMapi_host
being the matching wordchilly-plastic-75584
02/08/2022, 2:25 AMchilly-plastic-75584
02/08/2022, 2:25 AMbored-table-20691
02/08/2022, 2:26 AMbored-table-20691
02/08/2022, 2:26 AMchilly-plastic-75584
02/08/2022, 2:26 AMchilly-plastic-75584
02/08/2022, 2:28 AMtype AppConfig struct {
Env string `yaml:"env,omitempty"`
Jsonlogs bool `yaml:"jsonlogs,omitempty"`
Debug bool `yaml:"debug,omitempty"`
APIHost string `yaml:"APIHost,omitempty"`
// Not working APIHost string `yaml:"api_host,omitempty"`
// Not working APIHost string `yaml:"apihost,omitempty"`
}
var appConfig AppConfig
cfg := config.New(ctx, "")
cfg.RequireObject("appconfig", &appConfig)
// appConfig == env, jsonlogs, debug show up, but APIHost
chilly-plastic-75584
02/08/2022, 2:28 AMbored-table-20691
02/08/2022, 2:29 AMchilly-plastic-75584
02/08/2022, 2:29 AMmarshalledConfigVals, err := yaml.Marshal(appConfig)
cfgMap, err = corev1.NewConfigMap(ctx, configData.ServiceConfigMapName(), &corev1.ConfigMapArgs{
Metadata: &metav1.ObjectMetaArgs{
Labels: configData.AppPulumiStringMap(),
},
Data: pulumi.StringMap{configData.Configdatamapname: pulumi.String(string(marshalledConfigVals))},
Immutable: pulumi.Bool(true),
}, pulumi.Provider(prov))
chilly-plastic-75584
02/08/2022, 2:31 AMportal:appconfig:
api_host: my_api_host
apihost: my_apihost
APIHost: my_APIHost
api_port: 80
db_connection: ifipostthisimadevopsN00b
debug: true
env: dev
jsonlogs: true
redis_host: redis:6379
chilly-plastic-75584
02/08/2022, 2:32 AMyaml "<http://github.com/goccy/go-yaml|github.com/goccy/go-yaml>"
However, the core issue is even though it says the appdata was a required object, it wasn't able to map any of the properties apparently till I did that APIHost: val
which makes no sense to me at this time at leastchilly-plastic-75584
02/08/2022, 2:32 AMbored-table-20691
02/08/2022, 2:34 AMbored-table-20691
02/08/2022, 2:35 AMchilly-plastic-75584
02/08/2022, 2:37 AMchilly-plastic-75584
02/08/2022, 2:38 AMchilly-plastic-75584
02/08/2022, 2:38 AMchilly-plastic-75584
02/08/2022, 2:38 AMbored-table-20691
02/08/2022, 2:43 AMbored-table-20691
02/08/2022, 2:44 AMchilly-plastic-75584
02/08/2022, 2:44 AMbored-table-20691
02/08/2022, 2:44 AMchilly-plastic-75584
02/08/2022, 6:27 PMbored-table-20691
02/08/2022, 6:28 PMbored-table-20691
02/08/2022, 6:29 PMchilly-plastic-75584
02/08/2022, 6:33 PMbored-table-20691
02/08/2022, 6:34 PMchilly-plastic-75584
02/08/2022, 6:35 PMcfgMap, err = corev1.NewConfigMap(ctx, configData.ServiceConfigMapName(), &corev1.ConfigMapArgs{
Metadata: &metav1.ObjectMetaArgs{
Labels: configData.AppPulumiStringMap(),
},
Data: pulumi.StringMap(appconfig), // <<<< Example. Whatever the type, I just pass in the stringmap.
Immutable: pulumi.Bool(true),
}, pulumi.Provider(prov))
instead I was asked to generate a yaml config that gets mounted into the container at a path, not env variables.
cfgMap, err = corev1.NewConfigMap(ctx, configData.ServiceConfigMapName(), &corev1.ConfigMapArgs{
Metadata: &metav1.ObjectMetaArgs{
Labels: configData.AppPulumiStringMap(),
},
Data: pulumi.StringMap{"/config/config.yml": pulumi.String(string(marshalledConfigVals))}, <<< example string map, but the key = file path and the value = the yaml marshalled string
Immutable: pulumi.Bool(true),
}, pulumi.Provider(prov))
chilly-plastic-75584
02/08/2022, 6:36 PMtype AppConfig struct
from the pulumi config and passing to the ConfigMap to create. This way my config stays in Pulumi, but generates the yaml in the plan.chilly-plastic-75584
02/08/2022, 6:36 PMbored-table-20691
02/08/2022, 6:38 PMbored-table-20691
02/08/2022, 6:38 PMjson
piece being surprising. I think the rest is mostly just normal Go code.bored-table-20691
02/08/2022, 6:40 PMchilly-plastic-75584
02/08/2022, 6:45 PMbored-table-20691
02/08/2022, 6:49 PMbored-table-20691
02/08/2022, 6:51 PMchilly-plastic-75584
02/08/2022, 6:52 PMbored-table-20691
02/08/2022, 6:56 PM