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

astonishing-nightfall-90291

08/27/2023, 3:58 AM
Hi All, i'm starting to work with pulumi and golang as a way to train myself with the language as I'm not that experienced. I'm building a homelab stack for myself with Proxmox and some other stuff alongside with PiHole for DNS I'm trying to use the go-pihole for creating a DNS, outside of pulumi provider as it's not supported yet (maybe in a future I can see myself implementing one) But the problem I have now is that I'm requiring a secret, with
piholeToken := c.RequireSecret("piholeToken")
to use it with my pihole code, but the problem is that the
APIToken
field expects a string and
RequireSecret
returns a
pulumi.StringOutput
I've tried the
ApplyT
approach but didn't have any success. because both the IDE and the
pulumi up
complains that it's not the same type. even after using as per docs. Maybe it's just my lack of knowledge in Golang, but I can't make it work... Can someone shed a light on what am I missing? Here's the piece of code
Copy code
piToken := c.RequireSecret("piholeToken").ApplyT(func(s string) string { return s }).(pulumi.StringOutput)

	fmt.Println(piToken)
	pc := pihole.New(pihole.Config{
		BaseURL:    "<http://pi.hole>,",
		APIToken:   piToken,
		HttpClient: nil,
		Headers:    nil,
	})
	err = utils.NewPiHoleRecord(ctx, pc, "A", name, cArgs.IPv4)
s

salmon-account-74572

08/28/2023, 2:49 PM
Try getting rid of the
ApplyT
and instead set
APIToken: pulumi.String(piToken)
and see if that works.
a

astonishing-nightfall-90291

10/14/2023, 12:35 AM
I had to go out for a bit and forgot to answer, Sorry sad panda. But that doesn't work 😕 because the
APIToken
doesn't support
pulumi.String
as a type. That's why I tried the
ApplyT
Here's a screenshot from the IDE
3 Views