Skip to content

Commit 03bf7d6

Browse files
authored
Add lint (#134)
1 parent c10d9c4 commit 03bf7d6

File tree

7 files changed

+58
-9
lines changed

7 files changed

+58
-9
lines changed

.github/workflows/lint.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
paths:
8+
- '**'
9+
permissions: read-all
10+
jobs:
11+
call-workflow:
12+
uses: kairos-io/linting-composite-action/.github/workflows/reusable-linting.yaml@d38a45447609f936c9d519bd14ed771b7214ad42 # v0.0.10
13+
with:
14+
yamldirs: ".github/workflows/ pkg/bundled/cloudconfigs/"
15+
is-go: false

.hadolint.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# We use "override" instead of "ignore" to still see these issues.
2+
# With the "failure-threshold" set to "warning" below, these should not make
3+
# the test fail.
4+
override:
5+
info:
6+
# warning: Specify version with `dnf install -y <package>-<version>`.
7+
- DL3041
8+
# warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
9+
- DL3008
10+
# warning: Always tag the version of an image explicitly
11+
# Reason: We build "latest" images using "latest" base images.
12+
- DL3006
13+
failure-threshold: warning

.yamllint

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
extends: default
2+
3+
rules:
4+
# 80 chars should be enough, but don't fail if a line is longer
5+
line-length:
6+
max: 305
7+
level: warning
8+
9+
# accept both key:
10+
# - item
11+
#
12+
# and key:
13+
# - item
14+
indentation:
15+
indent-sequences: whatever
16+
17+
truthy:
18+
check-keys: false
19+
20+
document-start:
21+
present: false

Dockerfile.test

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ARG VALIDATE_IMAGE=ubuntu:24.04
33

44
FROM golang AS build
55
ARG TARGETARCH
6+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
67
WORKDIR /app
78
COPY Makefile .
89
RUN apt-get update && apt-get install -y --no-install-recommends xz-utils file && \
@@ -12,7 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends xz-utils file &
1213
apt-get remove -y xz-utils && \
1314
rm -rf /var/lib/apt/lists/*
1415
RUN make all
15-
COPY go.mod go.sum .
16+
COPY go.mod go.sum ./
1617
RUN go mod download
1718
COPY . .
1819
ENV CGO_ENABLED=0
@@ -27,7 +28,7 @@ FROM ${VALIDATE_IMAGE} AS validate
2728
COPY --from=build /app/kairos-init /kairos-init
2829
RUN /kairos-init validate
2930

30-
FROM ${BASE_IMAGE}
31+
FROM ${BASE_IMAGE} AS default
3132
ARG MODEL=generic
3233
ARG TRUSTED_BOOT=false
3334
ARG KUBERNETES_PROVIDER=k3s
@@ -36,7 +37,4 @@ ARG VERSION=v0.0.1
3637
ARG FIPS=false
3738

3839
COPY --from=kairos-init /kairos-init /kairos-init
39-
RUN /kairos-init -l debug -s install -m "${MODEL}" -t "${TRUSTED_BOOT}" -k "${KUBERNETES_PROVIDER}" --k8sversion "${KUBERNETES_VERSION}" --version "${VERSION}" $(if [ "${FIPS}" = "true" ]; then echo "--fips"; fi)
40-
RUN /kairos-init -l debug -s init -m "${MODEL}" -t "${TRUSTED_BOOT}" -k "${KUBERNETES_PROVIDER}" --k8sversion "${KUBERNETES_VERSION}" --version "${VERSION}" $(if [ "${FIPS}" = "true" ]; then echo "--fips"; fi)
41-
RUN /kairos-init validate -t "${TRUSTED_BOOT}"
42-
RUN rm /kairos-init
40+
RUN /kairos-init -l debug -m "${MODEL}" -t "${TRUSTED_BOOT}" -k "${KUBERNETES_PROVIDER}" --k8sversion "${KUBERNETES_VERSION}" --version "${VERSION}" "$(if [ "${FIPS}" = "true" ]; then echo "--fips"; fi)" && /kairos-init validate -t "${TRUSTED_BOOT}" && rm /kairos-init

pkg/bundled/bundled.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"embed"
55
)
66

7+
//nolint:staticcheck
78
//go:embed binaries/kairos-agent
89
var EmbeddedAgent []byte
910

@@ -28,6 +29,7 @@ var EmbeddedKairosProvider []byte
2829
//go:embed binaries/fips/provider-kairos
2930
var EmbeddedKairosProviderFips []byte
3031

32+
//nolint:staticcheck
3133
//go:embed binaries/edgevpn
3234
var EmbeddedEdgeVPN []byte
3335

pkg/bundled/cloudconfigs/00_home_dir_owner_fix.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ stages:
1313
echo "Skipping ownership fix because sentinel file was found: $SENTINEL_FILE"
1414
exit 0
1515
fi
16-
16+
1717
# Iterate over users in /etc/passwd and chown their directories
1818
awk -F: '$3 >= 1000 && $6 ~ /^\/home\// {print $1, $6}' /etc/passwd | while read -r user homedir; do
1919
if [ -d "$homedir" ]; then # Check if the home directory exists
@@ -23,7 +23,7 @@ stages:
2323
echo "Directory $homedir does not exist for user $user"
2424
fi
2525
done
26-
26+
2727
# Write the sentinel file
2828
mkdir -p "$(dirname $SENTINEL_FILE)"
2929
echo "https://github.com/kairos-io/kairos/issues/2843" > $SENTINEL_FILE

pkg/bundled/cloudconfigs/05_network.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ stages:
7575
only_service_manager: "systemd"
7676
commands:
7777
- rm /etc/resolv.conf
78-
- ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
78+
- ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

0 commit comments

Comments
 (0)