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

chilly-rainbow-79265

09/08/2020, 11:36 AM
How to parse this tag from stack file
Copy code
demo:tags:
    Environment: Development
Copy code
type Tags struct {
	Tags map[string]pulumi.String `yaml:"tags"`
}
...
cfg := config.New(ctx, "")
var tags Tags 
if err := cfg.GetObject("tags", &tags); err != nil {
	return err
}
...
...
server, err := NewVMInstance(ctx, name, &VMInstanceArgs{
  Tags:  pulumi.StringMap(tags), // This part is throwing error 
  // cannot convert v.Tags (variable of type map[string]pulumi.String) to pulumi.StringMap
})
l

lemon-agent-27707

09/08/2020, 12:49 PM
The
Tags
type you're unmarshalling to should just be a plain map[string]string. The rest of the answer is here https://github.com/pulumi/pulumi-azure/issues/460#issuecomment-688840667
c

chilly-rainbow-79265

09/08/2020, 12:51 PM
I already tried the same, but facing error
Copy code
panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x100 pc=0x2091753]
    goroutine 1 [running]:
    main.NewVMInstance(0xc0001da200, 0xc0001e5d90, 0xb, 0xc00022f7e8, 0x0, 0x0, 0x0, 0xc0001e6460, 0x0, 0x0)
        /home/rajeshr/Documents/projects/IaC/pulumi/cassandra/infra/vminstance.go:85 +0x9d3
    main.main.func1(0xc0001da200, 0x2738530, 0x13)
        /home/rajeshr/Documents/projects/IaC/pulumi/cassandra/infra/main.go:163 +0xbee
    <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.RunWithContext(0xc0001da200|github.com/pulumi/pulumi/sdk/v2/go/pulumi.RunWithContext(0xc0001da200>, 0x2769840, 0xc0000424ef, 0x4)
        /home/rajeshr/go_code/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/pulumi/run.go:101 +0x1ff
    <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.RunErr(0x2769840|github.com/pulumi/pulumi/sdk/v2/go/pulumi.RunErr(0x2769840>, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/rajeshr/go_code/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/pulumi/run.go:82 +0x20a
    <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.Run(0x2769840|github.com/pulumi/pulumi/sdk/v2/go/pulumi.Run(0x2769840>, 0x0, 0x0, 0x0)
        /home/rajeshr/go_code/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/pulumi/run.go:39 +0x59
    main.main()
        /home/rajeshr/Documents/projects/IaC/pulumi/cassandra/infra/main.go:106 +0x3e
    exit status 2

    error: an unhandled error occurred: program exited with non-zero exit code: 1
Hi @lemon-agent-27707 What should we do to make fmt.Print* work in main.go, or other files. That'll be a huge help for debugging. In the above case I'm pretty sure, I did goofed up something.
6 Views