From 07b6cb203389f18392f937e61a6271b30c7f87a1 Mon Sep 17 00:00:00 2001 From: Samuel Attwood Date: Wed, 7 Jun 2023 18:15:40 -0400 Subject: [PATCH] Bumping actions versions. Replacing deprecated ioutil functions --- .github/workflows/release.yaml | 23 ++++++++----------- .github/workflows/{testing.yaml => test.yaml} | 17 +++++++------- .goreleaser.yml | 11 ++++----- pkg/bootconfig/bootconfig.go | 5 ++-- pkg/natsreloader/natsreloader.go | 5 ++-- 5 files changed, 27 insertions(+), 34 deletions(-) rename .github/workflows/{testing.yaml => test.yaml} (59%) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b0d3c366..ed55dd8f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,12 +8,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: '1.19' + go-version: '1.20' - name: Setup QEMU uses: docker/setup-qemu-action@v2 @@ -35,20 +35,15 @@ jobs: echo tags="latest,${version}" >> $GITHUB_OUTPUT - name: Build and Push - # 2023-05-07 note: the action documents: - # This repository is considered EXPERIMENTAL and under active development - # until further notice. It is subject to non-backward compatible changes - # or removal in any future version - # thus while v3.0.1 is the latest, I'm leaving this on v2 for an owner to - # investigate. - uses: docker/bake-action@v2 - env: - TAGS: "${{ steps.tags.outputs.tags }}" - REGISTRY: "natsio" + uses: docker/bake-action@v3 with: + files: docker-bake.hcl push: true - set: + set: | goreleaser.args.GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} + env: + TAGS: "${{ steps.tags.outputs.tags }}" + REGISTRY: "natsio" - name: Attach Release Files run: gh release upload ${{ github.ref_name }} deploy/crds.yml deploy/rbac.yml diff --git a/.github/workflows/testing.yaml b/.github/workflows/test.yaml similarity index 59% rename from .github/workflows/testing.yaml rename to .github/workflows/test.yaml index ef0d6660..cd30ad5d 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/test.yaml @@ -1,22 +1,23 @@ -name: Testing +name: Test -on: -- push -- pull_request +on: [push, pull_request] jobs: build: - name: Testing Job - runs-on: ubuntu-20.04 + name: Test + runs-on: ubuntu-latest steps: - name: Setup Go id: setup-go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: '^1.19' + go-version: '1.20' + - name: Checkout source uses: actions/checkout@v3 + - name: Build run: make build + - name: Test run: make test diff --git a/.goreleaser.yml b/.goreleaser.yml index dd669880..331a3ade 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -14,11 +14,10 @@ builds: main: ./cmd/jetstream-controller binary: jetstream-controller ldflags: - - -s -w -X main.BuildTime={{.Date}} -X main.GitInfo={{.Commit}} -X main.Version={{.Version}} + - -s -w -X main.Version={{.Version}} -X main.GitInfo={{.ShortCommit}} -X main.BuildTime={{.Date}} tags: - timetzdata env: - - GO11MODULE=on - CGO_ENABLED=0 goos: - linux @@ -29,15 +28,15 @@ builds: goarm: - 6 - 7 + - id: nats-boot-config main: ./cmd/nats-boot-config binary: nats-boot-config ldflags: - - -s -w -X main.BuildTime={{.Date}} -X main.GitInfo={{.Commit}} -X main.Version={{.Version}} + - -s -w -X main.Version={{.Version}} -X main.GitInfo={{.ShortCommit}} -X main.BuildTime={{.Date}} tags: - timetzdata env: - - GO11MODULE=on - CGO_ENABLED=0 goos: - linux @@ -48,15 +47,15 @@ builds: goarm: - 6 - 7 + - id: nats-server-config-reloader main: ./cmd/nats-server-config-reloader binary: nats-server-config-reloader ldflags: - - -s -w -X main.BuildTime={{.Date}} -X main.GitInfo={{.Commit}} -X main.Version={{.Version}} + - -s -w -X main.Version={{.Version}} -X main.GitInfo={{.ShortCommit}} -X main.BuildTime={{.Date}} tags: - timetzdata env: - - GO11MODULE=on - CGO_ENABLED=0 goos: - linux diff --git a/pkg/bootconfig/bootconfig.go b/pkg/bootconfig/bootconfig.go index 4586572c..d4dd50ca 100644 --- a/pkg/bootconfig/bootconfig.go +++ b/pkg/bootconfig/bootconfig.go @@ -17,7 +17,6 @@ import ( "context" "errors" "fmt" - "io/ioutil" "os" log "github.com/sirupsen/logrus" @@ -122,7 +121,7 @@ func (c *Controller) Run(ctx context.Context) error { clientAdvertiseConfig := fmt.Sprintf("\nclient_advertise = \"%s\"\n\n", externalAddress) - err = ioutil.WriteFile(c.opts.ClientAdvertiseFileName, []byte(clientAdvertiseConfig), 0644) + err = os.WriteFile(c.opts.ClientAdvertiseFileName, []byte(clientAdvertiseConfig), 0644) if err != nil { return fmt.Errorf("Could not write client advertise config: %s", err) } @@ -130,7 +129,7 @@ func (c *Controller) Run(ctx context.Context) error { gatewayAdvertiseConfig := fmt.Sprintf("\nadvertise = \"%s\"\n\n", externalAddress) - err = ioutil.WriteFile(c.opts.GatewayAdvertiseFileName, []byte(gatewayAdvertiseConfig), 0644) + err = os.WriteFile(c.opts.GatewayAdvertiseFileName, []byte(gatewayAdvertiseConfig), 0644) if err != nil { return fmt.Errorf("Could not write gateway advertise config: %s", err) } diff --git a/pkg/natsreloader/natsreloader.go b/pkg/natsreloader/natsreloader.go index 41f15ed6..73ccad47 100644 --- a/pkg/natsreloader/natsreloader.go +++ b/pkg/natsreloader/natsreloader.go @@ -6,7 +6,6 @@ import ( "crypto/sha256" "fmt" "io" - "io/ioutil" "log" "math/rand" "os" @@ -49,7 +48,7 @@ func (r *Reloader) waitForProcess() error { startTime := time.Now() for { - pidfile, err := ioutil.ReadFile(r.PidFile) + pidfile, err := os.ReadFile(r.PidFile) if err != nil { goto WaitAndRetry } @@ -76,7 +75,7 @@ func (r *Reloader) waitForProcess() error { if attempts > 0 { log.Printf("found pid from pidfile %q after %v failed attempts (%v time after start)", - r.PidFile, attempts, time.Now().Sub(startTime)) + r.PidFile, attempts, time.Since(startTime)) } r.pid = pid