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

handle formatting of empty but not nil structs #65

Closed
wants to merge 2 commits into from

Conversation

rawlingsj
Copy link
Member

@rawlingsj rawlingsj commented Aug 6, 2024

Initially this is a test case to demonstrate what I'm hoping for. The test will fail, not 100% sure where to fix, maybe in encoder.go? I tried adding the below to the marshalMapping function but we get an extra indented line so figure there's more to it.

	if len(node.Content) == 0 {
		// This is an empty mapping node, we should return "{}"
		return []byte("{}\n"), nil
	}

Here's an example of what happens without this support https://github.com/rawlingsj/wolfi-os/pull/2064/files#diff-c1e7e6d93bdcfdbf44020ead40b6f83e46b82b28422c8a70fd48accc5e6acdd0L44

Signed-off-by: James Rawlings <jrawlings@chainguard.dev>
…ging it to nil

Signed-off-by: James Rawlings <jrawlings@chainguard.dev>
Comment on lines +202 to +207
// Handle empty mappings explicitly
//if len(node.Content) == 0 {
// return []byte("{}"), nil
//}

// Marshal non-empty mappings
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed but will close this PR anyways in favour of #66

@rawlingsj rawlingsj closed this Aug 13, 2024
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 this pull request may close these issues.

1 participant