Skip to content

Commit

Permalink
Merge pull request #663 from fluxcd/tidy-nits
Browse files Browse the repository at this point in the history
Address various nits throughout packages
  • Loading branch information
hiddeco authored Oct 16, 2023
2 parents 807a695 + e56a100 commit 4292046
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 59 deletions.
4 changes: 3 additions & 1 deletion git/gogit/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,14 @@ func TestPush_pushConfig_refspecs(t *testing.T) {
"refs/heads/feature/refspecs:refs/heads/prod/refspecs",
},
})
g.Expect(err).ToNot(HaveOccurred())

err = ggc.Push(context.TODO(), repository.PushConfig{
Refspecs: []string{
"refs/tags/v0.1.0:refs/tags/v0.1.0",
},
})
g.Expect(err).ToNot(HaveOccurred())

repo, err = extgogit.PlainClone(t.TempDir(), false, &extgogit.CloneOptions{
URL: repoURL,
Expand All @@ -321,7 +323,7 @@ func TestPush_pushConfig_refspecs(t *testing.T) {
g.Expect(err).ToNot(HaveOccurred())
g.Expect(tagRef.Hash().String()).To(Equal(head.Hash().String()))

tagRef, err = repo.Reference(plumbing.NewTagReferenceName("v0.2.0"), true)
_, err = repo.Reference(plumbing.NewTagReferenceName("v0.2.0"), true)
g.Expect(err).To(HaveOccurred())
}

Expand Down
5 changes: 3 additions & 2 deletions git/gogit/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ func Test_cloneSubmodule(t *testing.T) {
ShallowClone: true,
RecurseSubmodules: true,
})
g.Expect(err).ToNot(HaveOccurred())

expectedPaths := []string{"base", "base/foo.txt", "bar.txt", "."}
var c int
Expand Down Expand Up @@ -1259,12 +1260,12 @@ func Test_getRemoteHEAD(t *testing.T) {
g.Expect(head).To(Equal(fmt.Sprintf("refs/tags/%s@%s", "v0.1.0"+tagDereferenceSuffix, git.Hash(cc.String()).Digest())))

ref = plumbing.ReferenceName("/refs/heads/main")
head, err = ggc.getRemoteHEAD(context.TODO(), path, ref, nil)
_, err = ggc.getRemoteHEAD(context.TODO(), path, ref, nil)
g.Expect(err).To(HaveOccurred())
g.Expect(err.Error()).To(Equal(fmt.Sprintf("ref %s is invalid; Git refs cannot begin or end with a slash '/'", ref.String())))

ref = plumbing.ReferenceName("refs/heads/main/")
head, err = ggc.getRemoteHEAD(context.TODO(), path, ref, nil)
_, err = ggc.getRemoteHEAD(context.TODO(), path, ref, nil)
g.Expect(err).To(HaveOccurred())
g.Expect(err.Error()).To(Equal(fmt.Sprintf("ref %s is invalid; Git refs cannot begin or end with a slash '/'", ref.String())))
}
Expand Down
1 change: 0 additions & 1 deletion git/gogit/internal/test/socks_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
)

var proxiedRequests int32
var gitServerAddr *url.URL

func Test_SOCKS5_proxy(t *testing.T) {
g := NewWithT(t)
Expand Down
10 changes: 3 additions & 7 deletions git/internal/e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"io"
"io/fs"
"io/ioutil"
"math/rand"
"net/url"
"os"
Expand Down Expand Up @@ -140,10 +139,7 @@ func testUsingInit(g *WithT, client repository.Client, repoURL *url.URL, upstrea

g.Eventually(func() bool {
err = client.Push(context.TODO(), repository.PushConfig{})
if err != nil {
return false
}
return true
return err == nil
}, timeout).Should(BeTrue())

headCommit, _, err := headCommitWithBranch(upstreamRepo.url, "main", upstreamRepo.username, upstreamRepo.password)
Expand Down Expand Up @@ -290,11 +286,11 @@ func initRepo(tmp, repoURL, branch, fixture, username, password string) error {
if d.IsDir() {
return nil
}
input, err := ioutil.ReadFile(path)
input, err := os.ReadFile(path)
if err != nil {
return err
}
err = ioutil.WriteFile(filepath.Join(tmp, d.Name()), input, 0644)
err = os.WriteFile(filepath.Join(tmp, d.Name()), input, 0o600)
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion gittestserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ func (s *GitServer) StopHTTP() {
if s.httpServer != nil {
s.httpServer.Close()
}
return
}

// PublicKeyLookupFunc sets the function to be used for SSH authentication.
Expand Down
4 changes: 3 additions & 1 deletion helmtestserver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.20
replace github.com/fluxcd/pkg/testserver => ../testserver

require (
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c
github.com/fluxcd/pkg/testserver v0.4.0
golang.org/x/crypto v0.12.0
helm.sh/helm/v3 v3.12.3
sigs.k8s.io/yaml v1.3.0
)
Expand All @@ -27,6 +27,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/containerd/containerd v1.7.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -112,6 +113,7 @@ require (
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.starlark.net v0.0.0-20221028183056-acb66ad56dd2 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sync v0.1.0 // indirect
Expand Down
18 changes: 18 additions & 0 deletions helmtestserver/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA4
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
github.com/Microsoft/hcsshim v0.10.0-rc.7 h1:HBytQPxcv8Oy4244zbQbe6hnOnx544eL5QPUqhJldz8=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE=
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs=
github.com/a8m/expect v1.0.0/go.mod h1:4IwSCMumY49ScypDnjNbYEjgVeqy1/U2cEs3Lat96eA=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -89,6 +91,7 @@ github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx2
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd h1:rFt+Y/IK1aEZkEHchZRSq9OQbsSzIT/OrI8YFFmRIng=
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ=
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand All @@ -101,6 +104,8 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
Expand Down Expand Up @@ -666,7 +671,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -705,6 +712,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/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.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -753,6 +761,8 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -852,14 +862,19 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -873,6 +888,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -935,6 +952,7 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
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=
Expand Down
6 changes: 3 additions & 3 deletions helmtestserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"os"
"path/filepath"

"golang.org/x/crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/repo"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -113,15 +113,15 @@ func generateKeyring(privateKeyPath, publicKeyPath string) error {
return err
}
priv, err := os.Create(privateKeyPath)
defer priv.Close()
if err != nil {
return err
}
defer priv.Close()
pub, err := os.Create(publicKeyPath)
defer pub.Close()
if err != nil {
return err
}
defer pub.Close()
if err := entity.SerializePrivate(priv, nil); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions helmtestserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"path/filepath"
"testing"

"golang.org/x/crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp"
"helm.sh/helm/v3/pkg/downloader"
)

Expand All @@ -43,10 +43,10 @@ func TestPackageSignedChartWithVersion(t *testing.T) {
}

out, err := os.Open(publicKeyPath)
defer out.Close()
if err != nil {
t.Fatal(err)
}
defer out.Close()

if _, err = openpgp.ReadKeyRing(out); err != nil {
t.Fatal(err)
Expand Down
8 changes: 4 additions & 4 deletions http/fetch/archive_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ type ArchiveFetcher struct {
hostnameOverwrite string
}

// FileNotFoundError is an error type used to signal 404 HTTP status code responses.
var FileNotFoundError = errors.New("file not found")
// ErrFileNotFound is an error type used to signal 404 HTTP status code responses.
var ErrFileNotFound = errors.New("file not found")

// NewArchiveFetcher configures the retryable http client used for fetching archives.
func NewArchiveFetcher(retries, maxDownloadSize, maxUntarSize int, hostnameOverwrite string) *ArchiveFetcher {
Expand All @@ -65,7 +65,7 @@ func NewArchiveFetcher(retries, maxDownloadSize, maxUntarSize int, hostnameOverw

// Fetch downloads, verifies and extracts the tarball content to the specified directory.
// If the file server responds with 5xx errors, the download operation is retried.
// If the file server responds with 404, the returned error is of type FileNotFoundError.
// If the file server responds with 404, the returned error is of type ErrFileNotFound.
// If the file server is unavailable for more than 3 minutes, the returned error contains the original status code.
func (r *ArchiveFetcher) Fetch(archiveURL, digest, dir string) error {
if r.hostnameOverwrite != "" {
Expand All @@ -90,7 +90,7 @@ func (r *ArchiveFetcher) Fetch(archiveURL, digest, dir string) error {

if code := resp.StatusCode; code != http.StatusOK {
if code == http.StatusNotFound {
return FileNotFoundError
return ErrFileNotFound
}
return fmt.Errorf("failed to download archive from %s (status: %s)", archiveURL, resp.Status)
}
Expand Down
2 changes: 1 addition & 1 deletion http/fetch/archive_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func TestArchiveFetcher_Fetch(t *testing.T) {
maxDownloadSize: -1,
maxUntarSize: -1,
wantErr: true,
wantErrType: FileNotFoundError,
wantErrType: ErrFileNotFound,
},
}

Expand Down
5 changes: 0 additions & 5 deletions oci/client/internal/fs/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import (
"os"
"path/filepath"
"runtime"
"sync"
"testing"
)

var (
mu sync.Mutex
)

func TestMain(m *testing.M) {
symlinks := []struct {
oldPath string
Expand Down
2 changes: 1 addition & 1 deletion oci/client/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c *Client) LoginWithProvider(ctx context.Context, url string, provider oci
case oci.ProviderAzure:
authenticator, err = azure.NewClient().Login(ctx, true, url, ref)
default:
return errors.New(fmt.Sprintf("unsupported provider"))
return errors.New("unsupported provider")
}

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions oci/client/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package client
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
"testing"
Expand Down Expand Up @@ -68,7 +68,7 @@ func Test_Login(t *testing.T) {
transportFunc := mockTransport{
response: &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(strings.NewReader(`{}`)),
Body: io.NopCloser(strings.NewReader(`{}`)),
},
}

Expand Down
4 changes: 2 additions & 2 deletions ssa/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func (e *DryRunErr) Error() string {
return fmt.Sprintf("%s not found: %s", FmtUnstructured(e.involvedObject), e.Unwrap().Error())
}

reason := fmt.Sprintf("%s", apierrors.ReasonForError(e.Unwrap()))
reason := string(apierrors.ReasonForError(e.Unwrap()))

// Detect managed field conflict.
if status, ok := apierrors.StatusCause(e.Unwrap(), metav1.CauseTypeFieldManagerConflict); ok {
reason = fmt.Sprintf("%s", status.Type)
reason = string(status.Type)
}

if reason != "" {
Expand Down
20 changes: 0 additions & 20 deletions ssa/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"testing"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/rest"
"sigs.k8s.io/cli-utils/pkg/kstatus/polling"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -93,21 +92,6 @@ func readManifest(manifest, namespace string) ([]*unstructured.Unstructured, err
return objects, nil
}

func setNamespace(objects []*unstructured.Unstructured, namespace string) {
for _, object := range objects {
object.SetNamespace(namespace)
}

u := &unstructured.Unstructured{}
u.SetGroupVersionKind(schema.GroupVersionKind{
Group: "",
Kind: "Namespace",
Version: "v1",
})
u.SetName(namespace)
objects = append(objects, u)
}

var nextNameId int64

func generateName(prefix string) string {
Expand All @@ -123,7 +107,3 @@ func getFirstObject(objects []*unstructured.Unstructured, kind, name string) (st
}
return "", nil
}

func removeObject(s []*unstructured.Unstructured, index int) []*unstructured.Unstructured {
return append(s[:index], s[index+1:]...)
}
Loading

0 comments on commit 4292046

Please sign in to comment.