From a09940a18fd2069c58d629c78d69706318fda529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hellmann?= Date: Mon, 9 Sep 2024 13:33:06 +0200 Subject: [PATCH] chore: update to go1.23, github workflows & README.md --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++-- .github/workflows/main.yml | 12 ++++++----- .github/workflows/tag.yml | 23 ++++++++++++++++----- .golangci.yaml | 3 --- README.md | 1 + go.mod | 2 +- src/cmd/serviceLog.go | 2 +- src/logger/hooks.go | 2 +- src/serviceLogs/handler.go | 2 +- src/serviceLogs/handler_checkInputValues.go | 4 ++-- src/storage/handler.go | 2 +- tools/install.sh | 2 +- 12 files changed, 36 insertions(+), 23 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0e7f653d..59e4730c 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,8 +3,8 @@ #### What Type of Change is this? - [ ] New Feature -- [ ] Minor Fix -- [ ] Major Improvement +- [ ] Fix +- [ ] Improvement - [ ] Other #### Description (required) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d4e5e55..8da00e8c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,14 +43,16 @@ jobs: steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + - name: Set up Go 1.x - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: ~1.22 + go-version-file: "go.mod" id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 + env: + CGO_ENABLED: 0 - name: Get dependencies run: | diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index a2d64ee9..b2ac6e86 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -54,14 +54,16 @@ jobs: steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Go 1.x - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: - go-version: ~1.22 + go-version-file: "go.mod" id: go - - - name: Checkout code - uses: actions/checkout@v2 + env: + CGO_ENABLED: 0 - name: Get dependencies run: | @@ -101,6 +103,17 @@ jobs: asset_name: ${{ matrix.file }} asset_content_type: application/octet-stream + - name: Notify discord about new release + uses: sarisia/actions-status-discord@v1.15.0 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + title: "New version of `zcli` is ready!" + description: | + Version `${{ github.event.release.tag_name }}` + Changelog [here](${{ github.event.release.html_url }}) + color: 0xff91a4 + username: GitHub + publish-npm: needs: build runs-on: ubuntu-latest diff --git a/.golangci.yaml b/.golangci.yaml index bc9112fb..ca652e8c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -53,10 +53,8 @@ linters: - gosmopolitan - govet - grouper - - ifshort - importas - ineffassign - - interfacer - loggercheck - maintidx - makezero @@ -67,7 +65,6 @@ linters: - nilerr - noctx - nosprintfhostport - - perfsprint - prealloc - predeclared - promlinter diff --git a/README.md b/README.md index 69c7bfcf..a1c63807 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ ### Optional requirements - [Wireguard](https://www.wireguard.com/install/) - utilized by `zcli vpn` command. +- ping - utilized by `zcli vpn` command.
diff --git a/go.mod b/go.mod index 327ec187..af7b66b2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/zeropsio/zcli -go 1.21 +go 1.23 require github.com/zeropsio/zerops-go v1.0.10 diff --git a/src/cmd/serviceLog.go b/src/cmd/serviceLog.go index e11f5f0a..06109148 100644 --- a/src/cmd/serviceLog.go +++ b/src/cmd/serviceLog.go @@ -59,7 +59,7 @@ func serviceLogCmd() *cmdBuilder.Cmd { return handler.Run(ctx, serviceLogs.RunConfig{ Project: *cmdData.Project, ServiceId: serviceId, - Limit: uint32(cmdData.Params.GetInt("limit")), + Limit: cmdData.Params.GetInt("limit"), MinSeverity: cmdData.Params.GetString("minimumSeverity"), MsgType: cmdData.Params.GetString("messageType"), Format: cmdData.Params.GetString("format"), diff --git a/src/logger/hooks.go b/src/logger/hooks.go index 00bc074b..d168ff19 100644 --- a/src/logger/hooks.go +++ b/src/logger/hooks.go @@ -43,7 +43,7 @@ func (hook *VarLogHook) Fire(entry *logrus.Entry) error { defer f.Close() - _, err = io.WriteString(f, string(msg)) + _, err = io.Copy(f, bytes.NewReader(msg)) if err != nil { fmt.Fprintf(os.Stderr, "Unable to write message, %v", err) return err diff --git a/src/serviceLogs/handler.go b/src/serviceLogs/handler.go index bbe38495..7c04426e 100644 --- a/src/serviceLogs/handler.go +++ b/src/serviceLogs/handler.go @@ -15,7 +15,7 @@ type RunConfig struct { Project entity.Project ServiceId uuid.ServiceStackId Container entity.Container - Limit uint32 + Limit int MinSeverity string MsgType string Format string diff --git a/src/serviceLogs/handler_checkInputValues.go b/src/serviceLogs/handler_checkInputValues.go index 1e7b1e48..77d4c6a3 100644 --- a/src/serviceLogs/handler_checkInputValues.go +++ b/src/serviceLogs/handler_checkInputValues.go @@ -44,7 +44,7 @@ func (h *Handler) checkInputValues(config RunConfig) (inputValues InputValues, e } } return InputValues{ - limit: int(limit), + limit: limit, minSeverity: severity, facility: facility, format: format, @@ -53,7 +53,7 @@ func (h *Handler) checkInputValues(config RunConfig) (inputValues InputValues, e }, nil } -func (h *Handler) getLimit(config RunConfig) (limit uint32, err error) { +func (h *Handler) getLimit(config RunConfig) (limit int, err error) { limit = config.Limit if limit < 1 || limit > 1000 { diff --git a/src/storage/handler.go b/src/storage/handler.go index e786b634..d09b9b8f 100644 --- a/src/storage/handler.go +++ b/src/storage/handler.go @@ -55,7 +55,7 @@ func (h *Handler[T]) load() error { defer f.Close() if err := json.NewDecoder(f).Decode(&h.data); err != nil { - return errors.WithMessagef(err, i18n.T(i18n.UnableToDecodeJsonFile, h.config.FilePath)) + return errors.WithMessage(err, i18n.T(i18n.UnableToDecodeJsonFile, h.config.FilePath)) } return nil } diff --git a/tools/install.sh b/tools/install.sh index e0887c47..e089263d 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -20,4 +20,4 @@ echo "GOBIN=${GOBIN}" rm -rf tmp # https://github.com/golangci/golangci-lint#go Please, do not installDaemon golangci-lint by go get -curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$GOBIN" v1.55.2 +curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$GOBIN" v1.60.3