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

[Bug]: NewXMLConfigurationFromMap resulting xml property order may be different #81

Closed
whg517 opened this issue Jul 15, 2024 · 0 comments · Fixed by #82
Closed

[Bug]: NewXMLConfigurationFromMap resulting xml property order may be different #81

whg517 opened this issue Jul 15, 2024 · 0 comments · Fixed by #82
Labels
bug Something isn't working

Comments

@whg517
Copy link
Member

whg517 commented Jul 15, 2024

Describe the bug

Because maps are unordered, when you add an xml configuration based on map data, the property order may differ in the serialized xml string for the same data. When a configmap is created, the configmap object is constantly updated.

Reproduction

package main

import (
	"testing"

	"github.com/zncdatadev/operator-go/pkg/util"
)

var (
	data = map[string]string{
		"username": "admin",
		"age":      "18",
		"email":    "[email protected]",
	}
)

func Test(t *testing.T) {

	c1, err := util.NewXMLConfigurationFromMap(data).Marshal()

	if err != nil {
		t.Error(err)
	}

	c2, err := util.NewXMLConfigurationFromMap(data).Marshal()

	if err != nil {
		t.Error(err)
	}

	if c1 != c2 {
		t.Errorf("c1: %s, c2: %s", c1, c2)
	}

}

Screenshot

No response

Logs

No response

System Info

- github.com/zncdatadev/operator-go v0.8.1
- go version go1.22.4 darwin/arm64

Severity

I can work around it

@whg517 whg517 added the bug Something isn't working label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant