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

don't modify input when converting to orderedmap #870

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

notoriaga
Copy link
Contributor

I'm integrating with ytt as a library and noticed that when I convert an object to an orderedmap.Map the input object gets modified. I'm not sure if that's intended but right now it requires me to deepcopy the input before converting which is a little unfortunate.

"github.com/vmware-tanzu/carvel-ytt/pkg/orderedmap"
)

func TestFromUnorderedMaps(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test fails without the changes to convert.go


// some sources (e.g. toml library) yield specific type of slices.
// slices in Go are not covariant, so each flavor of slice must have its own case, here.
// process these exactly the same way we do for generic slices (prior case)
case []map[string]interface{}:
resultArray := make([]interface{}, len(typedObj))
result := make([]interface{}, len(typedObj))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed this because all the other case blocks use result as the new variable name

Copy link
Member

@prembhaskal prembhaskal left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@prembhaskal prembhaskal left a comment

Choose a reason for hiding this comment

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

1 nit, other part looks fine.

@@ -0,0 +1,23 @@
package orderedmap_test

Copy link
Member

Choose a reason for hiding this comment

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

nit: could you please add header.

@prembhaskal
Copy link
Member

go: carvel.dev/ytt/pkg/orderedmap tested by
carvel.dev/ytt/pkg/orderedmap.test imports
github.com/vmware-tanzu/carvel-ytt/pkg/orderedmap: no required module provides package github.com/vmware-tanzu/carvel-ytt/pkg/orderedmap; to add it:
go get github.com/vmware-tanzu/carvel-ytt/pkg/orderedmap
Error: Process completed with exit code 1.

@notoriaga I think commit should be rebased because we recently changes the module name to carvel.dev/ytt

@notoriaga notoriaga force-pushed the steve/orderedmap-fix branch from 1322d92 to 6b3bdc8 Compare February 15, 2024 17:11
@notoriaga notoriaga force-pushed the steve/orderedmap-fix branch from 6b3bdc8 to 1b92636 Compare February 15, 2024 17:12
@notoriaga
Copy link
Contributor Author

go: carvel.dev/ytt/pkg/orderedmap tested by
carvel.dev/ytt/pkg/orderedmap.test imports
github.com/vmware-tanzu/carvel-ytt/pkg/orderedmap: no required module provides package github.com/vmware-tanzu/carvel-ytt/pkg/orderedmap; to add it:
go get github.com/vmware-tanzu/carvel-ytt/pkg/orderedmap
Error: Process completed with exit code 1.

@notoriaga I think commit should be rebased because we recently changes the module name to carvel.dev/ytt

Ahh I see, thanks!

Signed-off-by: notoriaga <[email protected]>
@prembhaskal
Copy link
Member

LGTM
@100mik @cppforlife Please take a look.

Copy link
Member

@joaopapereira joaopapereira left a comment

Choose a reason for hiding this comment

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

LGTM

@joaopapereira joaopapereira merged commit 9d65662 into carvel-dev:develop Mar 13, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants