Skip to content

Commit

Permalink
chart values are indented 2 spaces instead of 4 (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert authored Apr 3, 2023
1 parent eedddba commit 177a4c4
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 121 deletions.
4 changes: 4 additions & 0 deletions changelog/v0.29.5/440-chart-yaml-indent-2-space.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changelog:
- type: FIX
description: chart values are indented 2 spaces instead of 4
issueLink: https://github.com/solo-io/skv2/issues/440
7 changes: 5 additions & 2 deletions codegen/render/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,14 @@ func wrapWords(s string, limit int) string {
}

func fromNode(n goyaml.Node) string {
b, err := goyaml.Marshal(sortYAML(&n))
buf := new(bytes.Buffer)
encoder := goyaml.NewEncoder(buf)
encoder.SetIndent(2)
err := encoder.Encode(sortYAML(&n))
if err != nil {
panic(err)
}
return string(b)
return buf.String()
}

// Implement sorting for prettier yaml
Expand Down
82 changes: 41 additions & 41 deletions codegen/render/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,45 +81,45 @@ var _ = Describe("toYAMLWithComments", func() {
Field1: Hello, comments
# a map to a list of structs
Field10:
hello:
- # nested field 1
FieldN1: field
- # nested field 1
FieldN1: ten
# list of field 2
Field2:
hello:
- # nested field 1
FieldN1: Hello!
FieldN1: field
- # nested field 1
FieldN1: Hello!
FieldN1: ten
# list of field 2
Field2:
- # nested field 1
FieldN1: Hello!
- # nested field 1
FieldN1: Hello!
# a field that is a pointer to another type
Field3:
# nested field 1
FieldN1: Hello field 3
# nested field 1
FieldN1: Hello field 3
# a field that is a pointer to a list of types
Field4:
- # nested field 1
FieldN1: Field4
- null
- # nested field 1
FieldN1: Field4
- null
# a list of scalars
Field6:
- hello
- field
- six
- hello
- field
- six
# a map of scalars to scalars
Field7:
hello1: hello 1
hello2: hello 2
hello1: hello 1
hello2: hello 2
# a map to a struct
Field8:
hello:
# nested field 1
FieldN1: field 8
hello:
# nested field 1
FieldN1: field 8
# a map to a pointer to a struct
Field9:
hello:
# nested field 1
FieldN1: field 9
hello:
# nested field 1
FieldN1: field 9
# non standard field name
fieldfive: hello field 5
`)))
Expand Down Expand Up @@ -172,8 +172,8 @@ var _ = Describe("toYAMLWithComments", func() {
actual := render.FromNode(node)
Expect(actual).To(Equal(prepareExpected(`
childType:
# field c1
FieldC1: ""
# field c1
FieldC1: ""
`)))
})

Expand Down Expand Up @@ -227,20 +227,20 @@ var _ = Describe("toYAMLWithComments", func() {
Expect(render.FromNode(node)).To(Equal(prepareExpected(`
# my interface field
Field1:
# nested field 1
FieldN1: field1 n1
# nested field 1
FieldN1: field1 n1
# my map of interface field
Field2:
field2:
# nested field 1
FieldN1: Hello!
field3:
# nested field 1
FieldN1: map value is pointer to nested type!
field2:
# nested field 1
FieldN1: Hello!
field3:
# nested field 1
FieldN1: map value is pointer to nested type!
# yet another interface field
Field3:
# nested field 1
FieldN1: interface is pointer to nested type!
# nested field 1
FieldN1: interface is pointer to nested type!
# yet another interface field 2
Field4: hello, world!
`)))
Expand All @@ -267,12 +267,12 @@ var _ = Describe("toYAMLWithComments", func() {
Expect(render.FromNode(node)).To(Equal(prepareExpected(`
# nested pointer type
Field1:
# nested field 1
FieldN1: Hello, world!
# nested field 1
FieldN1: Hello, world!
# doubly nested pointer type
Field2:
# nested field 1
FieldN1: Hello, world!
# nested field 1
FieldN1: Hello, world!
`)))
})

Expand Down
36 changes: 18 additions & 18 deletions codegen/test/chart-no-desc/values.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Code generated by skv2. DO NOT EDIT.

painter:
enabled: true
env:
- name: FOO
value: BAR
floatingUserId: false
image:
enabled: true
env:
- name: FOO
value: BAR
floatingUserId: false
image:
pullPolicy: IfNotPresent
registry: quay.io/solo-io
repository: painter
tag: v0.0.0
ports: {}
runAsUser: 10101
serviceType: ""
sidecars:
palette:
env: null
image:
pullPolicy: IfNotPresent
registry: quay.io/solo-io
repository: painter
repository: palette
tag: v0.0.0
ports: {}
runAsUser: 10101
serviceType: ""
sidecars:
palette:
env: null
image:
pullPolicy: IfNotPresent
registry: quay.io/solo-io
repository: palette
tag: v0.0.0

30 changes: 15 additions & 15 deletions codegen/test/chart-sidecar/values.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Code generated by skv2. DO NOT EDIT.

painter:
enabled: true
env: null
floatingUserId: false
image:
enabled: true
env: null
floatingUserId: false
image:
pullPolicy: IfNotPresent
registry: quay.io/solo-io
repository: painter
tag: v0.0.0
ports: {}
runAsUser: 10101
serviceType: ""
sidecars:
fooBar:
env: null
image:
pullPolicy: IfNotPresent
registry: quay.io/solo-io
repository: painter
tag: v0.0.0
ports: {}
runAsUser: 10101
serviceType: ""
sidecars:
fooBar:
env: null
image:
pullPolicy: IfNotPresent
registry: quay.io/solo-io
repository: painter
tag: v0.0.0

36 changes: 18 additions & 18 deletions codegen/test/chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Code generated by skv2. DO NOT EDIT.

painter:
enabled: true
env:
- name: FOO
value: BAR
floatingUserId: false
image:
enabled: true
env:
- name: FOO
value: BAR
floatingUserId: false
image:
pullPolicy: IfNotPresent
registry: quay.io/solo-io
repository: painter
tag: v0.0.0
ports: {}
runAsUser: 10101
serviceType: ""
sidecars:
palette:
env: null
image:
pullPolicy: IfNotPresent
registry: quay.io/solo-io
repository: painter
repository: palette
tag: v0.0.0
ports: {}
runAsUser: 10101
serviceType: ""
sidecars:
palette:
env: null
image:
pullPolicy: IfNotPresent
registry: quay.io/solo-io
repository: palette
tag: v0.0.0

54 changes: 27 additions & 27 deletions codegen/test/name_override_chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# Code generated by skv2. DO NOT EDIT.

overrideName:
# Enable creation of the deployment/service.
enabled: true
# Environment variables for the container. For more info, see the [Kubernetes
# documentation](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#envvarsource-v1-core).
env: null
# Allow the pod to be assigned a dynamic user ID. Required for OpenShift
# installations.
floatingUserId: false
# Container image.
image:
# Image pull policy.
pullPolicy: IfNotPresent
# Image registry.
registry: quay.io/solo-io
# Image name (repository).
repository: painter
# Version tag for the container image.
tag: v0.0.0
# Service ports as a map from port name to port number.
ports: {}
# Static user ID to run the containers as. Unused if floatingUserId is 'true'.
runAsUser: 10101
# Kubernetes service type. Can be either "ClusterIP", "NodePort", "LoadBalancer",
# or "ExternalName".
serviceType: ""
# Optional configuration for the deployed containers.
sidecars: {}
# Enable creation of the deployment/service.
enabled: true
# Environment variables for the container. For more info, see the [Kubernetes
# documentation](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#envvarsource-v1-core).
env: null
# Allow the pod to be assigned a dynamic user ID. Required for OpenShift
# installations.
floatingUserId: false
# Container image.
image:
# Image pull policy.
pullPolicy: IfNotPresent
# Image registry.
registry: quay.io/solo-io
# Image name (repository).
repository: painter
# Version tag for the container image.
tag: v0.0.0
# Service ports as a map from port name to port number.
ports: {}
# Static user ID to run the containers as. Unused if floatingUserId is 'true'.
runAsUser: 10101
# Kubernetes service type. Can be either "ClusterIP", "NodePort", "LoadBalancer",
# or "ExternalName".
serviceType: ""
# Optional configuration for the deployed containers.
sidecars: {}

0 comments on commit 177a4c4

Please sign in to comment.