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

ConfigGroup (V2) resources aren't useable in Pulumi Go SDK #2910

Open
Tracked by #1971
EronWright opened this issue Mar 26, 2024 · 1 comment
Open
Tracked by #1971

ConfigGroup (V2) resources aren't useable in Pulumi Go SDK #2910

EronWright opened this issue Mar 26, 2024 · 1 comment
Labels
area/yaml blocked The issue cannot be resolved without 3rd party action. kind/bug Some behavior is incorrect or out of spec

Comments

@EronWright
Copy link
Contributor

What happened?

I tried to write a Go SDK program that post-processes the resources produced by yamlv2.ConfigGroup. I found that the array elements aren't coercible to pulumi.Resource nor to *corev1.ConfigMap (the concrete resource type).

Example

package main

import (
	corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1"
	yamlv2 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/yaml/v2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := yamlv2.NewConfigGroup(ctx, "example", &yamlv2.ConfigGroupArgs{
			Objs: pulumi.Array{
				pulumi.Map{
					"apiVersion": pulumi.String("v1"),
					"kind":       pulumi.String("ConfigMap"),
					"metadata": pulumi.Map{
						"name": pulumi.String("my-map"),
					},
				},
			},
		})
		if err != nil {
			return err
		}

		_ = example.Resources.Index(pulumi.Int(0)).ApplyT(func(r any) error {
			res := r.(pulumi.Resource) // <-- BUG: r is not a "pulumi.Resource"
			ctx.Log.Info("Hello World", &pulumi.LogArgs{Resource: res})

			configMap := r.(*corev1.ConfigMap) // <-- BUG: r is a "corev1.ConfigMap" not a "*corev1.ConfigMap"
			ctx.Export("configMapUid", configMap.Metadata.Uid())
			return nil
		})

		return nil
	})
}

Output of pulumi about

CLI          
Version      3.108.1
Go Version   go1.22.0
Go Compiler  gc

Plugins
NAME        VERSION
go          unknown
kubernetes  4.10.0

Host     
OS       darwin
Version  13.5.1
Arch     arm64

Additional context

Root cause issue: pulumi/pulumi#15788

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@EronWright EronWright added kind/bug Some behavior is incorrect or out of spec area/yaml needs-triage Needs attention from the triage team labels Mar 26, 2024
@EronWright
Copy link
Contributor Author

A fix is under development in pu/pu for how resource reference outputs are handled:
pulumi/pulumi@8cd0a87

Also a pulumi.json/#Resource schema type will be introduced, such that the resources output property have a pulumi.ResourceArrayOutput type.

Once these are done, then we'll update the provider to use the Resource type:
#2918

@EronWright EronWright removed the needs-triage Needs attention from the triage team label Apr 1, 2024
@blampe blampe added the blocked The issue cannot be resolved without 3rd party action. label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/yaml blocked The issue cannot be resolved without 3rd party action. kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants