diff --git a/.github/stale.yml b/.github/stale.yml index 968126a6..f761b3dc 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -17,4 +17,3 @@ markComment: > for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable closeComment: false - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 633982d1..57c70cc9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.14 + go-version: ^1.15.0 id: go - name: Login to DockerHub diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05cca2f3..3cae6e32 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,21 +23,20 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Install golangci-lint - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.7 - - - name: Lint - run: $(go env GOPATH)/bin/golangci-lint run + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.32 test: name: Test runs-on: ubuntu-latest steps: - - name: Set up Go 1.14 + - name: Setup Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.14 + go-version: ^1.15.0 id: go - name: Checkout @@ -62,10 +61,10 @@ jobs: - name: Unshallow run: git fetch --prune --unshallow - - name: Set up Go + - name: Setup Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.14 + go-version: ^1.15.0 id: go - name: Run GoReleaser diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..44112823 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.3.0 + hooks: + - id: trailing-whitespace + - id: check-added-large-files + - id: check-json + - id: pretty-format-json + args: ['--autofix'] + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: detect-private-key + - id: check-merge-conflict + - id: check-executables-have-shebangs + - id: end-of-file-fixer + - id: mixed-line-ending +- repo: https://github.com/golangci/golangci-lint + rev: v1.32.2 + hooks: + - id: golangci-lint diff --git a/cmd/server.go b/cmd/server.go index bc638d8b..6778f039 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -126,9 +126,6 @@ func init() { serverCmd.Flags().StringSliceVar(&scrapeURIs, "phpfpm.scrape-uri", []string{"tcp://127.0.0.1:9000/status"}, "FastCGI address, e.g. unix:///tmp/php.sock;/status or tcp://127.0.0.1:9000/status") serverCmd.Flags().BoolVar(&fixProcessCount, "phpfpm.fix-process-count", false, "Enable to calculate process numbers via php-fpm_exporter since PHP-FPM sporadically reports wrong active/idle/total process numbers.") - //viper.BindEnv("web.listen-address", "PHP_FPM_WEB_LISTEN_ADDRESS") - //viper.BindPFlag("web.listen-address", serverCmd.Flags().Lookup("web.listen-address")) - // Workaround since vipers BindEnv is currently not working as expected (see https://github.com/spf13/viper/issues/461) envs := map[string]string{ diff --git a/phpfpm/exporter.go b/phpfpm/exporter.go index b15df466..25785c75 100644 --- a/phpfpm/exporter.go +++ b/phpfpm/exporter.go @@ -15,8 +15,9 @@ package phpfpm import ( - "sync" "fmt" + "sync" + "github.com/prometheus/client_golang/prometheus" ) diff --git a/phpfpm/phpfpm.go b/phpfpm/phpfpm.go index ad27fa02..1e1c8c19 100644 --- a/phpfpm/phpfpm.go +++ b/phpfpm/phpfpm.go @@ -213,7 +213,7 @@ func JSONResponseFixer(content []byte) []byte { sold := match[0] snew := match[1] + string(requestURI) + match[3] - c = strings.Replace(c, sold, snew, -1) + c = strings.ReplaceAll(c, sold, snew) } return []byte(c)