diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a493225e..e9eb60ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,10 +23,10 @@ permissions: jobs: unit-tests: name: Unit Tests - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup Golang Environment uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -43,7 +43,7 @@ jobs: build-docker: name: Build Docker Image - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 permissions: contents: write # for lucacome/draft-release to create/update release draft security-events: write # for github/codeql-action/upload-sarif to upload SARIF results @@ -58,7 +58,7 @@ jobs: - 5000:5000 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: fetch-depth: 0 @@ -164,14 +164,13 @@ jobs: - name: Setup Snapcraft run: | - sudo apt-get update - sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft + sudo snap install snapcraft --classic mkdir -p $HOME/.cache/snapcraft/download mkdir -p $HOME/.cache/snapcraft/stage-packages if: github.ref_type == 'tag' - name: Install Nix - uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b # v27 + uses: cachix/install-nix-action@9f70348d77d0422624097c4b7a75563948901306 # v29 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} if: github.ref_type == 'tag' @@ -218,7 +217,7 @@ jobs: add-cpes-if-none: true - name: Upload scan result to GitHub Security tab - uses: github/codeql-action/upload-sarif@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7 + uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9 continue-on-error: true with: sarif_file: ${{ steps.scan.outputs.sarif }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e8b03ed7..d156368b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -21,7 +21,7 @@ permissions: jobs: analyze: name: Analyze - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 permissions: actions: read # for github/codeql-action/init to get workflow details contents: read # for actions/checkout to fetch code @@ -45,7 +45,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup Golang Environment uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -55,7 +55,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7 + uses: github/codeql-action/init@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} @@ -67,6 +67,6 @@ jobs: # queries: security-extended,security-and-quality - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7 + uses: github/codeql-action/analyze@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index fac275be..88fe94e7 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -13,13 +13,13 @@ permissions: jobs: dependency-review: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 permissions: contents: read # for actions/checkout pull-requests: write # for actions/dependency-review-action to post comments steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Dependency Review uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 diff --git a/.github/workflows/dockerhub-description.yml b/.github/workflows/dockerhub-description.yml index 94f68e74..f62f6be3 100644 --- a/.github/workflows/dockerhub-description.yml +++ b/.github/workflows/dockerhub-description.yml @@ -16,10 +16,10 @@ permissions: jobs: dockerHubDescription: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 if: ${{ github.event.repository.fork == false }} steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Modify readme for DockerHub run: | diff --git a/.github/workflows/f5-cla.yml b/.github/workflows/f5-cla.yml index de0dbc8a..7f2c1d6c 100644 --- a/.github/workflows/f5-cla.yml +++ b/.github/workflows/f5-cla.yml @@ -19,7 +19,7 @@ permissions: jobs: f5-cla: name: F5 CLA - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 permissions: actions: write contents: read @@ -28,7 +28,7 @@ jobs: steps: - name: Run F5 Contributor License Agreement (CLA) assistant if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have hereby read the F5 CLA and agree to its terms') || github.event_name == 'pull_request_target' - uses: contributor-assistant/github-action@f41946747f85d28e9a738f4f38dbcc74b69c7e0e # v2.5.1 + uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1 with: # Any pull request targeting the following branch will trigger a CLA check. branch: "main" diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml index c63178ce..a8b07881 100644 --- a/.github/workflows/fossa.yml +++ b/.github/workflows/fossa.yml @@ -18,11 +18,11 @@ permissions: jobs: scan: name: Fossa - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 if: ${{ github.event.repository.fork == false }} steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Scan uses: fossas/fossa-action@09bcf127dc0ccb4b5a023f6f906728878e8610ba # v1.4.0 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 9cda1a2c..d33a50ef 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -10,9 +10,9 @@ jobs: permissions: contents: read pull-requests: write - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: sparse-checkout: | labeler.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index baa34aee..15b5e25b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,10 +19,10 @@ permissions: jobs: lint: name: Go Lint - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup Golang Environment uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -36,22 +36,22 @@ jobs: actionlint: name: Actionlint - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Lint Actions - uses: reviewdog/action-actionlint@05c9d7bef25a46caf572df3497afa7082fc111df # v1.55.0 + uses: reviewdog/action-actionlint@15a7a477ab5ab768a41c39b2c53970bf151c73f3 # v1.56.0 with: actionlint_flags: -shellcheck "" markdown-lint: name: Markdown Lint - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Lint Markdown uses: DavidAnson/markdownlint-cli2-action@db43aef879112c3119a410d69f66701e0d530809 # v17.0.0 @@ -62,10 +62,10 @@ jobs: yaml-lint: name: YAML lint - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Lint YAML uses: reviewdog/action-yamllint@e09f07780388032a624e9eb44a23fd1bbb4052cc # v1.19.0 diff --git a/.github/workflows/notifications.yml b/.github/workflows/notifications.yml index bbaa20d1..8b9b9b7e 100644 --- a/.github/workflows/notifications.yml +++ b/.github/workflows/notifications.yml @@ -16,7 +16,7 @@ permissions: jobs: on-failure: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 if: ${{ github.event.workflow_run.conclusion == 'failure' }} permissions: contents: read diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index e4c5a685..de5d092c 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -13,7 +13,7 @@ permissions: read-all jobs: analysis: name: Scorecard analysis - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 permissions: # Needed to upload the results to code-scanning dashboard. security-events: write @@ -25,7 +25,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: persist-credentials: false @@ -56,6 +56,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7 + uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9 with: sarif_file: results.sarif diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 031589dd..a6a292a9 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -11,7 +11,7 @@ jobs: permissions: issues: write # for actions/stale to close stale issues pull-requests: write # for actions/stale to close stale PRs - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 with: diff --git a/.golangci.yml b/.golangci.yml index bbdd7b97..3a58e95a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,24 +5,33 @@ linters-settings: ignore-generated-header: true rules: - name: blank-imports + - name: constant-logical-expr - name: context-as-argument - name: context-keys-type + - name: defer - name: dot-imports + - name: duplicated-imports - name: empty-block - name: error-naming - name: error-return - name: error-strings - name: errorf - name: exported + - name: import-shadowing - name: increment-decrement - name: indent-error-flow - name: package-comments - name: range + - name: range-val-address + - name: range-val-in-closure - name: receiver-naming - name: redefines-builtin-id + - name: string-of-int - name: superfluous-else - name: time-naming + - name: unchecked-type-assertion - name: unexported-return + - name: unnecessary-stmt - name: unreachable-code - name: unused-parameter - name: var-declaration @@ -37,6 +46,7 @@ linters: - asasalint - asciicheck - bidichk + - containedctx - contextcheck - copyloopvar - dupword @@ -62,9 +72,11 @@ linters: - intrange - loggercheck - makezero + - mirror - misspell - musttag - nilerr + - nilnil - noctx - nolintlint - paralleltest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2194d6bf..e16e90d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,7 @@ repos: - id: golangci-lint-full - repo: https://github.com/gitleaks/gitleaks - rev: v8.19.2 + rev: v8.19.3 hooks: - id: gitleaks diff --git a/Makefile b/Makefile index acc2c03c..ec92f30f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 1.3.0 TAG = $(VERSION) PREFIX = nginx/nginx-prometheus-exporter -# renovate: datasource=docker depName=golangci/golangci-lint +# renovate: datasource=github-tags depName=golangci/golangci-lint GOLANGCI_LINT_VERSION = v1.61.0 .DEFAULT_GOAL:=nginx-prometheus-exporter @@ -21,7 +21,7 @@ build-goreleaser: ## Build all binaries using GoReleaser .PHONY: lint lint: ## Run linter - docker run --pull always --rm -v $(shell pwd):/nginx-prometheus-exporter -w /nginx-prometheus-exporter -v $(shell go env GOCACHE):/cache/go -e GOCACHE=/cache/go -e GOLANGCI_LINT_CACHE=/cache/go -v $(shell go env GOPATH)/pkg:/go/pkg golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) golangci-lint --color always run + go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --fix .PHONY: test test: ## Run tests diff --git a/collector/nginx_plus.go b/collector/nginx_plus.go index d6baab09..0f524ff1 100644 --- a/collector/nginx_plus.go +++ b/collector/nginx_plus.go @@ -1,12 +1,13 @@ package collector import ( + "context" "fmt" "log/slog" "strconv" "sync" - plusclient "github.com/nginxinc/nginx-plus-go-client/client" + plusclient "github.com/nginxinc/nginx-plus-go-client/v2/client" "github.com/prometheus/client_golang/prometheus" ) @@ -622,7 +623,8 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) { c.mutex.Lock() // To protect metrics from concurrent collects defer c.mutex.Unlock() - stats, err := c.nginxClient.GetStats() + // FIXME: https://github.com/nginxinc/nginx-prometheus-exporter/issues/858 + stats, err := c.nginxClient.GetStats(context.TODO()) if err != nil { c.upMetric.Set(nginxDown) ch <- c.upMetric diff --git a/exporter.go b/exporter.go index 88950983..7f165444 100644 --- a/exporter.go +++ b/exporter.go @@ -16,7 +16,7 @@ import ( "syscall" "time" - plusclient "github.com/nginxinc/nginx-plus-go-client/client" + plusclient "github.com/nginxinc/nginx-plus-go-client/v2/client" "github.com/nginxinc/nginx-prometheus-exporter/client" "github.com/nginxinc/nginx-prometheus-exporter/collector" @@ -294,9 +294,9 @@ func cloneRequest(req *http.Request) *http.Request { func addMissingEnvironmentFlags(ka *kingpin.Application) { for _, f := range ka.Model().FlagGroupModel.Flags { if strings.HasPrefix(f.Name, "web.") && f.Envar == "" { - flag := ka.GetFlag(f.Name) - if flag != nil { - flag.Envar(convertFlagToEnvar(strings.TrimPrefix(f.Name, "web."))) + retrievedFlag := ka.GetFlag(f.Name) + if retrievedFlag != nil { + retrievedFlag.Envar(convertFlagToEnvar(strings.TrimPrefix(f.Name, "web."))) } } } diff --git a/go.mod b/go.mod index 3b271f49..30d078d5 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.22.6 require ( github.com/alecthomas/kingpin/v2 v2.4.0 - github.com/nginxinc/nginx-plus-go-client v1.3.0 - github.com/prometheus/client_golang v1.20.3 + github.com/nginxinc/nginx-plus-go-client/v2 v2.0.1 + github.com/prometheus/client_golang v1.20.4 github.com/prometheus/common v0.59.1 github.com/prometheus/exporter-toolkit v0.13.0 ) diff --git a/go.sum b/go.sum index ee488c54..caec8fb3 100644 --- a/go.sum +++ b/go.sum @@ -32,12 +32,12 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nginxinc/nginx-plus-go-client v1.3.0 h1:q/aeT4B5k0KLwWlefoBzfLfraBBvIKLuDg+lLFWAo4I= -github.com/nginxinc/nginx-plus-go-client v1.3.0/go.mod h1:n8OFLzrJulJ2fur28Cwa1Qp5DZNS2VicLV+Adt30LQ4= +github.com/nginxinc/nginx-plus-go-client/v2 v2.0.1 h1:5VVK38bnELMDWnwfF6dSv57ResXh9AUzeDa72ENj94o= +github.com/nginxinc/nginx-plus-go-client/v2 v2.0.1/go.mod h1:He+1izxYxVVO5/C9ZTukwOpvkAx5eS19nRQgKXDhX5I= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4= -github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0=