Skip to content

Commit

Permalink
fix issue on apiVersion where apiVersion is put at the end (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
bthuillier authored Jun 5, 2024
1 parent 15e9eaa commit a0a578e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion printutils/printYaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func printResource(w io.Writer, data interface{}) error {
if !ok {
fmt.Fprint(w, string(yamlBytes))
} else {
wantedKeys := []string{"version", "kind", "metadata", "spec"}
wantedKeys := []string{"apiVersion", "kind", "metadata", "spec"}
for _, wantedKey := range wantedKeys {
printKeyYaml(w, wantedKey, asMap[wantedKey])
}
Expand Down
8 changes: 4 additions & 4 deletions printutils/printYaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestPrintResourceLikeYamlOnSingleResource(t *testing.T) {
resourceFromBe := `{"spec": "someSpec", "version": "v4", "kind": "Gelato", "metadata": "arancia"}`
resourceFromBe := `{"spec": "someSpec", "apiVersion": "v4", "kind": "Gelato", "metadata": "arancia"}`
var data interface{}
err := json.Unmarshal([]byte(resourceFromBe), &data)
if err != nil {
Expand All @@ -17,7 +17,7 @@ func TestPrintResourceLikeYamlOnSingleResource(t *testing.T) {
var output bytes.Buffer
PrintResourceLikeYamlFile(&output, data)
expected := strings.TrimSpace(`
version: v4
apiVersion: v4
kind: Gelato
metadata: arancia
spec: someSpec`)
Expand Down Expand Up @@ -52,7 +52,7 @@ cat`)
}

func TestPrintResourceLikeYamlOnMultileResources(t *testing.T) {
resourceFromBe := `{"spec": "someSpec", "version": "v4", "newKind": "Gelato", "metadata": "arancia"}`
resourceFromBe := `{"spec": "someSpec", "apiVersion": "v4", "newKind": "Gelato", "metadata": "arancia"}`
var data interface{}
err := json.Unmarshal([]byte(resourceFromBe), &data)
if err != nil {
Expand All @@ -61,7 +61,7 @@ func TestPrintResourceLikeYamlOnMultileResources(t *testing.T) {
var output bytes.Buffer
PrintResourceLikeYamlFile(&output, data)
expected := strings.TrimSpace(`
version: v4
apiVersion: v4
metadata: arancia
spec: someSpec
newKind: Gelato
Expand Down

0 comments on commit a0a578e

Please sign in to comment.