Skip to content

Commit e4d7ebd

Browse files
Your Namemarkshleifer-coralogix
authored andcommitted
implemented linters in ci
1 parent a4db518 commit e4d7ebd

35 files changed

Lines changed: 8992 additions & 44 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
CHART_DIR="${CHART_DIR:-otel-integration/k8s-helm}"
5+
GOLDEN_DIR="${GOLDEN_DIR:-${CHART_DIR}/tests/golden}"
6+
RELEASE_NAME="${HELM_GOLDEN_RELEASE_NAME:-render-check}"
7+
DOMAIN="${HELM_GOLDEN_DOMAIN:-eu2.coralogix.com}"
8+
CLUSTER_NAME="${HELM_GOLDEN_CLUSTER_NAME:-golden-render}"
9+
10+
cases=(
11+
"tail-sampling:tail-sampling-values.yaml"
12+
"windows:values-windows.yaml"
13+
"eks-fargate:values-eks-fargate.yaml"
14+
"ebpf-profiler:values-ebpf-profiler.yaml"
15+
)
16+
17+
require_cmd() {
18+
local cmd="$1"
19+
if ! command -v "$cmd" >/dev/null 2>&1; then
20+
echo "Missing required command: $cmd" >&2
21+
exit 1
22+
fi
23+
}
24+
25+
render_case() {
26+
local name="$1"
27+
local values_file="$2"
28+
local output_file="$3"
29+
30+
helm template "$RELEASE_NAME" "$CHART_DIR" \
31+
-f "${CHART_DIR}/values.yaml" \
32+
-f "${CHART_DIR}/${values_file}" \
33+
--set-string "global.domain=${DOMAIN}" \
34+
--set-string "global.clusterName=${CLUSTER_NAME}" |
35+
sed -e 's/[[:blank:]]*$//' \
36+
> "$output_file"
37+
}
38+
39+
require_cmd helm
40+
require_cmd diff
41+
require_cmd sed
42+
43+
helm repo add --force-update open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts >/dev/null
44+
helm repo add --force-update coralogix-charts-virtual https://cgx.jfrog.io/artifactory/coralogix-charts-virtual >/dev/null
45+
helm repo add --force-update coralogix-charts https://cgx.jfrog.io/artifactory/coralogix-charts >/dev/null
46+
helm repo update >/dev/null
47+
helm dependency build "$CHART_DIR"
48+
49+
tmpdir="$(mktemp -d)"
50+
trap 'rm -rf "$tmpdir"' EXIT
51+
52+
failed=0
53+
for case in "${cases[@]}"; do
54+
name="${case%%:*}"
55+
values_file="${case#*:}"
56+
actual="${tmpdir}/${name}.yaml"
57+
expected="${GOLDEN_DIR}/${name}.yaml"
58+
59+
if [ ! -f "$expected" ]; then
60+
echo "Missing golden render: $expected" >&2
61+
failed=1
62+
continue
63+
fi
64+
65+
render_case "$name" "$values_file" "$actual"
66+
67+
if ! diff -u "$expected" "$actual"; then
68+
echo "Golden render mismatch for ${name}. Re-render ${expected} after reviewing the manifest change." >&2
69+
failed=1
70+
fi
71+
done
72+
73+
exit "$failed"

.github/workflows/chart-version-bump-check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
- 'otel-infrastructure-collector/k8s-helm/**'
3131
otel-integration:
3232
- 'otel-integration/k8s-helm/**'
33+
- '!otel-integration/k8s-helm/tests/**'
34+
- '!otel-integration/k8s-helm/e2e-test/**'
3335
metrics-prometheus-agent:
3436
- 'metrics/prometheus-agent/**'
3537
metrics-prometheus-operator:

.github/workflows/checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ jobs:
7979
- 'otel-infrastructure-collector/k8s-helm/**'
8080
otel-integration:
8181
- 'otel-integration/k8s-helm/**'
82+
- '!otel-integration/k8s-helm/tests/**'
83+
- '!otel-integration/k8s-helm/e2e-test/**'
8284
metrics-prometheus-agent:
8385
- 'metrics/prometheus-agent/**'
8486
metrics-prometheus-operator:

.github/workflows/otel-infra-helm-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
with:
1919
create-kind-cluster: "true"
2020
- name: Setup Secret
21-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
21+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
2222
- name: Run chart-testing (install)
2323
run: ct lint-and-install --namespace default --charts otel-infrastructure-collector/k8s-helm
24-

.github/workflows/otel-integration-e2e-test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
chmod +x ./get_host_endpoint.sh
3636
./get_host_endpoint.sh
3737
- name: Setup Secret
38-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
38+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
3939
- name: Install chart for testing
4040
env:
4141
HOSTENDPOINT: ${{ env.HOSTENDPOINT }}
@@ -125,7 +125,7 @@ jobs:
125125
chmod +x ./get_host_endpoint.sh
126126
./get_host_endpoint.sh
127127
- name: Setup Secret
128-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
128+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
129129
- name: Install chart for supervisor testing
130130
env:
131131
HOSTENDPOINT: ${{ env.HOSTENDPOINT }}
@@ -205,7 +205,7 @@ jobs:
205205
chmod +x ./get_host_endpoint.sh
206206
./get_host_endpoint.sh
207207
- name: Setup Secret
208-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
208+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
209209
- name: Install chart for tail-sampling test
210210
env:
211211
HOSTENDPOINT: ${{ env.HOSTENDPOINT }}
@@ -267,7 +267,7 @@ jobs:
267267
chmod +x ./get_host_endpoint.sh
268268
./get_host_endpoint.sh
269269
- name: Setup Secret
270-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
270+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
271271
- name: Install chart for span-metrics test
272272
env:
273273
HOSTENDPOINT: ${{ env.HOSTENDPOINT }}
@@ -327,7 +327,7 @@ jobs:
327327
chmod +x ./get_host_endpoint.sh
328328
./get_host_endpoint.sh
329329
- name: Setup Secret
330-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
330+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
331331
- name: Install cert-manager
332332
run: |
333333
helm repo add jetstack https://charts.jetstack.io

.github/workflows/otel-integration-helm-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
with:
1919
create-kind-cluster: "true"
2020
- name: Setup Secret
21-
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
21+
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=fake
2222
- name: Run chart-testing (install)
2323
run: ct lint-and-install --namespace default --charts otel-integration/k8s-helm
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Security and Hygiene
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
env:
10+
GITLEAKS_VERSION: 8.24.3
11+
SHELLCHECK_VERSION: 0.10.0
12+
HADOLINT_VERSION: 2.12.0
13+
14+
jobs:
15+
gitleaks:
16+
runs-on: ubuntu-latest
17+
name: gitleaks PR secret scan
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install gitleaks
22+
run: |
23+
set -euo pipefail
24+
mkdir -p "${RUNNER_TEMP}/bin"
25+
curl -sSfL \
26+
-o "${RUNNER_TEMP}/gitleaks.tar.gz" \
27+
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
28+
tar -xzf "${RUNNER_TEMP}/gitleaks.tar.gz" -C "${RUNNER_TEMP}/bin" gitleaks
29+
echo "${RUNNER_TEMP}/bin" >> "${GITHUB_PATH}"
30+
31+
- name: Scan current tree
32+
run: gitleaks detect --no-git --source . --redact --verbose
33+
34+
shellcheck:
35+
runs-on: ubuntu-latest
36+
name: shellcheck checked-in scripts
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Install shellcheck
41+
run: |
42+
set -euo pipefail
43+
mkdir -p "${RUNNER_TEMP}/bin"
44+
curl -sSfL \
45+
-o "${RUNNER_TEMP}/shellcheck.tar.xz" \
46+
"https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION}/shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
47+
tar -xJf "${RUNNER_TEMP}/shellcheck.tar.xz" \
48+
-C "${RUNNER_TEMP}/bin" \
49+
--strip-components=1 \
50+
"shellcheck-v${SHELLCHECK_VERSION}/shellcheck"
51+
echo "${RUNNER_TEMP}/bin" >> "${GITHUB_PATH}"
52+
53+
- name: Lint checked-in shell scripts
54+
run: |
55+
set -euo pipefail
56+
mapfile -d '' scripts < <(find . -type f -name '*.sh' -not -path './tmp/*' -print0)
57+
shellcheck "${scripts[@]}"
58+
59+
hadolint:
60+
runs-on: ubuntu-latest
61+
name: hadolint Dockerfiles
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: Install hadolint
66+
run: |
67+
set -euo pipefail
68+
mkdir -p "${RUNNER_TEMP}/bin"
69+
curl -sSfL \
70+
-o "${RUNNER_TEMP}/bin/hadolint" \
71+
"https://github.com/hadolint/hadolint/releases/download/v${HADOLINT_VERSION}/hadolint-Linux-x86_64"
72+
chmod +x "${RUNNER_TEMP}/bin/hadolint"
73+
echo "${RUNNER_TEMP}/bin" >> "${GITHUB_PATH}"
74+
75+
- name: Lint Dockerfiles
76+
run: |
77+
set -euo pipefail
78+
mapfile -d '' dockerfiles < <(find . -type f \( -name 'Dockerfile' -o -name 'Dockerfile.*' \) -print0)
79+
hadolint "${dockerfiles[@]}"
80+
81+
helm-golden-render:
82+
runs-on: ubuntu-latest
83+
name: Helm golden renders
84+
steps:
85+
- uses: actions/checkout@v4
86+
87+
- name: Setup Helm
88+
uses: azure/setup-helm@v4
89+
with:
90+
version: v3.12.1
91+
92+
- name: Check high-risk preset renders
93+
run: .github/scripts/check-helm-golden-renders.sh

logs/fluent-bit/image/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM fluent/fluent-bit:3.2.10
22
ARG TARGETARCH
3+
# hadolint ignore=DL3048 # Invalid label key.
34
LABEL Maintainer="Coralogix Inc. <info@coralogix.com>"
5+
# hadolint ignore=DL3048 # Invalid label key.
46
LABEL Description="Special Fluent-Bit image for Coralogix integration" Vendor="Coralogix Inc." Version="3.2.10"
57
COPY ./functions.lua /fluent-bit/etc/
68
CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.yaml"]

logs/fluentd/aws-ecs/image/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
FROM coralogixrepo/coralogix-fluentd-multiarch:v1.18.0-4
2+
# hadolint ignore=DL3002 # Last USER should not be root.
23
USER root
4+
# hadolint ignore=DL3028 # Pin versions in gem install.
35
RUN gem install fluent-plugin-docker_metadata_filter
6+
# hadolint ignore=DL3028,DL3059 # Pin versions in gem install; multiple consecutive RUN instructions.
47
RUN gem install fluent-plugin-script
8+
# hadolint ignore=DL3008,DL3009,DL3015,DL3027,DL3059 # Pin apt packages; delete apt lists; use no-install-recommends; use apt-get; multiple RUNs.
59
RUN apt update && apt install -y curl
610
COPY fargate.rb /fluentd/etc/
711
COPY fluent.conf /fluentd/etc/

logs/fluentd/image/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
ARG IMAGE_VERSION=v1.18.0-debian-forward-1.4
2+
# hadolint ignore=DL3006 # Always tag the version of an image explicitly.
23
FROM fluent/fluentd-kubernetes-daemonset:${IMAGE_VERSION}
34

45
# Image description labels
6+
# hadolint ignore=DL3048 # Invalid label key.
57
LABEL Description="Multi-Arch FluentD image for Coralogix integration" \
68
Vendor="Coralogix Inc." \
79
Version="1.18.0-4" \
810
Maintainer="Coralogix Inc. <info@coralogix.com>"
911

1012
# Change user
13+
# hadolint ignore=DL3002 # Last USER should not be root.
1114
USER root
1215

1316
# Installing dependencies and plugins
1417
RUN gem install elasticsearch -v 8.11
1518

19+
# hadolint ignore=DL3028,DL3059 # Pin versions in gem install; multiple consecutive RUN instructions.
1620
RUN gem install fluent-plugin-coralogix \
1721
fluent-plugin-parser-cri \
1822
fluent-plugin-sampling-filter \
@@ -22,5 +26,7 @@ RUN gem install fluent-plugin-coralogix \
2226
fluent-plugin-elasticsearch
2327

2428

29+
# hadolint ignore=DL3059 # Multiple consecutive RUN instructions.
2530
RUN gem install fluent-plugin-kubernetes_metadata_filter -v 3.4.0
31+
# hadolint ignore=DL3059 # Multiple consecutive RUN instructions.
2632
RUN gem install fluent-plugin-prometheus -v 2.1.0

0 commit comments

Comments
 (0)