Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
with:
go-version-file: go.mod
- name: Run golangci-lint
uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 # v6.5.0
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
with:
version: v1.54
args: --timeout 10m --exclude SA5011 --verbose --issues-exit-code=0
version: v2.0.2
args: --timeout 10m --verbose --issues-exit-code=0
only-new-issues: true

govulncheck:
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
cache-to: type=gha,mode=max

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.29.0
uses: aquasecurity/trivy-action@0.30.0
with:
image-ref: "quay.io/jetstack/version-checker:${{github.sha}}"
format: "table"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage-badge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
go tool cover -func=coverage.out -o=coverage.out

- name: Go Coverage Badge # Pass the `coverage.out` output to this action
uses: tj-actions/coverage-badge-go@v2
uses: tj-actions/coverage-badge-go@v3
with:
filename: coverage.out

Expand Down
4 changes: 2 additions & 2 deletions cmd/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ func (o *Options) addFlags(cmd *cobra.Command) {

usageFmt := "Usage:\n %s\n"
cmd.SetUsageFunc(func(cmd *cobra.Command) error {
fmt.Fprintf(cmd.OutOrStderr(), usageFmt, cmd.UseLine())
_, _ = fmt.Fprintf(cmd.OutOrStderr(), usageFmt, cmd.UseLine())
cliflag.PrintSections(cmd.OutOrStderr(), nfs, 0)
return nil
})

cmd.SetHelpFunc(func(cmd *cobra.Command, _ []string) {
fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n"+usageFmt, cmd.Long, cmd.UseLine())
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n"+usageFmt, cmd.Long, cmd.UseLine())
cliflag.PrintSections(cmd.OutOrStdout(), nfs, 0)
})

Expand Down
4 changes: 0 additions & 4 deletions cmd/app/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@ func TestComplete(t *testing.T) {
t.Errorf("unexpected client options, exp=%#+v got=%#+v",
test.expOptions, o.Client)
}

for _, env := range test.envs {
os.Unsetenv(env[0])
}
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/acr/acr.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (c *Client) Tags(ctx context.Context, host, repo, image string) ([]api.Imag
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

var manifestResp ManifestResponse
if err := json.NewDecoder(resp.Body).Decode(&manifestResp); err != nil {
Expand Down Expand Up @@ -212,7 +212,7 @@ func (c *Client) getAccessTokenClient(ctx context.Context, host string) (*acrCli
return nil, fmt.Errorf("%s: failed to request access token: %s",
host, err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

var respToken AccessTokenResponse
if err := json.NewDecoder(resp.Body).Decode(&respToken); err != nil {
Expand Down
14 changes: 8 additions & 6 deletions pkg/client/acr/path_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package acr

import "testing"
import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestIsHost(t *testing.T) {
tests := map[string]struct {
Expand Down Expand Up @@ -85,11 +89,9 @@ func TestRepoImage(t *testing.T) {
handler := new(Client)
for name, test := range tests {
t.Run(name, func(t *testing.T) {
if repo, image := handler.RepoImageFromPath(test.path); !(repo == test.expRepo &&
image == test.expImage) {
t.Errorf("%s: unexpected repo/image, exp=%s,%s got=%s,%s",
test.path, test.expRepo, test.expImage, repo, image)
}
repo, image := handler.RepoImageFromPath(test.path)
assert.Equal(t, repo, test.expRepo)
assert.Equal(t, image, test.expImage)
})
}
}
4 changes: 2 additions & 2 deletions pkg/client/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (c *Client) doRequest(ctx context.Context, url string) (*TagResponse, error
if err != nil {
return nil, fmt.Errorf("failed to get %q image: %s", c.Name(), err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down Expand Up @@ -165,7 +165,7 @@ func basicAuthSetup(ctx context.Context, client *http.Client, opts Options) (str
if err != nil {
return "", err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/ecr/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ func (c *Client) createClient(ctx context.Context, region string) (*ecr.Client,
if c.IamRoleArn != "" {
cfg, err = config.LoadDefaultConfig(ctx,
config.WithRegion(region),
config.WithHTTPClient(&http.Client{Transport: c.Options.Transporter}),
config.WithHTTPClient(&http.Client{Transport: c.Transporter}),
)
} else {
cfg, err = config.LoadDefaultConfig(ctx,
config.WithCredentialsProvider(
credentials.NewStaticCredentialsProvider(c.AccessKeyID, c.SecretAccessKey, c.SessionToken),
),
config.WithRegion(region),
config.WithHTTPClient(&http.Client{Transport: c.Options.Transporter}),
config.WithHTTPClient(&http.Client{Transport: c.Transporter}),
)
}
if err != nil {
Expand Down
14 changes: 8 additions & 6 deletions pkg/client/ecr/path_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package ecr

import "testing"
import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestIsHost(t *testing.T) {
tests := map[string]struct {
Expand Down Expand Up @@ -98,11 +102,9 @@ func TestRepoImage(t *testing.T) {
handler := new(Client)
for name, test := range tests {
t.Run(name, func(t *testing.T) {
if repo, image := handler.RepoImageFromPath(test.path); !(repo == test.expRepo &&
image == test.expImage) {
t.Errorf("%s: unexpected repo/image, exp=%s,%s got=%s,%s",
test.path, test.expRepo, test.expImage, repo, image)
}
repo, image := handler.RepoImageFromPath(test.path)
assert.Equal(t, repo, test.expRepo)
assert.Equal(t, image, test.expImage)
})
}
}
2 changes: 1 addition & 1 deletion pkg/client/gcr/gcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *Client) Tags(ctx context.Context, host, repo, image string) ([]api.Imag
if err != nil {
return nil, fmt.Errorf("failed to get %q image: %w", c.Name(), err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/ghcr/ghcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (c *Client) Tags(ctx context.Context, _, owner, repo string) ([]api.ImageTa
break
}

opts.ListOptions.Page = resp.NextPage
opts.Page = resp.NextPage
}

return tags, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/quay/quay.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (c *Client) makeRequest(ctx context.Context, url string, obj interface{}) e
if err != nil {
return fmt.Errorf("failed to make quay call %q: %s", url, err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if err := json.NewDecoder(resp.Body).Decode(obj); err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions pkg/client/selfhosted/selfhosted.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ func (c *Client) doRequest(ctx context.Context, url, header string, obj interfac
if err != nil {
return nil, fmt.Errorf("failed to get %q image: %s", c.Name(), err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
return nil, selfhostederrors.NewHTTPError(resp.StatusCode, body)
Expand Down Expand Up @@ -279,7 +279,7 @@ func (c *Client) setupBasicAuth(ctx context.Context, url, tokenPath string) (str
return "", fmt.Errorf("failed to send basic auth request %q: %s",
req.URL, err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/selfhosted/selfhosted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestName(t *testing.T) {

assert.Equal(t, "testhost", client.Name())

client.Options.Host = ""
client.Host = ""
assert.Equal(t, "selfhosted", client.Name())
}

Expand Down Expand Up @@ -322,7 +322,7 @@ func TestNewTLSConfig(t *testing.T) {
t.Run("successful TLS config creation with valid CA path", func(t *testing.T) {
caFile, err := os.CreateTemp("", "ca.pem")
assert.NoError(t, err)
defer os.Remove(caFile.Name())
defer func() { assert.NoError(t, os.Remove(caFile.Name())) }()

_, err = caFile.WriteString(`-----BEGIN CERTIFICATE-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwf3Kq/BnEePvM6rSGPP6
Expand Down
2 changes: 1 addition & 1 deletion pkg/metrics/roundtripper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func TestRoundTripper(t *testing.T) {
require.NoError(t, err)

resp, err := client.Do(req)
defer func() { _ = resp.Body.Close() }()

if tt.expectedError {
assert.Error(t, err)
Expand All @@ -185,7 +186,6 @@ func TestRoundTripper(t *testing.T) {
assert.NotNil(t, resp)
assert.Equal(t, tt.expectedStatus, resp.StatusCode)
}
resp.Body.Close()

// Validate metrics
assert.NoError(t,
Expand Down
Loading