From e62fa977e53bd5efd105da954c7108a842df4110 Mon Sep 17 00:00:00 2001 From: Mauro Morales Date: Tue, 18 Jul 2023 13:27:58 +0200 Subject: [PATCH 1/7] Add lint workflow Signed-off-by: Mauro Morales --- .github/workflows/lint.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..c6916eb --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,16 @@ +name: Lint +on: + push: + branches: + - master + pull_request: + paths: + - '**' +env: + FORCE_COLOR: 1 +jobs: + call-workflow: + uses: kairos-io/linting-composite-action/.github/workflows/reusable-linting.yaml@v0.0.6 + with: + yamldirs: ".github/workflows/ config/ tools-image/" + is-go: true From adba7de85a862b56134576f0150e662758582ea2 Mon Sep 17 00:00:00 2001 From: Mauro Morales Date: Tue, 18 Jul 2023 14:28:48 +0200 Subject: [PATCH 2/7] Add yaml lint config file Signed-off-by: Mauro Morales --- .yamllint | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .yamllint diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..02702cb --- /dev/null +++ b/.yamllint @@ -0,0 +1,21 @@ +extends: default + +rules: + # 80 chars should be enough, but don't fail if a line is longer + line-length: + max: 150 + level: warning + + # accept both key: + # - item + # + # and key: + # - item + indentation: + indent-sequences: whatever + + truthy: + check-keys: false + + document-start: + present: false From 892beef6cc4385520adc0ac33d71723467f2e5e3 Mon Sep 17 00:00:00 2001 From: Mauro Morales Date: Tue, 18 Jul 2023 14:50:29 +0200 Subject: [PATCH 3/7] fix yaml linter errors Signed-off-by: Mauro Morales --- config/default/kustomization.yaml | 4 +--- config/manager/controller_manager_config.yaml | 8 ++++---- config/prometheus/monitor.yaml | 1 - tools-image/config.yaml | 2 +- tools-image/defaults.yaml | 10 +++++----- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index e66a6f2..66eb279 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -73,13 +73,11 @@ vars: # kind: Service # version: v1 # name: webhook-service - -vars: - name: NGINX_NAMESPACE objref: kind: Namespace name: system - apiVersion: v1 + apiVersion: v1 - name: ARTIFACT_COPIER_ROLE objref: diff --git a/config/manager/controller_manager_config.yaml b/config/manager/controller_manager_config.yaml index d95dc28..2f4fbb2 100644 --- a/config/manager/controller_manager_config.yaml +++ b/config/manager/controller_manager_config.yaml @@ -9,13 +9,13 @@ webhook: leaderElection: leaderElect: true resourceName: 98ca89ca.kairos.io -# leaderElectionReleaseOnCancel defines if the leader should step down volume +# leaderElectionReleaseOnCancel defines if the leader should step down volume # when the Manager ends. This requires the binary to immediately end when the # Manager is stopped, otherwise, this setting is unsafe. Setting this significantly # speeds up voluntary leader transitions as the new leader don't have to wait # LeaseDuration time first. -# In the default scaffold provided, the program ends immediately after -# the manager stops, so would be fine to enable this option. However, -# if you are doing or is intended to do any operation such as perform cleanups +# In the default scaffold provided, the program ends immediately after +# the manager stops, so would be fine to enable this option. However, +# if you are doing or is intended to do any operation such as perform cleanups # after the manager stops then its usage might be unsafe. # leaderElectionReleaseOnCancel: true diff --git a/config/prometheus/monitor.yaml b/config/prometheus/monitor.yaml index d19136a..6812d4d 100644 --- a/config/prometheus/monitor.yaml +++ b/config/prometheus/monitor.yaml @@ -1,4 +1,3 @@ - # Prometheus Monitor Service (Metrics) apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor diff --git a/tools-image/config.yaml b/tools-image/config.yaml index 4ceb56c..60857c2 100644 --- a/tools-image/config.yaml +++ b/tools-image/config.yaml @@ -3,4 +3,4 @@ iso: - dir:/efi image: - dir:/efi - - dir:/grub2 \ No newline at end of file + - dir:/grub2 diff --git a/tools-image/defaults.yaml b/tools-image/defaults.yaml index 4cfc7ce..afd4fab 100644 --- a/tools-image/defaults.yaml +++ b/tools-image/defaults.yaml @@ -1,8 +1,8 @@ #cloud-config name: "Default user" stages: - initramfs: - - name: "Set default user/pass" - users: - kairos: - passwd: "kairos" \ No newline at end of file + initramfs: + - name: "Set default user/pass" + users: + kairos: + passwd: "kairos" From 1544361d6d9f78ac1c9c939d84549b1ccccb55b9 Mon Sep 17 00:00:00 2001 From: Mauro Morales Date: Tue, 18 Jul 2023 14:59:29 +0200 Subject: [PATCH 4/7] fix yaml linter errors Signed-off-by: Mauro Morales --- tools-image/defaults.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools-image/defaults.yaml b/tools-image/defaults.yaml index afd4fab..a7fe034 100644 --- a/tools-image/defaults.yaml +++ b/tools-image/defaults.yaml @@ -4,5 +4,5 @@ stages: initramfs: - name: "Set default user/pass" users: - kairos: - passwd: "kairos" + kairos: + passwd: "kairos" From 9f933175ef9a8442a62a2a22fc92d4f90a825d7b Mon Sep 17 00:00:00 2001 From: Mauro Morales Date: Tue, 18 Jul 2023 15:11:33 +0200 Subject: [PATCH 5/7] add shellcheckrc Signed-off-by: Mauro Morales --- .shellcheckrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .shellcheckrc diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..5de1df3 --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1 @@ +disable=SC2086 From 1b345623bc364199ace2a43ff6d5600b6c04d1b3 Mon Sep 17 00:00:00 2001 From: Mauro Morales Date: Tue, 18 Jul 2023 15:31:34 +0200 Subject: [PATCH 6/7] ignore checks and fix some Signed-off-by: Mauro Morales --- .shellcheckrc | 2 ++ tools-image/build-arm-image.sh | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.shellcheckrc b/.shellcheckrc index 5de1df3..f282b9d 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -1 +1,3 @@ disable=SC2086 +disable=SC2034 +disable=SC2046 \ No newline at end of file diff --git a/tools-image/build-arm-image.sh b/tools-image/build-arm-image.sh index 53ee8ae..e2de53e 100755 --- a/tools-image/build-arm-image.sh +++ b/tools-image/build-arm-image.sh @@ -131,7 +131,7 @@ get_url() esac } -trap "cleanup" 1 2 3 6 9 14 15 EXIT +trap "cleanup" 1 2 3 6 14 15 EXIT load_vars @@ -223,6 +223,7 @@ else fi if [ -n "$cos_config" ] && [ -e "$cos_config" ]; then + # shellcheck source=/dev/null source "$cos_config" fi @@ -283,7 +284,7 @@ ensure_dir_structure $TARGET # Download the container image if [ -z "$directory" ]; then echo ">>> Downloading container image" - elemental pull-image $( (( $local_build == 'true')) && printf %s '--local' ) $container_image $TARGET + elemental pull-image $( (( local_build == 'true')) && printf %s '--local' ) $container_image $TARGET else echo ">>> Copying files from $directory" rsync -axq --exclude='host' --exclude='mnt' --exclude='proc' --exclude='sys' --exclude='dev' --exclude='tmp' ${directory}/ $TARGET @@ -354,7 +355,7 @@ sgdisk -n 2:0:+${state_size}M -c 2:state -t 2:8300 ${output_image} if [ "$disable_lvm" == 'true' ]; then sgdisk -n 3:0:+${recovery_size}M -c 3:recovery -t 3:8300 ${output_image} else -sgdisk -n 3:0:+$(( ${recovery_size} + ${oem_size} ))M -c 3:lvm -t 3:8e00 ${output_image} +sgdisk -n 3:0:+$(( recovery_size + oem_size ))M -c 3:lvm -t 3:8e00 ${output_image} fi sgdisk -n 4:0:+64M -c 4:persistent -t 4:8300 ${output_image} @@ -366,7 +367,8 @@ fi # Prepare the image and copy over the files -export DRIVE=$(losetup -f "${output_image}" --show) +export DRIVE +DRIVE=$(losetup -f "${output_image}" --show) if [ -z "${DRIVE}" ]; then echo "Cannot execute losetup for $output_image" exit 1 From 9437413a242c561c06864f0a6a762664b737b87d Mon Sep 17 00:00:00 2001 From: Mauro Morales Date: Tue, 18 Jul 2023 16:01:57 +0200 Subject: [PATCH 7/7] ignore checks and fix some Signed-off-by: Mauro Morales --- .shellcheckrc | 4 +++- script/test.sh | 3 ++- tools-image/build-arm-image.sh | 2 +- tools-image/raw-images.sh | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.shellcheckrc b/.shellcheckrc index f282b9d..0547724 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -1,3 +1,5 @@ disable=SC2086 disable=SC2034 -disable=SC2046 \ No newline at end of file +disable=SC2046 +disable=SC2068 +disable=SC2154 diff --git a/script/test.sh b/script/test.sh index 6985134..555feed 100755 --- a/script/test.sh +++ b/script/test.sh @@ -26,7 +26,8 @@ set -e kubectl cluster-info --context kind-$CLUSTER_NAME echo "Sleep to give times to node to populate with all info" kubectl wait --for=condition=Ready node/$CLUSTER_NAME-control-plane -export EXTERNAL_IP=$(kubectl get nodes -o jsonpath='{.items[].status.addresses[?(@.type == "InternalIP")].address}') +EXTERNAL_IP=$(kubectl get nodes -o jsonpath='{.items[].status.addresses[?(@.type == "InternalIP")].address}') +export EXTERNAL_IP export BRIDGE_IP="172.18.0.1" kubectl get nodes -o wide cd $ROOT_DIR/tests && $GINKGO -r -v ./e2e \ No newline at end of file diff --git a/tools-image/build-arm-image.sh b/tools-image/build-arm-image.sh index e2de53e..9820458 100755 --- a/tools-image/build-arm-image.sh +++ b/tools-image/build-arm-image.sh @@ -367,8 +367,8 @@ fi # Prepare the image and copy over the files -export DRIVE DRIVE=$(losetup -f "${output_image}" --show) +export DRIVE if [ -z "${DRIVE}" ]; then echo "Cannot execute losetup for $output_image" exit 1 diff --git a/tools-image/raw-images.sh b/tools-image/raw-images.sh index a9fc391..47f613c 100755 --- a/tools-image/raw-images.sh +++ b/tools-image/raw-images.sh @@ -71,7 +71,7 @@ truncate -s "+$((1024*1024))" $OUT if [ -n "$EXTEND" ]; then echo "Extending image of $EXTEND MB" - truncate -s "+$(($EXTEND*1024*1024))" $OUT + truncate -s "+$((EXTEND*1024*1024))" $OUT fi # Create the partition table in $OUT (assumes sectors of 512 bytes)