Skip to content

Commit a6e58f7

Browse files
authored
upgrade to go1.19 (#1018)
Signed-off-by: cpanato <ctadeu@gmail.com> Signed-off-by: cpanato <ctadeu@gmail.com>
1 parent dc784c1 commit a6e58f7

File tree

107 files changed

+383
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+383
-301
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
- uses: imjasonh/setup-ko@78eea08f10db87a7a23a666a4a6fe2734f2eeb8d # v0.4
5151
with:
52-
version: v0.11.2
52+
version: v0.12.0
5353

5454
- name: Set up Cloud SDK
5555
uses: google-github-actions/auth@dac4e13deb3640f22e3ffe758fd3f95e6e89f712 # v0.8.1

.github/workflows/main.yml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
3636
with:
3737
go-version: ${{ env.GOVERSION }}
38+
3839
- name: Build
3940
run: make -C $GITHUB_WORKSPACE all
4041
- name: Fuzz-Build
@@ -55,9 +56,10 @@ jobs:
5556
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
5657
with:
5758
go-version: ${{ env.GOVERSION }}
59+
5860
- uses: imjasonh/setup-ko@78eea08f10db87a7a23a666a4a6fe2734f2eeb8d # v0.4
5961
with:
60-
version: v0.11.2
62+
version: v0.12.0
6163
- name: container
6264
run: |
6365
make ko-local 2>&1 | tee output.txt
@@ -78,6 +80,7 @@ jobs:
7880
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
7981
with:
8082
go-version: ${{ env.GOVERSION }}
83+
8184
- name: CLI
8285
run: ./tests/e2e-test.sh
8386
- name: Upload logs if they exist
@@ -102,6 +105,7 @@ jobs:
102105
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
103106
with:
104107
go-version: ${{ env.GOVERSION }}
108+
105109
- name: Sharding Test
106110
run: ./tests/sharding-e2e-test.sh
107111
- name: Upload logs if they exist
@@ -124,6 +128,7 @@ jobs:
124128
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
125129
with:
126130
go-version: ${{ env.GOVERSION }}
131+
127132
- name: Test for Attestation begin returned that was previously persisted in tlog
128133
run: ./tests/issue-872-e2e-test.sh
129134
- name: Upload logs if they exist
@@ -137,19 +142,20 @@ jobs:
137142
runs-on: ubuntu-20.04
138143
needs: build
139144
steps:
140-
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
141-
- name: Create git branch
142-
run: git switch -c harness-test-branch
143-
- name: Extract version of Go to use
144-
run: echo "GOVERSION=$(cat Dockerfile|grep golang | awk ' { print $2 } ' | cut -d '@' -f 1 | cut -d ':' -f 2 | uniq)" >> $GITHUB_ENV
145-
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
146-
with:
147-
go-version: ${{ env.GOVERSION }}
148-
- name: Run test harness
149-
run: ./tests/rekor-harness.sh
150-
- name: Upload logs if they exist
151-
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3
152-
if: failure()
153-
with:
154-
name: E2E Docker Compose logs
155-
path: /tmp/docker-compose.log
145+
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
146+
- name: Create git branch
147+
run: git switch -c harness-test-branch
148+
- name: Extract version of Go to use
149+
run: echo "GOVERSION=$(cat Dockerfile|grep golang | awk ' { print $2 } ' | cut -d '@' -f 1 | cut -d ':' -f 2 | uniq)" >> $GITHUB_ENV
150+
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
151+
with:
152+
go-version: ${{ env.GOVERSION }}
153+
154+
- name: Run test harness
155+
run: ./tests/rekor-harness.sh
156+
- name: Upload logs if they exist
157+
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3
158+
if: failure()
159+
with:
160+
name: E2E Docker Compose logs
161+
path: /tmp/docker-compose.log

.github/workflows/validate-release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
statuses: none
4040

4141
env:
42-
CROSS_BUILDER_IMAGE: ghcr.io/gythialy/golang-cross:v1.18.5-1@sha256:7dda2158ee68f0e4f53ca9bdf3971b2db01084dad4bdc775391e5f3bf40056a5
43-
COSIGN_IMAGE: gcr.io/projectsigstore/cosign:v1.10.1@sha256:9377edd13ae515dcb97c15052e577a2cbce098f36b0361bdb2348e3bdd8fe536
42+
CROSS_BUILDER_IMAGE: ghcr.io/gythialy/golang-cross:v1.19.0-0@sha256:904f22549b631c34c92fa696aa39144f8b5da3ee1dff095d4e3164fd50090767
43+
COSIGN_IMAGE: gcr.io/projectsigstore/cosign:v1.11.1@sha256:f9fd5a287a67f4b955d08062a966df10f9a600b6b8583fd367bce3f1f000a429
4444

4545
steps:
4646
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
@@ -49,6 +49,7 @@ jobs:
4949
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
5050
with:
5151
go-version: ${{ env.GOVERSION }}
52+
5253
- uses: anchore/sbom-action/download-syft@b5042e9d19d8b32849779bfe17673ff84aec702d # v0.12.0
5354
- name: Install GoReleaser
5455
uses: goreleaser/goreleaser-action@ff11ca24a9b39f2d36796d1fbd7a4e39c182630a # v3.1.0

.github/workflows/verify.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515

1616
name: Verify
1717

18-
on: [push, pull_request]
18+
on:
19+
push:
20+
branches:
21+
- main
22+
pull_request:
1923

2024
permissions:
2125
contents: read
@@ -31,6 +35,7 @@ jobs:
3135
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
3236
with:
3337
go-version: ${{ env.GOVERSION }}
38+
3439
- name: Install addlicense
3540
run: go install github.com/google/addlicense@v1.0.0
3641
- name: Check license headers
@@ -49,8 +54,9 @@ jobs:
4954
- uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.1.0
5055
with:
5156
go-version: ${{ env.GOVERSION }}
57+
5258
- name: golangci-lint
5359
uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # v3.2.0
5460
timeout-minutes: 5
5561
with:
56-
version: v1.46.0
62+
version: v1.49

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
linters:
1717
enable:
18-
- deadcode
18+
- unused
1919
- errcheck
2020
- gofmt
2121
- goimports
2222
- gosec
2323
- gocritic
24-
- golint
24+
- revive
2525
- misspell
2626
output:
2727
uniq-by-line: false

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
FROM golang:1.18.5@sha256:fb249eca1b9172732de4950b0fb0fb5c231b83c2c90952c56d822d8a9de4d64b AS builder
16+
FROM golang:1.19@sha256:d3f734e1f46ec36da8c1bce67cd48536138085289e24cfc8765f483c401b7d96 AS builder
1717
ENV APP_ROOT=/opt/app-root
1818
ENV GOPATH=$APP_ROOT
1919

@@ -30,7 +30,7 @@ RUN go build -ldflags "${SERVER_LDFLAGS}" ./cmd/rekor-server
3030
RUN CGO_ENABLED=0 go build -gcflags "all=-N -l" -ldflags "${SERVER_LDFLAGS}" -o rekor-server_debug ./cmd/rekor-server
3131

3232
# Multi-Stage production build
33-
FROM golang:1.18.5@sha256:fb249eca1b9172732de4950b0fb0fb5c231b83c2c90952c56d822d8a9de4d64b as deploy
33+
FROM golang:1.19@sha256:d3f734e1f46ec36da8c1bce67cd48536138085289e24cfc8765f483c401b7d96 as deploy
3434

3535
# Retrieve the binary from the previous stage
3636
COPY --from=builder /opt/app-root/src/rekor-server /usr/local/bin/rekor-server

cmd/rekor-cli/app/pflags_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ package app
1818
import (
1919
"context"
2020
"errors"
21-
"io/ioutil"
2221
"net/http"
2322
"net/http/httptest"
23+
"os"
2424
"testing"
2525

2626
"github.com/spf13/cobra"
@@ -54,27 +54,27 @@ func TestArtifactPFlags(t *testing.T) {
5454

5555
switch r.URL.Path {
5656
case "/artifact":
57-
file, err = ioutil.ReadFile("../../../tests/test_file.txt")
57+
file, err = os.ReadFile("../../../tests/test_file.txt")
5858
case "/signature":
59-
file, err = ioutil.ReadFile("../../../tests/test_file.sig")
59+
file, err = os.ReadFile("../../../tests/test_file.sig")
6060
case "/publicKey":
61-
file, err = ioutil.ReadFile("../../../tests/test_public_key.key")
61+
file, err = os.ReadFile("../../../tests/test_public_key.key")
6262
case "/rekord":
63-
file, err = ioutil.ReadFile("../../../tests/rekor.json")
63+
file, err = os.ReadFile("../../../tests/rekor.json")
6464
case "/rpmEntry":
65-
file, err = ioutil.ReadFile("../../../tests/rpm.json")
65+
file, err = os.ReadFile("../../../tests/rpm.json")
6666
case "/rpm":
67-
file, err = ioutil.ReadFile("../../../tests/test.rpm")
67+
file, err = os.ReadFile("../../../tests/test.rpm")
6868
case "/rpmPublicKey":
69-
file, err = ioutil.ReadFile("../../../tests/test_rpm_public_key.key")
69+
file, err = os.ReadFile("../../../tests/test_rpm_public_key.key")
7070
case "/alpine":
71-
file, err = ioutil.ReadFile("../../../tests/test_alpine.apk")
71+
file, err = os.ReadFile("../../../tests/test_alpine.apk")
7272
case "/alpinePublicKey":
73-
file, err = ioutil.ReadFile("../../../tests/test_alpine.pub")
73+
file, err = os.ReadFile("../../../tests/test_alpine.pub")
7474
case "/alpineEntry":
75-
file, err = ioutil.ReadFile("../../../tests/alpine.json")
75+
file, err = os.ReadFile("../../../tests/alpine.json")
7676
case "/helmEntry":
77-
file, err = ioutil.ReadFile("../../../tests/helm.json")
77+
file, err = os.ReadFile("../../../tests/helm.json")
7878
case "/not_found":
7979
err = errors.New("file not found")
8080
}
@@ -524,9 +524,9 @@ func TestSearchPFlags(t *testing.T) {
524524

525525
switch r.URL.Path {
526526
case "/artifact":
527-
file, err = ioutil.ReadFile("../../../tests/test_file.txt")
527+
file, err = os.ReadFile("../../../tests/test_file.txt")
528528
case "/publicKey":
529-
file, err = ioutil.ReadFile("../../../tests/test_public_key.key")
529+
file, err = os.ReadFile("../../../tests/test_public_key.key")
530530
case "/not_found":
531531
err = errors.New("file not found")
532532
}

cmd/rekor-cli/app/search.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"errors"
2222
"fmt"
2323
"io"
24-
"io/ioutil"
2524
"net/http"
2625
"os"
2726
"path/filepath"
@@ -136,7 +135,7 @@ var searchCmd = &cobra.Command{
136135

137136
tee = io.TeeReader(file, hasher)
138137
}
139-
if _, err := ioutil.ReadAll(tee); err != nil {
138+
if _, err := io.ReadAll(tee); err != nil {
140139
return nil, fmt.Errorf("error processing '%v': %w", artifactStr, err)
141140
}
142141

@@ -170,7 +169,7 @@ var searchCmd = &cobra.Command{
170169
if isURL(splitPubKeyString[0]) {
171170
params.Query.PublicKey.URL = strfmt.URI(splitPubKeyString[0])
172171
} else {
173-
keyBytes, err := ioutil.ReadFile(filepath.Clean(splitPubKeyString[0]))
172+
keyBytes, err := os.ReadFile(filepath.Clean(splitPubKeyString[0]))
174173
if err != nil {
175174
return nil, fmt.Errorf("error reading public key file: %w", err)
176175
}

cmd/rekor-cli/app/state/state.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package state
1717

1818
import (
1919
"encoding/json"
20-
"io/ioutil"
2120
"os"
2221
"path/filepath"
2322

@@ -44,7 +43,7 @@ func Dump(key string, sth *util.SignedCheckpoint) error {
4443
if err != nil {
4544
return err
4645
}
47-
if err := ioutil.WriteFile(statePath, b, 0600); err != nil {
46+
if err := os.WriteFile(statePath, b, 0600); err != nil {
4847
return err
4948
}
5049
return nil
@@ -56,7 +55,7 @@ func loadStateFile() persistedState {
5655
return nil
5756
}
5857
fp := filepath.Join(rekorDir, "state.json")
59-
b, err := ioutil.ReadFile(filepath.Clean(fp))
58+
b, err := os.ReadFile(filepath.Clean(fp))
6059
if err != nil {
6160
return nil
6261
}

cmd/rekor-server/app/root.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"net/http"
2121
"net/http/pprof"
2222
"os"
23+
"time"
2324

2425
homedir "github.com/mitchellh/go-homedir"
2526
"github.com/sigstore/rekor/pkg/log"
@@ -100,7 +101,14 @@ func init() {
100101
mux.HandleFunc("/debug/pprof/{action}", pprof.Index)
101102
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
102103

103-
if err := http.ListenAndServe(":6060", mux); err != nil && err != http.ErrServerClosed {
104+
srv := &http.Server{
105+
Addr: ":6060",
106+
ReadTimeout: 10 * time.Second,
107+
WriteTimeout: 10 * time.Second,
108+
Handler: mux,
109+
}
110+
111+
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
104112
log.Logger.Fatalf("Error when starting or running http server: %v", err)
105113
}
106114
}()

0 commit comments

Comments
 (0)