Skip to content

Commit 3a6afed

Browse files
perdasilvaPer G. da Silva
andauthored
🌱 Add yamlfmt to ensure consistent testdata yaml file formatting (#2284)
* Add yamlfmt bingo tool and update fmt Makefile target Signed-off-by: Per G. da Silva <[email protected]> * Apply consistent formatting to testdata yml files Signed-off-by: Per G. da Silva <[email protected]> --------- Signed-off-by: Per G. da Silva <[email protected]> Co-authored-by: Per G. da Silva <[email protected]>
1 parent 926d57e commit 3a6afed

17 files changed

+248
-232
lines changed

.bingo/Variables.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,9 @@ $(SETUP_ENVTEST): $(BINGO_DIR)/setup-envtest.mod
9595
@echo "(re)installing $(GOBIN)/setup-envtest-v0.0.0-20250620151452-b9a9ca01fd37"
9696
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=setup-envtest.mod -o=$(GOBIN)/setup-envtest-v0.0.0-20250620151452-b9a9ca01fd37 "sigs.k8s.io/controller-runtime/tools/setup-envtest"
9797

98+
YAMLFMT := $(GOBIN)/yamlfmt-v0.20.0
99+
$(YAMLFMT): $(BINGO_DIR)/yamlfmt.mod
100+
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
101+
@echo "(re)installing $(GOBIN)/yamlfmt-v0.20.0"
102+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=yamlfmt.mod -o=$(GOBIN)/yamlfmt-v0.20.0 "github.com/google/yamlfmt/cmd/yamlfmt"
103+

.bingo/variables.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ OPM="${GOBIN}/opm-v1.51.0"
3434

3535
SETUP_ENVTEST="${GOBIN}/setup-envtest-v0.0.0-20250620151452-b9a9ca01fd37"
3636

37+
YAMLFMT="${GOBIN}/yamlfmt-v0.20.0"
38+

.bingo/yamlfmt.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
2+
3+
go 1.24.4
4+
5+
require github.com/google/yamlfmt v0.20.0 // cmd/yamlfmt

.bingo/yamlfmt.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
github.com/bmatcuk/doublestar/v4 v4.7.1 h1:fdDeAqgT47acgwd9bd9HxJRDmc9UAmPpc+2m0CXv75Q=
2+
github.com/bmatcuk/doublestar/v4 v4.7.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
3+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
5+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
6+
github.com/google/yamlfmt v0.20.0 h1:EfMuMFEZGnXPn2NY+KgJTH9sNs6P+am/Of6IwE2K6P8=
7+
github.com/google/yamlfmt v0.20.0/go.mod h1:gs0UEklJOYkUJ+OOCG0hg9n+DzucKDPlJElTUasVNK8=
8+
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
9+
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
10+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11+
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
12+
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
13+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
14+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
15+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
16+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ fix-lint: $(GOLANGCI_LINT) #EXHELP Fix lint issues
186186
$(GOLANGCI_LINT) run --fix --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)
187187

188188
.PHONY: fmt
189-
fmt: #EXHELP Formats code
189+
fmt: $(YAMLFMT) #EXHELP Formats code
190190
go fmt ./...
191+
$(YAMLFMT) testdata
191192

192193
.PHONY: update-tls-profiles
193194
update-tls-profiles: $(GOJQ) #EXHELP Update TLS profiles from the Mozilla wiki

testdata/images/bundles/test-operator/v1.0.0/manifests/bundle.configmap.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ metadata:
44
name: test-configmap
55
annotations:
66
shouldNotTemplate: >
7-
The namespace is {{ $labels.namespace }}. The templated
8-
$labels.namespace is NOT expected to be processed by OLM's
9-
rendering engine for registry+v1 bundles.
7+
The namespace is {{ $labels.namespace }}. The templated $labels.namespace is NOT expected to be processed by OLM's rendering engine for registry+v1 bundles.
8+
109
data:
1110
version: "v1.0.0"
1211
name: "test-configmap"

testdata/images/bundles/test-operator/v1.0.0/manifests/olm.operatorframework.com_olme2etest.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
apiVersion: apiextensions.k8s.io/v1
32
kind: CustomResourceDefinition
43
metadata:

testdata/images/bundles/test-operator/v1.0.0/manifests/testoperator.clusterserviceversion.yaml

Lines changed: 98 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -35,115 +35,115 @@ spec:
3535
description: OLM E2E Testing Operator
3636
displayName: test-operator
3737
icon:
38-
- base64data: ""
39-
mediatype: ""
38+
- base64data: ""
39+
mediatype: ""
4040
install:
4141
spec:
4242
deployments:
43-
- label:
44-
app.kubernetes.io/component: controller
45-
app.kubernetes.io/name: test-operator
46-
app.kubernetes.io/version: 1.0.0
47-
name: test-operator
48-
spec:
49-
replicas: 1
50-
selector:
51-
matchLabels:
52-
app: olme2etest
53-
template:
54-
metadata:
55-
labels:
43+
- label:
44+
app.kubernetes.io/component: controller
45+
app.kubernetes.io/name: test-operator
46+
app.kubernetes.io/version: 1.0.0
47+
name: test-operator
48+
spec:
49+
replicas: 1
50+
selector:
51+
matchLabels:
5652
app: olme2etest
57-
spec:
58-
terminationGracePeriodSeconds: 0
59-
containers:
60-
- name: busybox
61-
image: busybox:1.36
62-
command:
63-
- 'sleep'
64-
- '1000'
65-
securityContext:
66-
runAsUser: 1000
67-
runAsNonRoot: true
68-
serviceAccountName: simple-bundle-manager
53+
template:
54+
metadata:
55+
labels:
56+
app: olme2etest
57+
spec:
58+
terminationGracePeriodSeconds: 0
59+
containers:
60+
- name: busybox
61+
image: busybox:1.36
62+
command:
63+
- 'sleep'
64+
- '1000'
65+
securityContext:
66+
runAsUser: 1000
67+
runAsNonRoot: true
68+
serviceAccountName: simple-bundle-manager
6969
clusterPermissions:
70-
- rules:
71-
- apiGroups:
72-
- authentication.k8s.io
73-
resources:
74-
- tokenreviews
75-
verbs:
76-
- create
77-
- apiGroups:
78-
- authorization.k8s.io
79-
resources:
80-
- subjectaccessreviews
81-
verbs:
82-
- create
83-
serviceAccountName: simple-bundle-manager
70+
- rules:
71+
- apiGroups:
72+
- authentication.k8s.io
73+
resources:
74+
- tokenreviews
75+
verbs:
76+
- create
77+
- apiGroups:
78+
- authorization.k8s.io
79+
resources:
80+
- subjectaccessreviews
81+
verbs:
82+
- create
83+
serviceAccountName: simple-bundle-manager
8484
permissions:
85-
- rules:
86-
- apiGroups:
87-
- ""
88-
resources:
89-
- configmaps
90-
- serviceaccounts
91-
verbs:
92-
- get
93-
- list
94-
- watch
95-
- create
96-
- update
97-
- patch
98-
- delete
99-
- apiGroups:
100-
- networking.k8s.io
101-
resources:
102-
- networkpolicies
103-
verbs:
104-
- get
105-
- list
106-
- create
107-
- update
108-
- delete
109-
- apiGroups:
110-
- coordination.k8s.io
111-
resources:
112-
- leases
113-
verbs:
114-
- get
115-
- list
116-
- watch
117-
- create
118-
- update
119-
- patch
120-
- delete
121-
- apiGroups:
122-
- ""
123-
resources:
124-
- events
125-
verbs:
126-
- create
127-
- patch
128-
serviceAccountName: simple-bundle-manager
85+
- rules:
86+
- apiGroups:
87+
- ""
88+
resources:
89+
- configmaps
90+
- serviceaccounts
91+
verbs:
92+
- get
93+
- list
94+
- watch
95+
- create
96+
- update
97+
- patch
98+
- delete
99+
- apiGroups:
100+
- networking.k8s.io
101+
resources:
102+
- networkpolicies
103+
verbs:
104+
- get
105+
- list
106+
- create
107+
- update
108+
- delete
109+
- apiGroups:
110+
- coordination.k8s.io
111+
resources:
112+
- leases
113+
verbs:
114+
- get
115+
- list
116+
- watch
117+
- create
118+
- update
119+
- patch
120+
- delete
121+
- apiGroups:
122+
- ""
123+
resources:
124+
- events
125+
verbs:
126+
- create
127+
- patch
128+
serviceAccountName: simple-bundle-manager
129129
strategy: deployment
130130
installModes:
131-
- supported: false
132-
type: OwnNamespace
133-
- supported: true
134-
type: SingleNamespace
135-
- supported: false
136-
type: MultiNamespace
137-
- supported: true
138-
type: AllNamespaces
131+
- supported: false
132+
type: OwnNamespace
133+
- supported: true
134+
type: SingleNamespace
135+
- supported: false
136+
type: MultiNamespace
137+
- supported: true
138+
type: AllNamespaces
139139
keywords:
140-
- registry
140+
- registry
141141
links:
142-
- name: simple-bundle
143-
url: https://simple-bundle.domain
142+
- name: simple-bundle
143+
url: https://simple-bundle.domain
144144
maintainers:
145-
- email: main#simple-bundle.domain
146-
name: Simple Bundle
145+
- email: main#simple-bundle.domain
146+
name: Simple Bundle
147147
maturity: beta
148148
provider:
149149
name: Simple Bundle

testdata/images/bundles/test-operator/v1.0.0/manifests/testoperator.networkpolicy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ metadata:
55
spec:
66
podSelector: {}
77
policyTypes:
8-
- Ingress
8+
- Ingress

testdata/images/bundles/test-operator/v1.2.0/manifests/bundle.configmap.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ metadata:
44
name: test-configmap
55
annotations:
66
shouldNotTemplate: >
7-
The namespace is {{ $labels.namespace }}. The templated
8-
$labels.namespace is NOT expected to be processed by OLM's
9-
rendering engine for registry+v1 bundles.
7+
The namespace is {{ $labels.namespace }}. The templated $labels.namespace is NOT expected to be processed by OLM's rendering engine for registry+v1 bundles.
8+
109
data:
1110
version: "v1.2.0"
1211
name: "test-configmap"

0 commit comments

Comments
 (0)