Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with yaml transformation in go helm/v3 #1369

Closed
hagaibarel opened this issue Nov 10, 2020 · 2 comments · Fixed by #1420
Closed

Error with yaml transformation in go helm/v3 #1369

hagaibarel opened this issue Nov 10, 2020 · 2 comments · Fixed by #1420
Assignees

Comments

@hagaibarel
Copy link

Problem description

Using []yaml.transformation with helm/v3 while the same code works with helm/v2:

error: program failed: json: unsupported type: func(map[string]interface {}, ...pulumi.ResourceOption)
    exit status 1
 
    error: an unhandled error occurred: program exited with non-zero exit code: 1

Affected product version(s)

pulumi v2.13.2
pulumi-kubernetes sdk v2.6.3
go version 1.15.3

Reproducing the issue

consider the following pulumi program:

package main

import (
	"github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes/helm/v3"
	"github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes/yaml"
	"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {

		_, err := helm.NewChart(ctx, "jaeger-operator", helm.ChartArgs{
			Chart: pulumi.String("jaeger-operator"),
			FetchArgs: helm.FetchArgs{
				Repo: pulumi.String("https://jaegertracing.github.io/helm-charts"),
			},
			Transformations: []yaml.Transformation{
				// when the operator pod starts it overrides the
				// .spec.selector of svc/jaeger-operator-metrics field to
				// `name=jaeger-operator` which is missing from the pod labels,
				// so the endpoints are never created. we add that label here to mitigate that
				func(state map[string]interface{}, opts ...pulumi.ResourceOption) {
					if state["kind"] == "Deployment" {
						podTemplate := state["spec"].(map[string]interface{})["template"].(map[string]interface{})
						podLabels := podTemplate["metadata"].(map[string]interface{})["labels"].(map[string]interface{})
						podLabels["name"] = "jaeger-operator"
					}
				},
			},
		})
		if err != nil {
			return err
		}

		return nil
	})
}

it fails with the error above, but using github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes/helm/v2 works as expected and pulumi is able to create the resources just fine

@hagaibarel
Copy link
Author

Any updates? Still seeing this with pulumi v2.16.1 and pulumi-kubernetes v2.7.5

@lblackstone
Copy link
Member

Sorry for the delayed response -- I fixed the bug in the linked PR, and this fix should be in the next k8s provider release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants