Skip to content

Commit

Permalink
Added yamllint, fixed current linting errors, added github action
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanning6 authored and priyanshikhetwani committed Nov 26, 2024
1 parent 622fcf4 commit 96fe8fe
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 26 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/validate-yaml-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: YamlLint
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run yamllint make target
run: make yamllint
15 changes: 15 additions & 0 deletions .github/workflows/validate-yaml-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: YamlLint
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run yamllint make target
run: make yamllint
43 changes: 43 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
extends: default

ignore:
- config # Skip autogenerated config dir from liniting

rules:
# Rules to control the number of spaces around operators
braces:
min-spaces-inside: 0 # No spaces required inside braces
max-spaces-inside: 1 # Maximum one space inside braces
brackets:
min-spaces-inside: 0
max-spaces-inside: 1
colons:
max-spaces-before: 0
max-spaces-after: 1
commas:
max-spaces-before: 0
max-spaces-after: 1
hyphens:
max-spaces-after: 1

# Rules to control indentation
indentation:
spaces: consistent # Spaces should be consistently used for indentation
indent-sequences: whatever # Either indenting or not indenting individual block sequences is OK
comments-indentation: enable # Comments should be indented the same as the content

# Rules to control lines
line-length:
max: 150 # Maximum 150 characters per line
allow-non-breakable-words: true # Allow long words without breaks
allow-non-breakable-inline-mappings: true # Allow long inline mappings without breaks
empty-lines:
max: 2 # Maximum two consecutive empty lines allowed
trailing-spaces: enable # Ensure no trailing spaces at the end of lines

# Other rules
comments:
min-spaces-from-content: 1 # At least one space required between content and comment
key-duplicates: enable # Ensure no duplicate keys in mappings
truthy:
allowed-values: ['true', 'false', 'on', 'off'] # Allow only these values for boolean scalars
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,17 @@ else
echo "Versions are different across Makefiles. Please ensure to keep them uniform."
endif


.PHONY: yamllint
yamllint:
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/yamllint:latest /data --config-file /data/.yamllint --no-warnings

.PHONY: lint-yaml-no-warnings
lint-yaml-no-warnings: ## Run yamllint and won’t output warning level problems
@echo "Running yamllint and won't output warning level problems..."
@yamllint . --no-warnings
@echo "Linting Yaml files completed"

## --------------------------------------
## Cleanup / Verification
## --------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions templates/bases/powervs/kcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ spec:
permissions: "0644"
- content: |
#!/bin/bash
# Copyright 2020 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -136,30 +136,30 @@ spec:
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
# Configure the workaround required for kubeadm init with kube-vip:
# xref: https://github.com/kube-vip/kube-vip/issues/684
# Nothing to do for kubernetes < v1.29
KUBEADM_MINOR="$(kubeadm version -o short | cut -d '.' -f 2)"
if [[ "$KUBEADM_MINOR" -lt "29" ]]; then
exit 0
fi
IS_KUBEADM_INIT="false"
# cloud-init kubeadm init
if [[ -f /run/kubeadm/kubeadm.yaml ]]; then
IS_KUBEADM_INIT="true"
fi
# ignition kubeadm init
if [[ -f /etc/kubeadm.sh ]] && grep -q -e "kubeadm init" /etc/kubeadm.sh; then
IS_KUBEADM_INIT="true"
fi
if [[ "$IS_KUBEADM_INIT" == "true" ]]; then
sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' \
/etc/kubernetes/manifests/kube-vip.yaml
Expand Down
4 changes: 2 additions & 2 deletions templates/bases/vpc/kcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ spec:
initConfiguration:
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
kubeletExtraArgs:
kubeletExtraArgs:
cloud-provider: external
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
joinConfiguration:
discovery: {}
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
kubeletExtraArgs:
kubeletExtraArgs:
cloud-provider: external
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ spec:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: "${IBMPOWERVS_CLUSTER_CLASS_NAME}-md-0"
name: "${IBMPOWERVS_CLUSTER_CLASS_NAME}-md-0"
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMPowerVSMachineTemplate
name: "${IBMPOWERVS_CLUSTER_CLASS_NAME}-worker-machinetemplate"
name: "${IBMPOWERVS_CLUSTER_CLASS_NAME}-worker-machinetemplate"
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMPowerVSClusterTemplate
Expand Down Expand Up @@ -166,7 +166,7 @@ spec:
permissions: "0644"
- content: |
#!/bin/bash
# Copyright 2020 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -180,30 +180,30 @@ spec:
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
# Configure the workaround required for kubeadm init with kube-vip:
# xref: https://github.com/kube-vip/kube-vip/issues/684
# Nothing to do for kubernetes < v1.29
KUBEADM_MINOR="$(kubeadm version -o short | cut -d '.' -f 2)"
if [[ "$KUBEADM_MINOR" -lt "29" ]]; then
exit 0
fi
IS_KUBEADM_INIT="false"
# cloud-init kubeadm init
if [[ -f /run/kubeadm/kubeadm.yaml ]]; then
IS_KUBEADM_INIT="true"
fi
# ignition kubeadm init
if [[ -f /etc/kubeadm.sh ]] && grep -q -e "kubeadm init" /etc/kubeadm.sh; then
IS_KUBEADM_INIT="true"
fi
if [[ "$IS_KUBEADM_INIT" == "true" ]]; then
sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' \
/etc/kubernetes/manifests/kube-vip.yaml
Expand Down
1 change: 0 additions & 1 deletion templates/cluster-template-powervs/kcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ spec:
nodeRegistration:
kubeletExtraArgs:
provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}'

Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ spec:
initConfiguration:
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
kubeletExtraArgs:
kubeletExtraArgs:
cloud-provider: external
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
joinConfiguration:
discovery: {}
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
kubeletExtraArgs:
kubeletExtraArgs:
cloud-provider: external
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
1 change: 0 additions & 1 deletion templates/cluster-template/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ metadata:
namespace: "${NAMESPACE}"
labels:
ccm: external

1 change: 0 additions & 1 deletion templates/cluster-template/kcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ spec:
apiServer:
extraArgs:
cloud-provider: external

2 changes: 1 addition & 1 deletion test/e2e/data/cni/calico/calico.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4229,7 +4229,7 @@ rules:
resources:
- endpointslices
verbs:
- watch
- watch
- list
- apiGroups: [""]
resources:
Expand Down

0 comments on commit 96fe8fe

Please sign in to comment.