Does anyone have any info on how to convert `pulum...
# golang
b
Does anyone have any info on how to convert
pulumi.StringOutput
to base64?
b
One way to do this could be to convert the
pulumi.StringOutput
to a string, convert the string to a byte slice, and create a
base64
encoded string from the byte slice:
Copy code
// convert pulumi.StringOutput to a string
stringOutput := fmt.Sprintf("%v", <insert your pulumi.StringOutput>)

// convert string to byte slice
bytes := []byte(stringOutput)

// encode the byte slice in base64
encoded := base64.StdEncoding.EncodeToString(bytes)
b
thank you,i will try it here!
i must be doing something wrong, cause it seems i get an address
{0xc0003798f0}
i basically return this:
return pulumi.Sprintf(...)
inside i a string with some
%s
as
pulumi.StringOutput
arguments..
Copy code
`func generateUserData(clusterEndpoint pulumi.StringOutput, certData pulumi.StringOutput, clusterName pulumi.StringOutput, extraRuntime string) pulumi.StringOutput {
	return pulumi.Sprintf(`
[settings.kubernetes]
api-server = "%s"
cluster-certificate = "%s"
cluster-name = "%s"

[settings.kubernetes.node-labels]
"extraRuntime" = "%s"
"host-os" = "bottle-rocket"
`, clusterEndpoint, certData, clusterName, extraRuntime)
}
Then:
Copy code
userData := generateUserData(eksCluster.EksCluster.Endpoint(), eksCluster.EksCluster.CertificateAuthority().Data().Elem(), eksCluster.EksCluster.Name(), "default")
	stringOutput := fmt.Sprintf("%v", userData)
	fmt.Println(stringOutput)

	// convert string to byte slice
	bytes := []byte(stringOutput)

	// encode the byte slice in base64
	encoded := base64.StdEncoding.EncodeToString(bytes)
	fmt.Println(encoded)
i will, debug more wheni have some time
263 Views