diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5af945d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +name: Go +on: + push: + branches: [ main ] + tags: + - v* + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: 'stable' + check-latest: true + + - name: Test + run: go test -v ./... + + - name: Build + run: go build -v . + + - name: Run goreleaser in release mode + if: success() && startsWith(github.ref, 'refs/tags/v') + uses: goreleaser/goreleaser-action@v7 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index ecd4343..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Go -on: - push: - tags: - - v* - branches: - - master - pull_request: {} - -jobs: - build: - name: Build - runs-on: ubuntu-latest - - strategy: - matrix: - go: [ '1.25', '1.26' ] - - steps: - - name: Set up Go ${{ matrix.go }} - uses: actions/setup-go@v6 - with: - go-version: ${{ matrix.go }} - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v6 - - - name: Go Test - run: make test - - - name: Go Build - run: make build - -# - name: Upload artifact -# uses: actions/upload-artifact@v1.0.0 -# with: -# name: check_by_powershell-go${{ matrix.go }} -# path: build diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index e3cf72c..a49f98b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -4,7 +4,7 @@ on: tags: - v* branches: - - master + - main pull_request: jobs: @@ -18,8 +18,3 @@ jobs: uses: golangci/golangci-lint-action@v9 with: version: v2.12.2 - - - name: Go mod tidy - run: | - go mod tidy - git diff --exit-code go.sum diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml deleted file mode 100644 index 062c912..0000000 --- a/.github/workflows/goreleaser.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: goreleaser - -on: - push: - tags: - - 'v*' - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v6 - with: - go-version: 1.24 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v7 - with: - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 0db7521..303f7d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .*.sw[opa] *~ +coverage.html +coverage.out /build/ /dist/ check_by_* diff --git a/.golangci.yml b/.golangci.yml index 278e9db..f143046 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,8 +5,10 @@ linters: default: all enable: - wsl_v5 + - gomodguard_v2 disable: - wsl + - gomodguard - cyclop - depguard - err113 diff --git a/go.mod b/go.mod index e656488..27967cf 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/NETWAYS/check_by_powershell -go 1.25.0 +go 1.26 require ( - github.com/NETWAYS/go-check v0.6.4 + github.com/NETWAYS/go-check v1.0.0 github.com/masterzen/winrm v0.0.0-20260407182533-5570be7f80cf github.com/spf13/pflag v1.0.10 golang.org/x/crypto v0.53.0 diff --git a/go.sum b/go.sum index f3101c7..d774349 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/Azure/go-ntlmssp v0.1.1 h1:l+FM/EEMb0U9QZE7mKNEDw5Mu3mFiaa2GKOoTSsNDP github.com/Azure/go-ntlmssp v0.1.1/go.mod h1:NYqdhxd/8aAct/s4qSYZEerdPuH1liG2/X9DiVTbhpk= github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 h1:w0E0fgc1YafGEh5cROhlROMWXiNoZqApk2PDN0M1+Ns= github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4= -github.com/NETWAYS/go-check v0.6.4 h1:4WETSVNZNEP0Yudcp5xlvxq6RGn920cmUKq4fz/P1GQ= -github.com/NETWAYS/go-check v0.6.4/go.mod h1:8/GWnq8SirreAixgRmcp82JG16NnEl38rHq9phICy9s= +github.com/NETWAYS/go-check v1.0.0 h1:YkzTwFfGR+Z+mK3Wsqpnu8wibzsB30im19iPNfCOsMQ= +github.com/NETWAYS/go-check v1.0.0/go.mod h1:8/GWnq8SirreAixgRmcp82JG16NnEl38rHq9phICy9s= github.com/bodgit/ntlmssp v0.0.0-20240506230425-31973bb52d9b h1:baFN6AnR0SeC194X2D292IUZcHDs4JjStpqtE70fjXE= github.com/bodgit/ntlmssp v0.0.0-20240506230425-31973bb52d9b/go.mod h1:Ram6ngyPDmP+0t6+4T2rymv0w0BS9N8Ch5vvUJccw5o= github.com/bodgit/windows v1.0.1 h1:tF7K6KOluPYygXa3Z2594zxlkbKPAOvqr97etrGNIz4= diff --git a/main.go b/main.go index e32e9f7..d4e4204 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,6 @@ import ( "github.com/NETWAYS/go-check" ) -// nolint: gochecknoglobals var ( // These get filled at build time with the proper vaules. version = "development" @@ -63,12 +62,12 @@ func main() { err := config.Validate() if err != nil { - check.ExitRaw(check.Unknown, "could not validate parameters: "+err.Error()) + check.Exit(check.Unknown, "could not validate parameters:", err.Error()) } rc, output, err := config.Run(time.Duration(plugin.Timeout) * time.Second) if err != nil { - check.ExitRaw(check.Unknown, "execution failed: "+err.Error()) + check.Exit(check.Unknown, "execution failed:", err.Error()) } fmt.Print(output)