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

tag configMap data nodes as 'string' #3229

Merged
merged 2 commits into from
May 23, 2022

Conversation

natasha41575
Copy link
Contributor

@natasha41575 natasha41575 commented May 23, 2022

Fixes #3193

First commit moves some code around and adds a (broken) test demonstrating current behavior. Second commit provides the fix for #3193.

When underlying go-yaml sees non-string values (e.g. integers or booleans), they must be explicitly tagged as strings in order to be quoted and processed correctly by other yaml-processing code.

With the following input:

data := map[string]string{
    "normal string": "abc",
    "integer":       "8081",
    "float":         "1.23",
    "bool":          "true",
}
m, err := NewConfigMap(data)
fmt.Println(m.MustString())

Before this fix:

apiVersion: v1
kind: ConfigMap
metadata:
  name: function-input
data: {normal string: abc, integer: 8081, float: 1.23, bool: true} # this is invalid

After this fix:

apiVersion: v1
kind: ConfigMap
metadata:
  name: function-input
data: {normal string: abc, integer: "8081", float: "1.23", bool: "true"}

@natasha41575 natasha41575 changed the title Configmapregression tag configMap data nodes as 'string' May 23, 2022
@natasha41575
Copy link
Contributor Author

@droot PTAL

@natasha41575 natasha41575 merged commit b5403ad into kptdev:main May 23, 2022
@natasha41575 natasha41575 deleted the configmapregression branch May 23, 2022 21:46
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.

Cannot unmarshal some ConfigMap values
2 participants