Skip to content

Commit b5961be

Browse files
committed
Fix and/or ignore linting issues
1 parent 319333f commit b5961be

File tree

8 files changed

+40
-37
lines changed

8 files changed

+40
-37
lines changed

ca/bootstrap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func Bootstrap(token string) (*Client, error) {
6161
// }
6262
// resp, err := client.Get("https://internal.smallstep.com")
6363
func BootstrapClient(ctx context.Context, token string, options ...TLSOption) (*http.Client, error) {
64-
b, err := createBootstrap(token)
64+
b, err := createBootstrap(token) //nolint:contextcheck // deeply nested context; temporary
6565
if err != nil {
6666
return nil, err
6767
}
@@ -120,7 +120,7 @@ func BootstrapServer(ctx context.Context, token string, base *http.Server, optio
120120
return nil, errors.New("server TLSConfig is already set")
121121
}
122122

123-
b, err := createBootstrap(token)
123+
b, err := createBootstrap(token) //nolint:contextcheck // deeply nested context; temporary
124124
if err != nil {
125125
return nil, err
126126
}
@@ -169,7 +169,7 @@ func BootstrapServer(ctx context.Context, token string, base *http.Server, optio
169169
// ... // register services
170170
// srv.Serve(lis)
171171
func BootstrapListener(ctx context.Context, token string, inner net.Listener, options ...TLSOption) (net.Listener, error) {
172-
b, err := createBootstrap(token)
172+
b, err := createBootstrap(token) //nolint:contextcheck // deeply nested context; temporary
173173
if err != nil {
174174
return nil, err
175175
}

ca/client.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ retry:
607607
return nil, clientError(err)
608608
}
609609
if resp.StatusCode >= 400 {
610-
if !retried && c.retryOnError(resp) {
610+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
611611
retried = true
612612
goto retry
613613
}
@@ -637,7 +637,7 @@ retry:
637637
return nil, clientError(err)
638638
}
639639
if resp.StatusCode >= 400 {
640-
if !retried && c.retryOnError(resp) {
640+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
641641
retried = true
642642
goto retry
643643
}
@@ -672,7 +672,7 @@ retry:
672672
return nil, clientError(err)
673673
}
674674
if resp.StatusCode >= 400 {
675-
if !retried && c.retryOnError(resp) {
675+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
676676
retried = true
677677
goto retry
678678
}
@@ -711,7 +711,7 @@ retry:
711711
return nil, clientError(err)
712712
}
713713
if resp.StatusCode >= 400 {
714-
if !retried && c.retryOnError(resp) {
714+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
715715
retried = true
716716
goto retry
717717
}
@@ -750,7 +750,7 @@ retry:
750750
return nil, clientError(err)
751751
}
752752
if resp.StatusCode >= 400 {
753-
if !retried && c.retryOnError(resp) {
753+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
754754
retried = true
755755
goto retry
756756
}
@@ -787,7 +787,7 @@ retry:
787787
return nil, clientError(err)
788788
}
789789
if resp.StatusCode >= 400 {
790-
if !retried && c.retryOnError(resp) {
790+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
791791
retried = true
792792
goto retry
793793
}
@@ -827,7 +827,7 @@ retry:
827827
return nil, clientError(err)
828828
}
829829
if resp.StatusCode >= 400 {
830-
if !retried && c.retryOnError(resp) {
830+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
831831
retried = true
832832
goto retry
833833
}
@@ -868,7 +868,7 @@ retry:
868868
return nil, clientError(err)
869869
}
870870
if resp.StatusCode >= 400 {
871-
if !retried && c.retryOnError(resp) {
871+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
872872
retried = true
873873
goto retry
874874
}
@@ -911,7 +911,7 @@ retry:
911911
return nil, clientError(err)
912912
}
913913
if resp.StatusCode >= 400 {
914-
if !retried && c.retryOnError(resp) {
914+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
915915
retried = true
916916
goto retry
917917
}
@@ -943,7 +943,7 @@ retry:
943943
return nil, clientError(err)
944944
}
945945
if resp.StatusCode >= 400 {
946-
if !retried && c.retryOnError(resp) {
946+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
947947
retried = true
948948
goto retry
949949
}
@@ -973,7 +973,7 @@ retry:
973973
return nil, clientError(err)
974974
}
975975
if resp.StatusCode >= 400 {
976-
if !retried && c.retryOnError(resp) {
976+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
977977
retried = true
978978
goto retry
979979
}
@@ -1003,7 +1003,7 @@ retry:
10031003
return nil, clientError(err)
10041004
}
10051005
if resp.StatusCode >= 400 {
1006-
if !retried && c.retryOnError(resp) {
1006+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
10071007
retried = true
10081008
goto retry
10091009
}
@@ -1037,7 +1037,7 @@ retry:
10371037
return nil, clientError(err)
10381038
}
10391039
if resp.StatusCode >= 400 {
1040-
if !retried && c.retryOnError(resp) {
1040+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
10411041
retried = true
10421042
goto retry
10431043
}
@@ -1071,7 +1071,7 @@ retry:
10711071
return nil, clientError(err)
10721072
}
10731073
if resp.StatusCode >= 400 {
1074-
if !retried && c.retryOnError(resp) {
1074+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
10751075
retried = true
10761076
goto retry
10771077
}
@@ -1105,7 +1105,7 @@ retry:
11051105
return nil, clientError(err)
11061106
}
11071107
if resp.StatusCode >= 400 {
1108-
if !retried && c.retryOnError(resp) {
1108+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
11091109
retried = true
11101110
goto retry
11111111
}
@@ -1139,7 +1139,7 @@ retry:
11391139
return nil, clientError(err)
11401140
}
11411141
if resp.StatusCode >= 400 {
1142-
if !retried && c.retryOnError(resp) {
1142+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
11431143
retried = true
11441144
goto retry
11451145
}
@@ -1169,7 +1169,7 @@ retry:
11691169
return nil, clientError(err)
11701170
}
11711171
if resp.StatusCode >= 400 {
1172-
if !retried && c.retryOnError(resp) {
1172+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
11731173
retried = true
11741174
goto retry
11751175
}
@@ -1199,7 +1199,7 @@ retry:
11991199
return nil, clientError(err)
12001200
}
12011201
if resp.StatusCode >= 400 {
1202-
if !retried && c.retryOnError(resp) {
1202+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
12031203
retried = true
12041204
goto retry
12051205
}
@@ -1233,7 +1233,7 @@ retry:
12331233
return nil, clientError(err)
12341234
}
12351235
if resp.StatusCode >= 400 {
1236-
if !retried && c.retryOnError(resp) {
1236+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
12371237
retried = true
12381238
goto retry
12391239
}
@@ -1272,7 +1272,7 @@ retry:
12721272
return nil, clientError(err)
12731273
}
12741274
if resp.StatusCode >= 400 {
1275-
if !retried && c.retryOnError(resp) {
1275+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
12761276
retried = true
12771277
goto retry
12781278
}
@@ -1301,7 +1301,7 @@ retry:
13011301
return nil, clientError(err)
13021302
}
13031303
if resp.StatusCode >= 400 {
1304-
if !retried && c.retryOnError(resp) {
1304+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
13051305
retried = true
13061306
goto retry
13071307
}
@@ -1333,7 +1333,7 @@ retry:
13331333
return nil, clientError(err)
13341334
}
13351335
if resp.StatusCode >= 400 {
1336-
if !retried && c.retryOnError(resp) {
1336+
if !retried && c.retryOnError(resp) { //nolint:contextcheck // deeply nested context; retry using the same context
13371337
retried = true
13381338
goto retry
13391339
}

ca/tls.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (c *Client) getClientTLSConfig(ctx context.Context, sign *api.SignResponse,
135135
//nolint:staticcheck // Use mutable tls.Config on renew
136136
tr.DialTLS = c.buildDialTLS(tlsCtx)
137137
// tr.DialTLSContext = c.buildDialTLSContext(tlsCtx)
138-
renewer.RenewCertificate = getRenewFunc(tlsCtx, c, tr, pk)
138+
renewer.RenewCertificate = getRenewFunc(tlsCtx, c, tr, pk) //nolint:contextcheck // deeply nested context
139139

140140
// Update client transport
141141
c.SetTransport(tr)
@@ -183,7 +183,7 @@ func (c *Client) GetServerTLSConfig(ctx context.Context, sign *api.SignResponse,
183183
//nolint:staticcheck // Use mutable tls.Config on renew
184184
tr.DialTLS = c.buildDialTLS(tlsCtx)
185185
// tr.DialTLSContext = c.buildDialTLSContext(tlsCtx)
186-
renewer.RenewCertificate = getRenewFunc(tlsCtx, c, tr, pk)
186+
renewer.RenewCertificate = getRenewFunc(tlsCtx, c, tr, pk) //nolint:contextcheck // deeply nested context
187187

188188
// Update client transport
189189
c.SetTransport(tr)

cas/stepcas/issuer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package stepcas
22

33
import (
4+
"context"
45
"net/url"
56
"strings"
67
"time"
@@ -37,7 +38,7 @@ type stepIssuer interface {
3738
}
3839

3940
// newStepIssuer returns the configured step issuer.
40-
func newStepIssuer(caURL *url.URL, client *ca.Client, iss *apiv1.CertificateIssuer) (stepIssuer, error) {
41+
func newStepIssuer(ctx context.Context, caURL *url.URL, client *ca.Client, iss *apiv1.CertificateIssuer) (stepIssuer, error) {
4142
if err := validateCertificateIssuer(iss); err != nil {
4243
return nil, err
4344
}
@@ -46,7 +47,7 @@ func newStepIssuer(caURL *url.URL, client *ca.Client, iss *apiv1.CertificateIssu
4647
case "x5c":
4748
return newX5CIssuer(caURL, iss)
4849
case "jwk":
49-
return newJWKIssuer(caURL, client, iss)
50+
return newJWKIssuer(ctx, caURL, client, iss)
5051
default:
5152
return nil, errors.Errorf("stepCAS `certificateIssuer.type` %s is not supported", iss.Type)
5253
}

cas/stepcas/issuer_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package stepcas
22

33
import (
4+
"context"
45
"net/url"
56
"reflect"
67
"testing"
@@ -118,7 +119,7 @@ func Test_newStepIssuer(t *testing.T) {
118119
}
119120
for _, tt := range tests {
120121
t.Run(tt.name, func(t *testing.T) {
121-
got, err := newStepIssuer(tt.args.caURL, tt.args.client, tt.args.iss)
122+
got, err := newStepIssuer(context.TODO(), tt.args.caURL, tt.args.client, tt.args.iss)
122123
if (err != nil) != tt.wantErr {
123124
t.Errorf("newStepIssuer() error = %v, wantErr %v", err, tt.wantErr)
124125
return

cas/stepcas/jwk_issuer.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package stepcas
22

33
import (
4+
"context"
45
"crypto"
56
"encoding/json"
67
"net/url"
@@ -21,13 +22,13 @@ type jwkIssuer struct {
2122
signer jose.Signer
2223
}
2324

24-
func newJWKIssuer(caURL *url.URL, client *ca.Client, cfg *apiv1.CertificateIssuer) (*jwkIssuer, error) {
25+
func newJWKIssuer(ctx context.Context, caURL *url.URL, client *ca.Client, cfg *apiv1.CertificateIssuer) (*jwkIssuer, error) {
2526
var err error
2627
var signer jose.Signer
2728
// Read the key from the CA if not provided.
2829
// Or read it from a PEM file.
2930
if cfg.Key == "" {
30-
p, err := findProvisioner(client, provisioner.TypeJWK, cfg.Provisioner)
31+
p, err := findProvisioner(ctx, client, provisioner.TypeJWK, cfg.Provisioner)
3132
if err != nil {
3233
return nil, err
3334
}
@@ -144,10 +145,10 @@ func newJWKSignerFromEncryptedKey(kid, key, password string) (jose.Signer, error
144145
return newJoseSigner(signer, so)
145146
}
146147

147-
func findProvisioner(client *ca.Client, typ provisioner.Type, name string) (provisioner.Interface, error) {
148+
func findProvisioner(ctx context.Context, client *ca.Client, typ provisioner.Type, name string) (provisioner.Interface, error) {
148149
cursor := ""
149150
for {
150-
ps, err := client.Provisioners(ca.WithProvisionerCursor(cursor))
151+
ps, err := client.ProvisionersWithContext(ctx, ca.WithProvisionerCursor(cursor))
151152
if err != nil {
152153
return nil, err
153154
}

cas/stepcas/stepcas.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func New(ctx context.Context, opts apiv1.Options) (*StepCAS, error) {
4343
}
4444

4545
// Create client.
46-
client, err := ca.NewClient(opts.CertificateAuthority, ca.WithRootSHA256(opts.CertificateAuthorityFingerprint))
46+
client, err := ca.NewClient(opts.CertificateAuthority, ca.WithRootSHA256(opts.CertificateAuthorityFingerprint)) //nolint:contextcheck // deeply nested context
4747
if err != nil {
4848
return nil, err
4949
}
@@ -52,7 +52,7 @@ func New(ctx context.Context, opts apiv1.Options) (*StepCAS, error) {
5252
// Create configured issuer unless we only want to use GetCertificateAuthority.
5353
// This avoid the request for the password if not provided.
5454
if !opts.IsCAGetter {
55-
if iss, err = newStepIssuer(caURL, client, opts.CertificateIssuer); err != nil {
55+
if iss, err = newStepIssuer(ctx, caURL, client, opts.CertificateIssuer); err != nil {
5656
return nil, err
5757
}
5858
}

cas/stepcas/stepcas_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func testJWKIssuer(t *testing.T, caURL *url.URL, password string) *jwkIssuer {
245245
key = testEncryptedKeyPath
246246
password = testPassword
247247
}
248-
jwk, err := newJWKIssuer(caURL, client, &apiv1.CertificateIssuer{
248+
jwk, err := newJWKIssuer(context.TODO(), caURL, client, &apiv1.CertificateIssuer{
249249
Type: "jwk",
250250
Provisioner: "ra@doe.org",
251251
Key: key,

0 commit comments

Comments
 (0)