https://pulumi.com logo
#golang
Title
# golang
r

ripe-shampoo-80285

01/04/2022, 2:39 AM
Anybody knows how to create a ConfigMap from a config.yaml file using Golang Pulumi?
b

billowy-army-68599

01/04/2022, 3:01 AM
@ripe-shampoo-80285 what would be in the
config.yaml
? if it's just a Kubernetes configmap, you can use this: https://www.pulumi.com/registry/packages/kubernetes/api-docs/yaml/configfile/
r

ripe-shampoo-80285

01/04/2022, 3:10 AM
@billowy-army-68599 the config.yaml is application specific configuration not a k8s configmap manifest file. thresholds: - name: default speed: 110 posJump: 1 - name: foo speed: 100 posJump: 1.5
b

billowy-army-68599

01/04/2022, 3:14 AM
got it, hold on I'll throw an example together
something like this:
Copy code
dat, err := ioutil.ReadFile("assets/config.yaml")
		if err != nil {
			return err
		}

		_, err = corev1.NewConfigMap(ctx, "example", &corev1.ConfigMapArgs{
			Data: pulumi.StringMap{"data": pulumi.String(string(dat))},
		})
		if err != nil {
			return err
		}
I haven't tested that, but it should work
r

ripe-shampoo-80285

01/04/2022, 3:21 AM
@billowy-army-68599 Great, I will give it try, thank you!
Thanks @billowy-army-68599 It worked. I changed ioutil.ReadFile to os.ReadFile because the ioutil package is deprecated since Golang 1.16
b

billowy-army-68599

01/04/2022, 3:50 AM
huh, TIL! thanks!
3 Views