Skip to content

Commit f9d7ade

Browse files
Added yamllint, fixed current linting errors, added github action (#2072)
Co-authored-by: evelynliu <[email protected]>
1 parent 0bff383 commit f9d7ade

File tree

11 files changed

+80
-26
lines changed

11 files changed

+80
-26
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: YamlLint
2+
on: [push, pull_request]
3+
jobs:
4+
yamllint:
5+
runs-on: ubuntu-24.04
6+
steps:
7+
- uses: actions/checkout@v4
8+
- name: Run yamllint make target
9+
run: make yamllint

.yamllint

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
extends: default
2+
3+
ignore:
4+
- config # Skip autogenerated config dir from liniting
5+
6+
rules:
7+
# Rules to control the number of spaces around operators
8+
braces:
9+
min-spaces-inside: 0 # No spaces required inside braces
10+
max-spaces-inside: 1 # Maximum one space inside braces
11+
brackets:
12+
min-spaces-inside: 0
13+
max-spaces-inside: 1
14+
colons:
15+
max-spaces-before: 0
16+
max-spaces-after: 1
17+
commas:
18+
max-spaces-before: 0
19+
max-spaces-after: 1
20+
hyphens:
21+
max-spaces-after: 1
22+
23+
# Rules to control indentation
24+
indentation:
25+
spaces: consistent # Spaces should be consistently used for indentation
26+
indent-sequences: whatever # Either indenting or not indenting individual block sequences is OK
27+
comments-indentation: enable # Comments should be indented the same as the content
28+
29+
# Rules to control lines
30+
line-length:
31+
max: 200 # Maximum 150 characters per line
32+
allow-non-breakable-words: true # Allow long words without breaks
33+
allow-non-breakable-inline-mappings: true # Allow long inline mappings without breaks
34+
empty-lines:
35+
max: 2 # Maximum two consecutive empty lines allowed
36+
trailing-spaces: enable # Ensure no trailing spaces at the end of lines
37+
38+
# Other rules
39+
comments:
40+
min-spaces-from-content: 1 # At least one space required between content and comment
41+
key-duplicates: enable # Ensure no duplicate keys in mappings
42+
truthy:
43+
allowed-values: ['true', 'false', 'on', 'off'] # Allow only these values for boolean scalars

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,11 @@ else
546546
echo "Versions are different across Makefiles. Please ensure to keep them uniform."
547547
endif
548548

549+
550+
.PHONY: yamllint
551+
yamllint:
552+
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/yamllint:latest /data --config-file /data/.yamllint --no-warnings
553+
549554
## --------------------------------------
550555
## Cleanup / Verification
551556
## --------------------------------------

templates/bases/powervs/kcp.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ spec:
122122
permissions: "0644"
123123
- content: |
124124
#!/bin/bash
125-
125+
126126
# Copyright 2020 The Kubernetes Authors.
127127
#
128128
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -136,30 +136,30 @@ spec:
136136
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137137
# See the License for the specific language governing permissions and
138138
# limitations under the License.
139-
139+
140140
set -e
141-
141+
142142
# Configure the workaround required for kubeadm init with kube-vip:
143143
# xref: https://github.com/kube-vip/kube-vip/issues/684
144-
144+
145145
# Nothing to do for kubernetes < v1.29
146146
KUBEADM_MINOR="$(kubeadm version -o short | cut -d '.' -f 2)"
147147
if [[ "$KUBEADM_MINOR" -lt "29" ]]; then
148148
exit 0
149149
fi
150-
150+
151151
IS_KUBEADM_INIT="false"
152-
152+
153153
# cloud-init kubeadm init
154154
if [[ -f /run/kubeadm/kubeadm.yaml ]]; then
155155
IS_KUBEADM_INIT="true"
156156
fi
157-
157+
158158
# ignition kubeadm init
159159
if [[ -f /etc/kubeadm.sh ]] && grep -q -e "kubeadm init" /etc/kubeadm.sh; then
160160
IS_KUBEADM_INIT="true"
161161
fi
162-
162+
163163
if [[ "$IS_KUBEADM_INIT" == "true" ]]; then
164164
sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' \
165165
/etc/kubernetes/manifests/kube-vip.yaml

templates/bases/vpc/kcp.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ spec:
2626
initConfiguration:
2727
nodeRegistration:
2828
criSocket: /var/run/containerd/containerd.sock
29-
kubeletExtraArgs:
29+
kubeletExtraArgs:
3030
cloud-provider: external
3131
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
3232
joinConfiguration:
3333
discovery: {}
3434
nodeRegistration:
3535
criSocket: /var/run/containerd/containerd.sock
36-
kubeletExtraArgs:
36+
kubeletExtraArgs:
3737
cloud-provider: external
3838
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
3939
---

templates/cluster-template-powervs-clusterclass/cluster-with-kcp.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ spec:
5353
ref:
5454
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
5555
kind: KubeadmConfigTemplate
56-
name: "${IBMPOWERVS_CLUSTER_CLASS_NAME}-md-0"
56+
name: "${IBMPOWERVS_CLUSTER_CLASS_NAME}-md-0"
5757
infrastructure:
5858
ref:
5959
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
6060
kind: IBMPowerVSMachineTemplate
61-
name: "${IBMPOWERVS_CLUSTER_CLASS_NAME}-worker-machinetemplate"
61+
name: "${IBMPOWERVS_CLUSTER_CLASS_NAME}-worker-machinetemplate"
6262
---
6363
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
6464
kind: IBMPowerVSClusterTemplate
@@ -166,7 +166,7 @@ spec:
166166
permissions: "0644"
167167
- content: |
168168
#!/bin/bash
169-
169+
170170
# Copyright 2020 The Kubernetes Authors.
171171
#
172172
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -180,30 +180,30 @@ spec:
180180
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
181181
# See the License for the specific language governing permissions and
182182
# limitations under the License.
183-
183+
184184
set -e
185-
185+
186186
# Configure the workaround required for kubeadm init with kube-vip:
187187
# xref: https://github.com/kube-vip/kube-vip/issues/684
188-
188+
189189
# Nothing to do for kubernetes < v1.29
190190
KUBEADM_MINOR="$(kubeadm version -o short | cut -d '.' -f 2)"
191191
if [[ "$KUBEADM_MINOR" -lt "29" ]]; then
192192
exit 0
193193
fi
194-
194+
195195
IS_KUBEADM_INIT="false"
196-
196+
197197
# cloud-init kubeadm init
198198
if [[ -f /run/kubeadm/kubeadm.yaml ]]; then
199199
IS_KUBEADM_INIT="true"
200200
fi
201-
201+
202202
# ignition kubeadm init
203203
if [[ -f /etc/kubeadm.sh ]] && grep -q -e "kubeadm init" /etc/kubeadm.sh; then
204204
IS_KUBEADM_INIT="true"
205205
fi
206-
206+
207207
if [[ "$IS_KUBEADM_INIT" == "true" ]]; then
208208
sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' \
209209
/etc/kubernetes/manifests/kube-vip.yaml

templates/cluster-template-powervs/kcp.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ spec:
1313
nodeRegistration:
1414
kubeletExtraArgs:
1515
provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}'
16-

templates/cluster-template-vpc-clusterclass/cluster-with-kcp.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ spec:
104104
initConfiguration:
105105
nodeRegistration:
106106
criSocket: /var/run/containerd/containerd.sock
107-
kubeletExtraArgs:
107+
kubeletExtraArgs:
108108
cloud-provider: external
109109
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
110110
joinConfiguration:
111111
discovery: {}
112112
nodeRegistration:
113113
criSocket: /var/run/containerd/containerd.sock
114-
kubeletExtraArgs:
114+
kubeletExtraArgs:
115115
cloud-provider: external
116116
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'

templates/cluster-template/cluster.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ metadata:
55
namespace: "${NAMESPACE}"
66
labels:
77
ccm: external
8-

templates/cluster-template/kcp.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ spec:
1212
apiServer:
1313
extraArgs:
1414
cloud-provider: external
15-

test/e2e/data/cni/calico/calico.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4229,7 +4229,7 @@ rules:
42294229
resources:
42304230
- endpointslices
42314231
verbs:
4232-
- watch
4232+
- watch
42334233
- list
42344234
- apiGroups: [""]
42354235
resources:

0 commit comments

Comments
 (0)