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

Unable to set property value to nil in golang #4529

Open
iliapolo opened this issue Jun 3, 2024 · 0 comments
Open

Unable to set property value to nil in golang #4529

iliapolo opened this issue Jun 3, 2024 · 0 comments
Labels
bug This issue is a bug. language/go Regarding GoLang bindings p2

Comments

@iliapolo
Copy link
Contributor

iliapolo commented Jun 3, 2024

Describe the bug

Using cdk8s, I want to set a specific property to have the YAML null value. Not seeing a way to do this.

Expected Behavior

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    foo: bar
    foo2: null
  name: my-chart-my-cm-c841940f

Current Behavior

Synthesizing application
panic: parameter value is required, but nil was provided

goroutine 1 [running]:
github.com/cdk8s-team/cdk8s-core-go/cdk8s/v2.JsonPatch_Replace(0xc000014b80, {0x0, 0x0})
        /Users/epolon/go/pkg/mod/github.com/cdk8s-team/cdk8s-core-go/cdk8s/[email protected]/JsonPatch.go:168 +0x106
main.main()
        /private/tmp/cdk8s-go/main.go:25 +0x2af
exit status 2
Error: command "go run . " at /private/tmp/cdk8s-go returned a non-zero exit code 1
    at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/cdk8s-cli/lib/util.js:54:27)
    at Object.onceWrapper (node:events:634:26)
    at ChildProcess.emit (node:events:519:28)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12)

Reproduction Steps

package main

import (
	"example.com/cdk8s-go/imports/k8s"
	"github.com/aws/jsii-runtime-go"
	"github.com/cdk8s-team/cdk8s-core-go/cdk8s/v2"
)

func main() {
	app := cdk8s.NewApp(&cdk8s.AppProps{})

	chart := cdk8s.NewChart(app, jsii.String("my-chart"), &cdk8s.ChartProps{})

	labels := map[string]*string{
		"foo1": jsii.String("bar1"),
	}
	cm := k8s.NewKubeConfigMap(chart, jsii.String("my-cm"), &k8s.KubeConfigMapProps{
		Metadata: &k8s.ObjectMeta{
			Labels: &labels,
		}})

	app.Synth()

	cm.AddJsonPatch(cdk8s.JsonPatch_Add(jsii.String("/metadata/labels/foo2"), nil))
}

Possible Solution

No response

Additional Information/Context

cdk8s-team/cdk8s#2162

SDK version used

    "jsii-pacmak": "^1.98.0",
    "jsii-rosetta": "^5.4.21",
    "jsii-srcmak": "^0.1.1142",

Environment details (OS name and version, etc.)

Darwin bcd07455aba8 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000 arm64

@iliapolo iliapolo added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. language/go Regarding GoLang bindings p2 and removed needs-triage This issue or PR still needs to be triaged. labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. language/go Regarding GoLang bindings p2
Projects
None yet
Development

No branches or pull requests

1 participant