From 4630c4040dfa7e6ed3ce2d1bcdafb40e9e55b6b7 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Fri, 18 Oct 2024 10:39:59 -0400 Subject: [PATCH] don't pin chainguard-dev/actions (#2025) * don't pin chainguard-dev/actions Signed-off-by: Jason Hall * these too Signed-off-by: Jason Hall * Update style.yaml * update go versions Signed-off-by: Jason Hall * use latest go everywhere Signed-off-by: Jason Hall --------- Signed-off-by: Jason Hall --- .github/workflows/boilerplate.yaml | 2 +- .github/workflows/build.yaml | 7 +---- .github/workflows/bump-deps.yaml | 3 +- .github/workflows/donotsubmit.yaml | 2 +- .github/workflows/e2e.yaml | 10 +++--- .github/workflows/ecr-auth.yaml | 6 ++-- .github/workflows/ghcr-auth.yaml | 5 ++- .github/workflows/presubmit.yaml | 3 +- .github/workflows/style.yaml | 16 +++++----- .github/workflows/test.yaml | 9 +----- .golangci.yaml | 13 ++++---- cmd/crane/cmd/append.go | 2 +- cmd/crane/cmd/auth.go | 4 +-- cmd/crane/cmd/root.go | 2 +- cmd/crane/cmd/validate.go | 4 +-- cmd/krane/go.mod | 2 +- cmd/krane/go.sum | 2 ++ go.mod | 2 +- go.sum | 1 + hack/presubmit.sh | 2 +- pkg/authn/k8schain/go.mod | 2 +- pkg/authn/k8schain/go.sum | 10 ++++++ pkg/authn/keychain.go | 4 +-- pkg/authn/kubernetes/go.mod | 2 +- pkg/authn/kubernetes/go.sum | 8 +++++ pkg/name/ref.go | 2 +- pkg/v1/partial/index_test.go | 4 +-- pkg/v1/remote/error_roundtrip_test.go | 2 +- pkg/v1/remote/transport/basic_test.go | 12 ++----- pkg/v1/remote/transport/ping_test.go | 38 ++++++++--------------- pkg/v1/remote/transport/retry_test.go | 2 +- pkg/v1/remote/transport/transport_test.go | 36 +++++++-------------- 32 files changed, 95 insertions(+), 124 deletions(-) diff --git a/.github/workflows/boilerplate.yaml b/.github/workflows/boilerplate.yaml index bae82167e..de883d711 100644 --- a/.github/workflows/boilerplate.yaml +++ b/.github/workflows/boilerplate.yaml @@ -27,7 +27,7 @@ jobs: - name: Check out code uses: actions/checkout@v4 - - uses: chainguard-dev/actions/boilerplate@5e21cb47971231c078a677dfe89a348371cb880c # main + - uses: chainguard-dev/actions/boilerplate@main with: extension: ${{ matrix.extension }} language: ${{ matrix.language }} diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 913923f8a..93dd5d320 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,16 +10,11 @@ jobs: name: Build runs-on: ubuntu-latest - strategy: - matrix: - go-version: [1.19, 1.20] - steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go-version }} - check-latest: true + go-version-file: go.mod - run: | go build ./... diff --git a/.github/workflows/bump-deps.yaml b/.github/workflows/bump-deps.yaml index a57304aa1..8ea03d443 100644 --- a/.github/workflows/bump-deps.yaml +++ b/.github/workflows/bump-deps.yaml @@ -21,8 +21,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.19 - check-latest: true + go-version-file: go.mod - run: ./hack/bump-deps.sh - name: Create Pull Request diff --git a/.github/workflows/donotsubmit.yaml b/.github/workflows/donotsubmit.yaml index 0ebf7e08f..5a294523e 100644 --- a/.github/workflows/donotsubmit.yaml +++ b/.github/workflows/donotsubmit.yaml @@ -12,4 +12,4 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: chainguard-dev/actions/donotsubmit@5e21cb47971231c078a677dfe89a348371cb880c # main + - uses: chainguard-dev/actions/donotsubmit@main diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index af37dd05e..dcb345242 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -19,8 +19,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.19 - check-latest: true + go-version-file: go.mod - name: crane append to an image, set the entrypoint, run it locally, roundtrip it shell: bash @@ -29,6 +28,7 @@ jobs: # Setup local registry go run ./cmd/registry & + sleep 3 base=alpine platform=linux/amd64 @@ -82,13 +82,13 @@ jobs: ./app/crane pull --platform=linux/arm64 --format=oci $remote $distroless ./app/crane push $distroless $local diff <(./app/crane manifest --platform linux/arm64 $remote) <(./app/crane manifest $local) - + - name: crane pull image, and export it from stdin to filesystem tar to stdout shell: bash run: | set -euxo pipefail - + ./app/crane pull ubuntu ubuntu.tar ./app/crane export - - < ubuntu.tar > filesystem.tar ls -la *.tar - + diff --git a/.github/workflows/ecr-auth.yaml b/.github/workflows/ecr-auth.yaml index f17e5132d..7b87f3d75 100644 --- a/.github/workflows/ecr-auth.yaml +++ b/.github/workflows/ecr-auth.yaml @@ -21,8 +21,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.19 - check-latest: true + go-version-file: go.mod - name: Install krane working-directory: ./cmd/krane @@ -61,8 +60,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.19 - check-latest: true + go-version-file: go.mod - name: Install crane working-directory: ./cmd/crane diff --git a/.github/workflows/ghcr-auth.yaml b/.github/workflows/ghcr-auth.yaml index c8bfa01c4..262933921 100644 --- a/.github/workflows/ghcr-auth.yaml +++ b/.github/workflows/ghcr-auth.yaml @@ -17,8 +17,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.19 - check-latest: true + go-version-file: go.mod - name: Install krane working-directory: ./cmd/krane @@ -44,4 +43,4 @@ jobs: if [[ "$CRED1" == "$CRED2" ]] ; then echo "credentials are cached by infrastructure" fi - + diff --git a/.github/workflows/presubmit.yaml b/.github/workflows/presubmit.yaml index 680f006aa..d0c057f4c 100644 --- a/.github/workflows/presubmit.yaml +++ b/.github/workflows/presubmit.yaml @@ -29,6 +29,5 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.19 - check-latest: true + go-version-file: go.mod - run: ./hack/presubmit.sh diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index 623f4e462..f97e209e2 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -10,12 +10,11 @@ jobs: name: check goimports runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.19 - check-latest: true - - uses: actions/checkout@v4 - - uses: chainguard-dev/actions/goimports@5e21cb47971231c078a677dfe89a348371cb880c # main + go-version-file: go.mod + - uses: chainguard-dev/actions/goimports@main lint: name: Lint @@ -25,12 +24,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.19 - check-latest: true + go-version-file: go.mod - uses: golangci/golangci-lint-action@v3.4.0 with: - version: v1.51.2 + version: v1.61.0 - uses: reviewdog/action-misspell@v1 if: ${{ always() }} @@ -40,10 +38,10 @@ jobs: locale: "US" exclude: ./vendor/* - - uses: chainguard-dev/actions/trailing-space@5e21cb47971231c078a677dfe89a348371cb880c # main + - uses: chainguard-dev/actions/trailing-space@main if: ${{ always() }} - - uses: chainguard-dev/actions/eof-newline@5e21cb47971231c078a677dfe89a348371cb880c # main + - uses: chainguard-dev/actions/eof-newline@main if: ${{ always() }} - uses: get-woke/woke-action-reviewdog@v0 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 05b3a0ed8..db456e75d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,21 +7,14 @@ on: branches: ['main'] jobs: - test: - strategy: - matrix: - go-version: [1.19, '1.20'] - name: Unit Tests runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go-version }} - check-latest: true + go-version-file: go.mod - run: go test -coverprofile=coverage.txt -covermode=atomic -race ./... diff --git a/.golangci.yaml b/.golangci.yaml index 1dee826a6..bf48f711d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,11 +1,10 @@ run: timeout: 5m - skip-dirs: +issues: + exclude-dirs: - internal - pkg/registry - -issues: exclude-rules: - path: test # Excludes /test, *_test.go etc. linters: @@ -35,6 +34,8 @@ linters: linters-settings: depguard: - include-go-root: true - packages-with-error-message: - - crypto/sha256: "use crypto.SHA256 instead" + rules: + main: + deny: + - pkg: "crypto/sha256" + desc: use crypto.SHA256 instead diff --git a/cmd/crane/cmd/append.go b/cmd/crane/cmd/append.go index 3555a7864..f00a00a27 100644 --- a/cmd/crane/cmd/append.go +++ b/cmd/crane/cmd/append.go @@ -45,7 +45,7 @@ If the base image is a Windows base image (i.e., its config.OS is "windows"), the contents of the tarballs will be modified to be suitable for a Windows container image.`, Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { var base v1.Image var err error diff --git a/cmd/crane/cmd/auth.go b/cmd/crane/cmd/auth.go index 433d4195b..cd2b2897d 100644 --- a/cmd/crane/cmd/auth.go +++ b/cmd/crane/cmd/auth.go @@ -211,7 +211,7 @@ func NewCmdAuthLogin(argv ...string) *cobra.Command { Short: "Log in to a registry", Example: eg, Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { reg, err := name.NewRegistry(args[0]) if err != nil { return err @@ -285,7 +285,7 @@ func NewCmdAuthLogout(argv ...string) *cobra.Command { Short: "Log out of a registry", Example: eg, Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { reg, err := name.NewRegistry(args[0]) if err != nil { return err diff --git a/cmd/crane/cmd/root.go b/cmd/crane/cmd/root.go index 8fc8ccefa..abfd1dc99 100644 --- a/cmd/crane/cmd/root.go +++ b/cmd/crane/cmd/root.go @@ -56,7 +56,7 @@ func New(use, short string, options []crane.Option) *cobra.Command { RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Usage() }, DisableAutoGenTag: true, SilenceUsage: true, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { options = append(options, crane.WithContext(cmd.Context())) // TODO(jonjohnsonjr): crane.Verbose option? if verbose { diff --git a/cmd/crane/cmd/validate.go b/cmd/crane/cmd/validate.go index 411772f52..c26da6baa 100644 --- a/cmd/crane/cmd/validate.go +++ b/cmd/crane/cmd/validate.go @@ -33,8 +33,8 @@ func NewCmdValidate(options *[]crane.Option) *cobra.Command { validateCmd := &cobra.Command{ Use: "validate", Short: "Validate that an image is well-formed", - Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { if tarballPath != "" { img, err := tarball.ImageFromPath(tarballPath, nil) if err != nil { diff --git a/cmd/krane/go.mod b/cmd/krane/go.mod index 6b4f74bce..5e23afc8c 100644 --- a/cmd/krane/go.mod +++ b/cmd/krane/go.mod @@ -1,6 +1,6 @@ module github.com/google/go-containerregistry/cmd/krane -go 1.18 +go 1.23.0 replace github.com/google/go-containerregistry => ../../ diff --git a/cmd/krane/go.sum b/cmd/krane/go.sum index d7b6bde0d..7467c9865 100644 --- a/cmd/krane/go.sum +++ b/cmd/krane/go.sum @@ -140,6 +140,7 @@ golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -187,6 +188,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/go.mod b/go.mod index 323b6c64f..934dbe2cf 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/google/go-containerregistry -go 1.18 +go 1.23.0 require ( github.com/containerd/stargz-snapshotter/estargz v0.14.3 diff --git a/go.sum b/go.sum index 70e16e3e8..8720723a1 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,7 @@ cloud.google.com/go/compute v1.19.3/go.mod h1:qxvISKp/gYnXkSAD1ppcSOveRAmzxicEv/ cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= diff --git a/hack/presubmit.sh b/hack/presubmit.sh index 25afe44ed..076fd94b5 100755 --- a/hack/presubmit.sh +++ b/hack/presubmit.sh @@ -26,7 +26,7 @@ export PATH="${PATH}:${TMP_DIR}/bin" export GOPATH="${TMP_DIR}" pushd ${TMP_DIR} trap popd EXIT -go install honnef.co/go/tools/cmd/staticcheck@v0.3.3 +go install honnef.co/go/tools/cmd/staticcheck@latest popd pushd ${PROJECT_ROOT} diff --git a/pkg/authn/k8schain/go.mod b/pkg/authn/k8schain/go.mod index 7d4e8cb0f..7db069740 100644 --- a/pkg/authn/k8schain/go.mod +++ b/pkg/authn/k8schain/go.mod @@ -1,6 +1,6 @@ module github.com/google/go-containerregistry/pkg/authn/k8schain -go 1.18 +go 1.23.0 replace ( github.com/google/go-containerregistry => ../../../ diff --git a/pkg/authn/k8schain/go.sum b/pkg/authn/k8schain/go.sum index 9a1955b9e..f0b810d71 100644 --- a/pkg/authn/k8schain/go.sum +++ b/pkg/authn/k8schain/go.sum @@ -98,6 +98,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= +github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -110,6 +111,7 @@ github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= @@ -149,6 +151,7 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -168,6 +171,7 @@ github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -184,7 +188,9 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk= +github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo= github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= +github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc3 h1:fzg1mXZFj8YdPeNkRXMg+zb88BFV0Ys52cJydRwBkb8= @@ -196,12 +202,14 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sirupsen/logrus v1.9.1 h1:Ou41VVR3nMWWmTiEUnj0OlsgOSCUFgsPAOl6jRIcVtQ= github.com/sirupsen/logrus v1.9.1/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= @@ -317,6 +325,7 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -367,6 +376,7 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.1.0 h1:rVV8Tcg/8jHUkPUorwjaMTtemIMVXfIPKiOqnhEhakk= +gotest.tools/v3 v3.1.0/go.mod h1:fHy7eyTmJFO5bQbUsEGQ1v4m2J3Jz9eWL54TP2/ZuYQ= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.27.1 h1:Z6zUGQ1Vd10tJ+gHcNNNgkV5emCyW+v2XTmn+CLjSd0= diff --git a/pkg/authn/keychain.go b/pkg/authn/keychain.go index f4c452bdc..6e8814d80 100644 --- a/pkg/authn/keychain.go +++ b/pkg/authn/keychain.go @@ -84,7 +84,7 @@ func (dk *defaultKeychain) Resolve(target Resource) (Authenticator, error) { } // Resolve implements Keychain. -func (dk *defaultKeychain) ResolveContext(ctx context.Context, target Resource) (Authenticator, error) { +func (dk *defaultKeychain) ResolveContext(_ context.Context, target Resource) (Authenticator, error) { dk.mu.Lock() defer dk.mu.Unlock() @@ -204,7 +204,7 @@ func (w wrapper) Resolve(r Resource) (Authenticator, error) { return w.ResolveContext(context.Background(), r) } -func (w wrapper) ResolveContext(ctx context.Context, r Resource) (Authenticator, error) { +func (w wrapper) ResolveContext(_ context.Context, r Resource) (Authenticator, error) { u, p, err := w.h.Get(r.RegistryStr()) if err != nil { return Anonymous, nil diff --git a/pkg/authn/kubernetes/go.mod b/pkg/authn/kubernetes/go.mod index 94ed42534..b4d991189 100644 --- a/pkg/authn/kubernetes/go.mod +++ b/pkg/authn/kubernetes/go.mod @@ -1,6 +1,6 @@ module github.com/google/go-containerregistry/pkg/authn/kubernetes -go 1.18 +go 1.23.0 replace github.com/google/go-containerregistry => ../../../ diff --git a/pkg/authn/kubernetes/go.sum b/pkg/authn/kubernetes/go.sum index ab1ddeabe..34c636cb2 100644 --- a/pkg/authn/kubernetes/go.sum +++ b/pkg/authn/kubernetes/go.sum @@ -41,6 +41,7 @@ github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -75,6 +76,7 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -88,6 +90,7 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -104,7 +107,9 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk= +github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo= github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= +github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -114,11 +119,13 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/sirupsen/logrus v1.9.1 h1:Ou41VVR3nMWWmTiEUnj0OlsgOSCUFgsPAOl6jRIcVtQ= github.com/sirupsen/logrus v1.9.1/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= @@ -205,6 +212,7 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/name/ref.go b/pkg/name/ref.go index 912ab3301..0a0486772 100644 --- a/pkg/name/ref.go +++ b/pkg/name/ref.go @@ -44,7 +44,7 @@ func ParseReference(s string, opts ...Option) (Reference, error) { if d, err := NewDigest(s, opts...); err == nil { return d, nil } - return nil, newErrBadName("could not parse reference: " + s) + return nil, newErrBadName("could not parse reference: %s", s) } type stringConst string diff --git a/pkg/v1/partial/index_test.go b/pkg/v1/partial/index_test.go index c28975812..4a3518665 100644 --- a/pkg/v1/partial/index_test.go +++ b/pkg/v1/partial/index_test.go @@ -105,9 +105,7 @@ func TestFindIndexes(t *testing.T) { } // just see if it finds all of the indexes - matcher := func(desc v1.Descriptor) bool { - return true - } + matcher := func(v1.Descriptor) bool { return true } index := mutate.AppendManifests(base, adds...) idxes, err := partial.FindIndexes(index, matcher) switch { diff --git a/pkg/v1/remote/error_roundtrip_test.go b/pkg/v1/remote/error_roundtrip_test.go index 5b81ee50d..9396dac43 100644 --- a/pkg/v1/remote/error_roundtrip_test.go +++ b/pkg/v1/remote/error_roundtrip_test.go @@ -36,7 +36,7 @@ func TestStatusCodeReturned(t *testing.T) { Handler http.Handler }{{ Description: "Only returns teapot status", - Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + Handler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusTeapot) }), }, { diff --git a/pkg/v1/remote/transport/basic_test.go b/pkg/v1/remote/transport/basic_test.go index 68dd90e0c..fe6c266af 100644 --- a/pkg/v1/remote/transport/basic_test.go +++ b/pkg/v1/remote/transport/basic_test.go @@ -46,9 +46,7 @@ func TestBasicTransport(t *testing.T) { defer server.Close() inner := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } basic := &authn.Basic{Username: username, Password: password} @@ -96,9 +94,7 @@ func TestBasicTransportRegistryToken(t *testing.T) { defer server.Close() inner := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } client := http.Client{Transport: &basicTransport{inner: inner, auth: tc.auth, target: "gcr.io"}} @@ -125,9 +121,7 @@ func TestBasicTransportWithEmptyAuthnCred(t *testing.T) { defer server.Close() inner := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } client := http.Client{Transport: &basicTransport{inner: inner, auth: authn.Anonymous, target: "gcr.io"}} diff --git a/pkg/v1/remote/transport/ping_test.go b/pkg/v1/remote/transport/ping_test.go index 36d79ab20..3c0c5b981 100644 --- a/pkg/v1/remote/transport/ping_test.go +++ b/pkg/v1/remote/transport/ping_test.go @@ -33,12 +33,12 @@ var ( func TestPingNoChallenge(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } @@ -57,15 +57,13 @@ func TestPingNoChallenge(t *testing.T) { func TestPingBasicChallengeNoParams(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("WWW-Authenticate", `BASIC`) http.Error(w, "Unauthorized", http.StatusUnauthorized) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } pr, err := Ping(context.Background(), testRegistry, tprt) @@ -82,15 +80,13 @@ func TestPingBasicChallengeNoParams(t *testing.T) { func TestPingBearerChallengeWithParams(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("WWW-Authenticate", `Bearer realm="http://auth.example.com/token"`) http.Error(w, "Unauthorized", http.StatusUnauthorized) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } pr, err := Ping(context.Background(), testRegistry, tprt) @@ -107,16 +103,14 @@ func TestPingBearerChallengeWithParams(t *testing.T) { func TestPingMultipleChallenges(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Add("WWW-Authenticate", "Negotiate") w.Header().Add("WWW-Authenticate", `Basic realm="http://auth.example.com/token"`) http.Error(w, "Unauthorized", http.StatusUnauthorized) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } pr, err := Ping(context.Background(), testRegistry, tprt) @@ -133,16 +127,14 @@ func TestPingMultipleChallenges(t *testing.T) { func TestPingMultipleNotSupportedChallenges(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Add("WWW-Authenticate", "Negotiate") w.Header().Add("WWW-Authenticate", "Digest") http.Error(w, "Unauthorized", http.StatusUnauthorized) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } pr, err := Ping(context.Background(), testRegistry, tprt) @@ -156,15 +148,13 @@ func TestPingMultipleNotSupportedChallenges(t *testing.T) { func TestUnsupportedStatus(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("WWW-Authenticate", `Bearer realm="http://auth.example.com/token`) http.Error(w, "Forbidden", http.StatusForbidden) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } pr, err := Ping(context.Background(), testRegistry, tprt) @@ -206,9 +196,7 @@ func TestPingHttpFallback(t *testing.T) { defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } fallbackDelay = 2 * time.Millisecond diff --git a/pkg/v1/remote/transport/retry_test.go b/pkg/v1/remote/transport/retry_test.go index dc65f0836..33011d193 100644 --- a/pkg/v1/remote/transport/retry_test.go +++ b/pkg/v1/remote/transport/retry_test.go @@ -145,7 +145,7 @@ func TestRetryDefaults(t *testing.T) { func TestTimeoutContext(t *testing.T) { tr := NewRetry(http.DefaultTransport) - slowServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + slowServer := httptest.NewServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) { // hanging request time.Sleep(time.Second * 1) })) diff --git a/pkg/v1/remote/transport/transport_test.go b/pkg/v1/remote/transport/transport_test.go index 18625c081..fb5c33f22 100644 --- a/pkg/v1/remote/transport/transport_test.go +++ b/pkg/v1/remote/transport/transport_test.go @@ -35,15 +35,13 @@ var ( func TestTransportNoActionIfTransportIsAlreadyWrapper(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("WWW-Authenticate", `Bearer realm="http://foo.io"`) http.Error(w, "Should not contact the server", http.StatusBadRequest) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } wTprt := &Wrapper{inner: tprt} @@ -89,15 +87,13 @@ func TestTransportSelectionAnonymous(t *testing.T) { func TestTransportSelectionBasic(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("WWW-Authenticate", `Basic`) http.Error(w, "Unauthorized", http.StatusUnauthorized) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } basic := &authn.Basic{Username: "foo", Password: "bar"} @@ -121,15 +117,13 @@ func (a *badAuth) Authorization() (*authn.AuthConfig, error) { func TestTransportBadAuth(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("WWW-Authenticate", `Bearer realm="http://foo.io"`) http.Error(w, "Unauthorized", http.StatusUnauthorized) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } if _, err := NewWithContext(context.Background(), testReference.Context().Registry, &badAuth{}, tprt, []string{testReference.Scope(PullScope)}); err == nil { @@ -167,9 +161,7 @@ func TestTransportSelectionBearer(t *testing.T) { })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } basic := &authn.Basic{Username: "foo", Password: "bar"} @@ -186,15 +178,13 @@ func TestTransportSelectionBearer(t *testing.T) { func TestTransportSelectionBearerMissingRealm(t *testing.T) { server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("WWW-Authenticate", `Bearer service="gcr.io"`) http.Error(w, "Unauthorized", http.StatusUnauthorized) })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } basic := &authn.Basic{Username: "foo", Password: "bar"} @@ -207,7 +197,7 @@ func TestTransportSelectionBearerMissingRealm(t *testing.T) { func TestTransportSelectionBearerAuthError(t *testing.T) { request := 0 server := httptest.NewServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { request++ switch request { case 1: @@ -219,9 +209,7 @@ func TestTransportSelectionBearerAuthError(t *testing.T) { })) defer server.Close() tprt := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - return url.Parse(server.URL) - }, + Proxy: func(*http.Request) (*url.URL, error) { return url.Parse(server.URL) }, } basic := &authn.Basic{Username: "foo", Password: "bar"} @@ -236,7 +224,7 @@ func TestTransportAlwaysTriesHttps(t *testing.T) { // This ensures that we try https even for local registries. count := 0 server := httptest.NewTLSServer( - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { count++ w.Write([]byte(`{"token": "dfskdjhfkhsjdhfkjhsdf"}`)) }))