magnificent-helicopter-3467
06/21/2022, 6:06 AMPulumi.dev.yaml
of the following form:
config:
gcp-go-gke:data:
cluster:
initialNodeCount: 2
machineType: n1-standard-2
name: my-cluster
registry:
appLabel: my-proj
deployment:
containers:
- image: us-central1-docker.pkg.dev/my-gcloud-proj/my-gcloud-repo/my-image:0.1.0
name: my-image
name: my-deployment
replicas: 1
namespace:
metadata:
name: namespace-meta
name: my-namespace
service:
name: my-service
port: 80
serviceType: LoadBalancer
targetPort: 8080
gcp:project: my-proj
gcp:zone: us-west1-a
In main.go
, I have the following code:
type Data struct {
cluster Cluster
registry Registry
}
type Cluster struct {
initialNodeCount int
machineType string
name string
}
type Registry struct {
appLabel string
deployment Deployment
namespace Namespace
service Service
}
type Deployment struct {
containers []Container
name string
replicas int
}
type Namespace struct {
metadata Metadata
name string
}
type Service struct {
name string
port int
targetPort int
serviceType string
}
type Container struct {
image string
name string
}
type Metadata struct {
name string
}
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
var d Data
cfg := config.New(ctx, "")
cfg.RequireObject("data", &d)
engineVersions, err := container.GetEngineVersions(ctx, &container.GetEngineVersionsArgs{})
if err != nil {
return err
}
masterVersion := engineVersions.LatestMasterVersion
cluster, err := container.NewCluster(ctx, d.cluster.name, &container.ClusterArgs{
...
}
The cfg.RequireObject
call does not panic, but d.cluster.name
resolves to ""
. I’m using this doc as a reference to read structured configuration. Any tips for troubleshooting why the config is not read properly? I used verbose logging ( pulumi up --logtostderr --logflow -v=9 2> out.txt
) but didn’t find anything useful in the logs. Thanks in advance for your help/guidance! 🙂echoing-dinner-19531
06/21/2022, 10:19 AMfmt.Println("ENV:", os.Getenv("PULUMI_CONFIG"))
to check the program config looks right. Should be a JSON object with all your values in it.magnificent-helicopter-3467
06/21/2022, 3:59 PMechoing-dinner-19531
06/21/2022, 4:24 PMmagnificent-helicopter-3467
06/21/2022, 7:58 PMconfig:
gcp-go-gke:data:
cluster:
name: my-cluster
gcp:project: my-proj
gcp:zone: us-west1-a
`main.go`:
type Data struct {
cluster Cluster
}
type Cluster struct {
name string
}
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
var d Data
cfg := config.New(ctx, "")
cfg.RequireObject("data", &d)
fmt.Println("Cluster name is:", d.cluster.name)
return nil
})
}
And d.cluster.name
here is ""
RequireObject
can properly populate the passed in struct.echoing-dinner-19531
06/22/2022, 9:32 AM