Skip to content

Commit d7490db

Browse files
Merge branch 'main' into add-parent-tunnel-byte-counters
2 parents 46cc80d + c4ba2aa commit d7490db

22 files changed

Lines changed: 617 additions & 396 deletions

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
data/
2+
.build/
3+
.tarballs/
4+
5+
!.build/linux-amd64/
6+
!.build/linux-arm64/
7+
!.build/linux-armv7/
8+
!.build/linux-ppc64le/
9+
!.build/linux-riscv64/
10+
!.build/linux-s390x/

.github/dependabot.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
version: 2
22
updates:
3-
- package-ecosystem: gomod
4-
directory: /
3+
- package-ecosystem: "gomod"
4+
directory: "/"
55
schedule:
6-
interval: monthly
7-
open-pull-requests-limit: 10
8-
- package-ecosystem: github-actions
9-
directory: /
6+
interval: "monthly"
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
109
schedule:
11-
interval: monthly
12-
open-pull-requests-limit: 10
10+
interval: "monthly"
11+
# Exclude configs synced from upstream prometheus/prometheus.
12+
exclude-paths:
13+
- .github/workflows/container_description.yml
14+
- .github/workflows/golangci-lint.yml

.github/workflows/ci.yml

Lines changed: 25 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,69 @@
1+
---
12
name: CI
2-
33
on:
44
pull_request:
55
push:
6-
branches: [main, 'release-*']
6+
branches: [main, master, 'release-*']
77
tags: ['v*']
88

9+
permissions:
10+
contents: read
11+
912
jobs:
10-
build:
11-
name: Build for common architectures
13+
test_go:
14+
name: Go tests
1215
runs-on: ubuntu-latest
13-
if: |
14-
!(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
15-
&&
16-
!(github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-'))
17-
&&
18-
!(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
19-
strategy:
20-
matrix:
21-
thread: [ 0, 1, 2 ]
16+
container:
17+
# Whenever the Go version is updated here, .promu.yml
18+
# should also be updated.
19+
image: quay.io/prometheus/golang-builder:1.26-base
2220
steps:
2321
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24-
- uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4
25-
- uses: ./.github/promci/actions/build
26-
with:
27-
promu_opts: "-p linux/amd64 -p windows/amd64 -p darwin/amd64 -p linux/arm64 -p windows/arm64 -p darwin/arm64"
28-
parallelism: 3
29-
thread: ${{ matrix.thread }}
22+
- uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0
23+
- run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1
3024

31-
build_all:
32-
name: Build for all architectures
25+
build:
26+
name: Build
3327
runs-on: ubuntu-latest
34-
if: |
35-
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
36-
||
37-
(github.event_name == 'pull_request' && startsWith(github.event.pull_request.base.ref, 'release-'))
38-
||
39-
(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
4028
strategy:
4129
matrix:
42-
thread: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
30+
thread: [ 0, 1, 2, 3]
4331
steps:
4432
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
45-
- uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4
46-
- uses: ./.github/promci/actions/build
33+
- uses: prometheus/promci/build@9c86752f3395e08c57719af549cc455d8e2c2514 # v0.7.0
4734
with:
48-
parallelism: 12
35+
parallelism: 4
4936
thread: ${{ matrix.thread }}
5037

51-
verify-example-configs:
52-
name: Verify
53-
runs-on: ubuntu-latest
54-
container:
55-
image: quay.io/prometheus/golang-builder:1.26-base
56-
steps:
57-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
58-
- run: make build
59-
- name: Verify example configs
60-
run: find ./examples -name "*.yml" -print0 | xargs -0 -I % ./yace verify-config -config.file %
61-
6238
publish_main:
6339
name: Publish main branch artifacts
6440
runs-on: ubuntu-latest
65-
needs: [build_all, verify-example-configs]
41+
needs: [test_go, build]
6642
if: |
67-
(github.repository == 'prometheus-community/fortigate_exporter')
68-
&&
6943
(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
44+
||
45+
(github.event_name == 'push' && github.event.ref == 'refs/heads/master')
7046
steps:
7147
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
72-
- uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4
73-
- uses: ./.github/promci/actions/publish_main
48+
- uses: prometheus/promci/publish_main@9c86752f3395e08c57719af549cc455d8e2c2514 # v0.7.0
7449
with:
7550
docker_hub_organization: prometheuscommunity
76-
docker_hub_login: ${{ secrets.docker_hub_login }}
7751
docker_hub_password: ${{ secrets.docker_hub_password }}
7852
quay_io_organization: prometheuscommunity
79-
quay_io_login: ${{ secrets.quay_io_login }}
8053
quay_io_password: ${{ secrets.quay_io_password }}
8154

8255
publish_release:
83-
name: Publish release artifacts
56+
name: Publish release artefacts
8457
runs-on: ubuntu-latest
85-
needs: [build_all, verify-example-configs]
58+
needs: [test_go, build]
8659
if: |
87-
(github.repository == 'prometheus-community/fortigate_exporter')
88-
&&
8960
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
9061
steps:
9162
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
92-
- uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4
93-
- uses: ./.github/promci/actions/publish_release
63+
- uses: prometheus/promci/publish_release@9c86752f3395e08c57719af549cc455d8e2c2514 # v0.7.0
9464
with:
9565
docker_hub_organization: prometheuscommunity
96-
docker_hub_login: ${{ secrets.docker_hub_login }}
9766
docker_hub_password: ${{ secrets.docker_hub_password }}
9867
quay_io_organization: prometheuscommunity
99-
quay_io_login: ${{ secrets.quay_io_login }}
10068
quay_io_password: ${{ secrets.quay_io_password }}
10169
github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }}

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
with:
3131
persist-credentials: false
3232
- name: Install Go
33-
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
33+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
3434
with:
3535
go-version: 1.26.x
3636
- name: Install snmp_exporter/generator dependencies

.github/workflows/govulncheck.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: govulncheck
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
schedule:
10+
- cron: '33 2 * * *'
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
govulncheck:
17+
runs-on: ubuntu-latest
18+
name: Run govulncheck
19+
steps:
20+
- id: govulncheck
21+
uses: golang/govulncheck-action@31f7c5463448f83528bd771c2d978d940080c9fd # v1.0.4-unreleased

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ ARG ARCH="amd64"
22
ARG OS="linux"
33
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:glibc
44
LABEL maintainer="The Prometheus Authors <prometheus-developers@googlegroups.com>"
5+
LABEL org.opencontainers.image.authors="The Prometheus Authors"
6+
LABEL org.opencontainers.image.vendor="Prometheus"
7+
LABEL org.opencontainers.image.title="snmp_exporter"
8+
LABEL org.opencontainers.image.description="Prometheus SNMP Exporter"
9+
LABEL org.opencontainers.image.source="https://github.com/prometheus-community/fortigate_exporter"
10+
LABEL org.opencontainers.image.url="https://github.com/prometheus-community/fortigate_exporter"
11+
LABEL org.opencontainers.image.documentation="https://github.com/prometheus-community/fortigate_exporter/blob/main/README.md"
12+
LABEL org.opencontainers.image.licenses="Apache License 2.0"
13+
LABEL io.prometheus.image.variant="busybox"
514

615
ARG ARCH="amd64"
716
ARG OS="linux"

Dockerfile.distroless

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ARG DISTROLESS_ARCH="amd64"
2+
FROM gcr.io/distroless/static-debian13:nonroot-${DISTROLESS_ARCH}
3+
4+
ARG ARCH="amd64"
5+
ARG OS="linux"
6+
LABEL maintainer="The Prometheus Authors <prometheus-developers@googlegroups.com>"
7+
LABEL org.opencontainers.image.authors="The Prometheus Authors"
8+
LABEL org.opencontainers.image.vendor="Prometheus"
9+
LABEL org.opencontainers.image.title="snmp_exporter"
10+
LABEL org.opencontainers.image.description="Prometheus SNMP Exporter"
11+
LABEL org.opencontainers.image.source="https://github.com/prometheus-community/fortigate_exporter"
12+
LABEL org.opencontainers.image.url="https://github.com/prometheus-community/fortigate_exporter"
13+
LABEL org.opencontainers.image.documentation="https://github.com/prometheus-community/fortigate_exporter/blob/main/README.md"
14+
LABEL org.opencontainers.image.licenses="Apache License 2.0"
15+
LABEL io.prometheus.image.variant="distroless"
16+
17+
ARG ARCH="amd64"
18+
ARG OS="linux"
19+
COPY .build/${OS}-${ARCH}/fortigate_exporter /bin/fortigate_exporter
20+
21+
EXPOSE 9710
22+
ENTRYPOINT [ "/bin/fortigate_exporter" ]

Makefile.common

Lines changed: 4 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ ifneq ($(shell command -v gotestsum 2> /dev/null),)
5555
endif
5656
endif
5757

58-
PROMU_VERSION ?= 0.18.0
58+
PROMU_VERSION ?= 0.18.1
5959
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
6060

6161
SKIP_GOLANGCI_LINT :=
6262
GOLANGCI_LINT :=
6363
GOLANGCI_LINT_OPTS ?=
64-
GOLANGCI_LINT_VERSION ?= v2.10.1
64+
GOLANGCI_LINT_VERSION ?= v2.11.4
6565
GOLANGCI_FMT_OPTS ?=
6666
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
6767
# windows isn't included here because of the path separator being different.
@@ -90,8 +90,8 @@ ifdef DOCKERFILE_PATH
9090
$(error DOCKERFILE_PATH is deprecated. Use DOCKERFILE_VARIANTS ?= $(DOCKERFILE_PATH) in the Makefile)
9191
endif
9292

93-
DOCKER_ARCHS ?= amd64
94-
DOCKERFILE_VARIANTS ?= Dockerfile $(wildcard Dockerfile.*)
93+
DOCKER_ARCHS ?= amd64 arm64 armv7 ppc64le riscv64 s390x
94+
DOCKERFILE_VARIANTS ?= $(wildcard Dockerfile Dockerfile.*)
9595

9696
# Function to extract variant from Dockerfile label.
9797
# Returns the variant name from io.prometheus.image.variant label, or "default" if not found.
@@ -109,24 +109,6 @@ endif
109109
# Build variant:dockerfile pairs for shell iteration.
110110
DOCKERFILE_VARIANTS_WITH_NAMES := $(foreach df,$(DOCKERFILE_VARIANTS),$(call dockerfile_variant,$(df)):$(df))
111111

112-
# Shell helper to check whether a dockerfile/arch pair is excluded.
113-
define dockerfile_arch_is_excluded
114-
case " $(DOCKERFILE_ARCH_EXCLUSIONS) " in \
115-
*" $$dockerfile:$(1) "*) true ;; \
116-
*) false ;; \
117-
esac
118-
endef
119-
120-
# Shell helper to check whether a registry/arch pair is excluded.
121-
# Extracts registry from DOCKER_REPO (e.g., quay.io/prometheus -> quay.io)
122-
define registry_arch_is_excluded
123-
registry=$$(echo "$(DOCKER_REPO)" | cut -d'/' -f1); \
124-
case " $(DOCKER_REGISTRY_ARCH_EXCLUSIONS) " in \
125-
*" $$registry:$(1) "*) true ;; \
126-
*) false ;; \
127-
esac
128-
endef
129-
130112
BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS))
131113
PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS))
132114
TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS))
@@ -268,10 +250,6 @@ $(BUILD_DOCKER_ARCHS): common-docker-%:
268250
@for variant in $(DOCKERFILE_VARIANTS_WITH_NAMES); do \
269251
dockerfile=$${variant#*:}; \
270252
variant_name=$${variant%%:*}; \
271-
if $(call dockerfile_arch_is_excluded,$*); then \
272-
echo "Skipping $$variant_name variant for linux-$* (excluded by DOCKERFILE_ARCH_EXCLUSIONS)"; \
273-
continue; \
274-
fi; \
275253
distroless_arch="$*"; \
276254
if [ "$*" = "armv7" ]; then \
277255
distroless_arch="arm"; \
@@ -306,14 +284,6 @@ $(PUBLISH_DOCKER_ARCHS): common-docker-publish-%:
306284
@for variant in $(DOCKERFILE_VARIANTS_WITH_NAMES); do \
307285
dockerfile=$${variant#*:}; \
308286
variant_name=$${variant%%:*}; \
309-
if $(call dockerfile_arch_is_excluded,$*); then \
310-
echo "Skipping push for $$variant_name variant on linux-$* (excluded by DOCKERFILE_ARCH_EXCLUSIONS)"; \
311-
continue; \
312-
fi; \
313-
if $(call registry_arch_is_excluded,$*); then \
314-
echo "Skipping push for $$variant_name variant on linux-$* to $(DOCKER_REPO) (excluded by DOCKER_REGISTRY_ARCH_EXCLUSIONS)"; \
315-
continue; \
316-
fi; \
317287
if [ "$$dockerfile" != "Dockerfile" ] || [ "$$variant_name" != "default" ]; then \
318288
echo "Pushing $$variant_name variant for linux-$*"; \
319289
docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)-$$variant_name"; \
@@ -341,14 +311,6 @@ $(TAG_DOCKER_ARCHS): common-docker-tag-latest-%:
341311
@for variant in $(DOCKERFILE_VARIANTS_WITH_NAMES); do \
342312
dockerfile=$${variant#*:}; \
343313
variant_name=$${variant%%:*}; \
344-
if $(call dockerfile_arch_is_excluded,$*); then \
345-
echo "Skipping tag for $$variant_name variant on linux-$* (excluded by DOCKERFILE_ARCH_EXCLUSIONS)"; \
346-
continue; \
347-
fi; \
348-
if $(call registry_arch_is_excluded,$*); then \
349-
echo "Skipping tag for $$variant_name variant on linux-$* for $(DOCKER_REPO) (excluded by DOCKER_REGISTRY_ARCH_EXCLUSIONS)"; \
350-
continue; \
351-
fi; \
352314
if [ "$$dockerfile" != "Dockerfile" ] || [ "$$variant_name" != "default" ]; then \
353315
echo "Tagging $$variant_name variant for linux-$* as latest"; \
354316
docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)-$$variant_name" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest-$$variant_name"; \
@@ -370,14 +332,6 @@ common-docker-manifest:
370332
echo "Creating manifest for $$variant_name variant"; \
371333
refs=""; \
372334
for arch in $(DOCKER_ARCHS); do \
373-
if $(call dockerfile_arch_is_excluded,$$arch); then \
374-
echo " Skipping $$arch for $$variant_name (excluded by DOCKERFILE_ARCH_EXCLUSIONS)"; \
375-
continue; \
376-
fi; \
377-
if $(call registry_arch_is_excluded,$$arch); then \
378-
echo " Skipping $$arch for $$variant_name on $(DOCKER_REPO) (excluded by DOCKER_REGISTRY_ARCH_EXCLUSIONS)"; \
379-
continue; \
380-
fi; \
381335
refs="$$refs $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$$arch:$(SANITIZED_DOCKER_IMAGE_TAG)-$$variant_name"; \
382336
done; \
383337
if [ -z "$$refs" ]; then \
@@ -391,14 +345,6 @@ common-docker-manifest:
391345
echo "Creating default variant ($$variant_name) manifest"; \
392346
refs=""; \
393347
for arch in $(DOCKER_ARCHS); do \
394-
if $(call dockerfile_arch_is_excluded,$$arch); then \
395-
echo " Skipping $$arch for default variant (excluded by DOCKERFILE_ARCH_EXCLUSIONS)"; \
396-
continue; \
397-
fi; \
398-
if $(call registry_arch_is_excluded,$$arch); then \
399-
echo " Skipping $$arch for default variant on $(DOCKER_REPO) (excluded by DOCKER_REGISTRY_ARCH_EXCLUSIONS)"; \
400-
continue; \
401-
fi; \
402348
refs="$$refs $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$$arch:$(SANITIZED_DOCKER_IMAGE_TAG)"; \
403349
done; \
404350
if [ -z "$$refs" ]; then \
@@ -413,14 +359,6 @@ common-docker-manifest:
413359
echo "Creating manifest for $$variant_name variant version tag"; \
414360
refs=""; \
415361
for arch in $(DOCKER_ARCHS); do \
416-
if $(call dockerfile_arch_is_excluded,$$arch); then \
417-
echo " Skipping $$arch for $$variant_name version tag (excluded by DOCKERFILE_ARCH_EXCLUSIONS)"; \
418-
continue; \
419-
fi; \
420-
if $(call registry_arch_is_excluded,$$arch); then \
421-
echo " Skipping $$arch for $$variant_name version tag on $(DOCKER_REPO) (excluded by DOCKER_REGISTRY_ARCH_EXCLUSIONS)"; \
422-
continue; \
423-
fi; \
424362
refs="$$refs $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$$arch:v$(DOCKER_MAJOR_VERSION_TAG)-$$variant_name"; \
425363
done; \
426364
if [ -z "$$refs" ]; then \
@@ -434,14 +372,6 @@ common-docker-manifest:
434372
echo "Creating default variant version tag manifest"; \
435373
refs=""; \
436374
for arch in $(DOCKER_ARCHS); do \
437-
if $(call dockerfile_arch_is_excluded,$$arch); then \
438-
echo " Skipping $$arch for default variant version tag (excluded by DOCKERFILE_ARCH_EXCLUSIONS)"; \
439-
continue; \
440-
fi; \
441-
if $(call registry_arch_is_excluded,$$arch); then \
442-
echo " Skipping $$arch for default variant version tag on $(DOCKER_REPO) (excluded by DOCKER_REGISTRY_ARCH_EXCLUSIONS)"; \
443-
continue; \
444-
fi; \
445375
refs="$$refs $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$$arch:v$(DOCKER_MAJOR_VERSION_TAG)"; \
446376
done; \
447377
if [ -z "$$refs" ]; then \
@@ -495,9 +425,3 @@ $(1)_precheck:
495425
exit 1; \
496426
fi
497427
endef
498-
499-
govulncheck: install-govulncheck
500-
govulncheck ./...
501-
502-
install-govulncheck:
503-
command -v govulncheck > /dev/null || go install golang.org/x/vuln/cmd/govulncheck@latest

0 commit comments

Comments
 (0)