Skip to content

Commit 217e8b5

Browse files
committed
Update for Prometheus Community
Update various files for Prometheus Community * Use Prometheus common Makefile setup. * Add license headers in Go files. * Update Go module path. * Enable dependabot. * Update GitHub Actions. Signed-off-by: SuperQ <[email protected]>
1 parent 3ce77d6 commit 217e8b5

File tree

90 files changed

+1456
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1456
-204
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"

.github/semantic.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
targetUrl: "https://github.com/bluecmd/fortigate_exporter/blob/master/CONTRIBUTING.md#pull-request-checklist"
1+
targetUrl: "https://github.com/prometheus-community/fortigate_exporter/blob/master/CONTRIBUTING.md#pull-request-checklist"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
name: Push README to Docker Hub
3+
on:
4+
push:
5+
paths:
6+
- "README.md"
7+
- "README-containers.md"
8+
- ".github/workflows/container_description.yml"
9+
branches: [ main, master ]
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
PushDockerHubReadme:
16+
runs-on: ubuntu-latest
17+
name: Push README to Docker Hub
18+
if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks.
19+
steps:
20+
- name: git checkout
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
- name: Set docker hub repo name
23+
run: echo "DOCKER_REPO_NAME=$(make docker-repo-name)" >> $GITHUB_ENV
24+
- name: Push README to Dockerhub
25+
uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1
26+
env:
27+
DOCKER_USER: ${{ secrets.DOCKER_HUB_LOGIN }}
28+
DOCKER_PASS: ${{ secrets.DOCKER_HUB_PASSWORD }}
29+
with:
30+
destination_container_repo: ${{ env.DOCKER_REPO_NAME }}
31+
provider: dockerhub
32+
short_description: ${{ env.DOCKER_REPO_NAME }}
33+
# Empty string results in README-containers.md being pushed if it
34+
# exists. Otherwise, README.md is pushed.
35+
readme_file: ''
36+
37+
PushQuayIoReadme:
38+
runs-on: ubuntu-latest
39+
name: Push README to quay.io
40+
if: github.repository_owner == 'prometheus' || github.repository_owner == 'prometheus-community' # Don't run this workflow on forks.
41+
steps:
42+
- name: git checkout
43+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
44+
- name: Set quay.io org name
45+
run: echo "DOCKER_REPO=$(echo quay.io/${GITHUB_REPOSITORY_OWNER} | tr -d '-')" >> $GITHUB_ENV
46+
- name: Set quay.io repo name
47+
run: echo "DOCKER_REPO_NAME=$(make docker-repo-name)" >> $GITHUB_ENV
48+
- name: Push README to quay.io
49+
uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1
50+
env:
51+
DOCKER_APIKEY: ${{ secrets.QUAY_IO_API_TOKEN }}
52+
with:
53+
destination_container_repo: ${{ env.DOCKER_REPO_NAME }}
54+
provider: quay
55+
# Empty string results in README-containers.md being pushed if it
56+
# exists. Otherwise, README.md is pushed.
57+
readme_file: ''

.github/workflows/go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v5
1919
with:
20-
go-version: ^1.18
20+
go-version: ^1.23
2121
id: go
2222

2323
- name: Get dependencies

.github/workflows/golangci-lint.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# This action is synced from https://github.com/prometheus/prometheus
3+
name: golangci-lint
4+
on:
5+
push:
6+
paths:
7+
- "go.sum"
8+
- "go.mod"
9+
- "**.go"
10+
- "scripts/errcheck_excludes.txt"
11+
- ".github/workflows/golangci-lint.yml"
12+
- ".golangci.yml"
13+
pull_request:
14+
15+
permissions: # added using https://github.com/step-security/secure-repo
16+
contents: read
17+
18+
jobs:
19+
golangci:
20+
permissions:
21+
contents: read # for actions/checkout to fetch code
22+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
23+
name: lint
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
- name: Install Go
29+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
30+
with:
31+
go-version: 1.23.x
32+
- name: Install snmp_exporter/generator dependencies
33+
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
34+
if: github.repository == 'prometheus/snmp_exporter'
35+
- name: Lint
36+
uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0
37+
with:
38+
args: --verbose
39+
version: v1.63.4

.promu.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
go:
2+
# This must match .circle/config.yml.
3+
version: 1.23
4+
repository:
5+
path: github.com/prometheus-community/fortigate_exporter
6+
build:
7+
binaries:
8+
- name: fortigate_exporter
9+
ldflags: |
10+
-X github.com/prometheus/common/version.Version={{.Version}}
11+
-X github.com/prometheus/common/version.Revision={{.Revision}}
12+
-X github.com/prometheus/common/version.Branch={{.Branch}}
13+
-X github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
14+
-X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
15+
tarball:
16+
files:
17+
- LICENSE
18+
- NOTICE

.releaserc.yml

-20
This file was deleted.

CONTRIBUTING.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ Fortigate exporter uses GitHub to manage reviews of pull requests.
44

55
* If you are a new contributor see: [Steps to Contribute](#steps-to-contribute)
66

7-
* If you have a trivial fix or improvement, go ahead and create a pull request,
8-
addressing it to @bluecmd or @secustor.
7+
* If you have a trivial fix or improvement, go ahead and create a pull request.
98

109
* If you plan to do something more impacting, first discuss your ideas
11-
in our [chat room](https://matrix.to/#/#fortigate_exporter:matrix.org) or the [discussions](https://github.com/bluecmd/fortigate_exporter/discussions/landing) page.
10+
in our [chat room](https://matrix.to/#/#fortigate_exporter:matrix.org) or the [discussions](https://github.com/prometheus-community/fortigate_exporter/discussions/landing) page.
1211
This will avoid unnecessary work and surely give you and us a good deal
1312
of inspiration.
1413

Dockerfile

+12-19
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
# Build using the minimum supported Golang version (match go.mod)
2-
FROM golang:1.18 as builder
3-
4-
WORKDIR /build
5-
6-
COPY . .
7-
RUN go get -v -t -d ./...
8-
RUN make build
9-
10-
FROM scratch
11-
WORKDIR /opt/fortigate_exporter
12-
13-
COPY --from=builder /build/target/fortigate-exporter .
14-
COPY --from=builder /etc/ssl/certs/ca-certificates.crt .
15-
ENV SSL_CERT_DIR=/opt/fortigate_exporter
16-
17-
EXPOSE 9710
18-
ENTRYPOINT ["./fortigate-exporter"]
19-
CMD ["-auth-file", "/config/fortigate-key.yaml"]
1+
ARG ARCH="amd64"
2+
ARG OS="linux"
3+
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:glibc
4+
LABEL maintainer="The Prometheus Authors <[email protected]>"
5+
6+
ARG ARCH="amd64"
7+
ARG OS="linux"
8+
COPY .build/${OS}-${ARCH}/fortigate_exporter /bin/fortigate_exporter
9+
10+
EXPOSE 9710
11+
USER nobody
12+
ENTRYPOINT [ "/bin/fortigate_exporter" ]

MAINTAINERS.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Ben Kochie <[email protected]> @SuperQ

Makefile

+22-64
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,22 @@
1-
VERSION := $(shell git describe --tags)
2-
GIT_HASH := $(shell git rev-parse --short HEAD )
3-
4-
GO_VERSION ?= $(shell go version)
5-
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
6-
LDFLAGS = -ldflags "-X main.Version=${VERSION} -X main.GitHash=${GIT_HASH} -X main.GoVersion=${GO_VERSION_NUMBER}"
7-
8-
.PHONY: build
9-
build:
10-
CGO_ENABLED=0 go build ${LDFLAGS} -v -o target/fortigate-exporter .
11-
12-
.PHONY: build-release
13-
build-release: build-release-amd64 build-release-arm64
14-
15-
.PHONY: build-release-amd64
16-
build-release-amd64:
17-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o=fortigate-exporter.linux.amd64 . && \
18-
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o=fortigate-exporter.windows.amd64.exe . && \
19-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o=fortigate-exporter.darwin.amd64 .
20-
21-
.PHONY: build-release-arm64
22-
build-release-arm64:
23-
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ${LDFLAGS} -o=fortigate-exporter.linux.arm64 . && \
24-
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ${LDFLAGS} -o=fortigate-exporter.darwin.arm64 .
25-
26-
.PHONY: generate-html-coverage
27-
generate-html-coverage:
28-
go tool cover -html=cover.out -o coverage.html
29-
@printf "Generated coverage html \n"
30-
31-
.PHONY: print-coverage
32-
print-coverage:
33-
@go tool cover -func cover.out
34-
35-
.PHONY: test-unittests
36-
test-unittests:
37-
go test -v -race -coverprofile cover.out ./...
38-
39-
.PHONY: test
40-
test: fmt-check vet test-unittests generate-html-coverage print-coverage
41-
@printf "Sucessfully run tests \n"
42-
43-
.PHONY: get-dependencies
44-
get-dependencies:
45-
go get -v -t -d ./...
46-
47-
.PHONY: vet
48-
vet:
49-
@go vet ./...
50-
@go mod tidy
51-
52-
test-output:
53-
$(shell echo $$GO_VERSION_NUMBER)
54-
55-
.PHONY: fmt-fix
56-
fmt-fix:
57-
@go mod download golang.org/x/tools
58-
@go run golang.org/x/tools/cmd/goimports -w -l .
59-
60-
.PHONY: fmt-check
61-
fmt-check:
62-
@printf "Check formatting... \n"
63-
@go mod download golang.org/x/tools
64-
@if [[ $$( go run golang.org/x/tools/cmd/goimports -l . ) ]]; then printf "Files not properly formatted. Run 'make fmt-fix' \n"; exit 1; else printf "Check formatting finished \n"; fi
1+
# Copyright 2025 The Prometheus Authors
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
# Needs to be defined before including Makefile.common to auto-generate targets
15+
DOCKER_ARCHS ?= amd64 armv7 arm64
16+
DOCKER_REPO ?= prometheuscommunity
17+
18+
include Makefile.common
19+
20+
STATICCHECK_IGNORE =
21+
22+
DOCKER_IMAGE_NAME ?= fortigate-exporter

0 commit comments

Comments
 (0)