Skip to content

Commit 39df9f9

Browse files
authored
Run go fix on codebase (#2299)
Just some stylistic cleanup. Signed-off-by: Hayden <8418760+Hayden-IO@users.noreply.github.com>
1 parent b0b3140 commit 39df9f9

File tree

26 files changed

+145
-149
lines changed

26 files changed

+145
-149
lines changed

cmd/app/grpc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type grpcServer struct {
6262
}
6363

6464
func PassFulcioConfigThruContext(cfg *config.FulcioConfig) grpc.UnaryServerInterceptor {
65-
return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
65+
return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
6666
// For each request, infuse context with our snapshot of the FulcioConfig.
6767
// TODO(mattmoor): Consider periodically (every minute?) refreshing the ConfigMap
6868
// from disk, so that we don't need to cycle pods to pick up config updates.
@@ -292,7 +292,7 @@ func createLegacyGRPCServer(cfg *config.FulcioConfig, unixDomainSocket string, v
292292
return &grpcServer{myServer, unixDomainSocket, v2Server, nil}, nil
293293
}
294294

295-
func panicRecoveryHandler(ctx context.Context, p interface{}) error {
295+
func panicRecoveryHandler(ctx context.Context, p any) error {
296296
log.ContextLogger(ctx).Error(p)
297297
return fmt.Errorf("panic: %v", p)
298298
}

cmd/app/serve.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"os"
2929
"os/signal"
3030
"path/filepath"
31+
"slices"
3132
"strings"
3233
"sync"
3334
"syscall"
@@ -157,7 +158,7 @@ type logAdaptor struct {
157158
logger *zap.SugaredLogger
158159
}
159160

160-
func (la logAdaptor) Printf(s string, args ...interface{}) {
161+
func (la logAdaptor) Printf(s string, args ...any) {
161162
la.logger.Infof(s, args...)
162163
}
163164

@@ -431,11 +432,8 @@ func checkServeCmdConfigFile() error {
431432
extWithDot := filepath.Ext(abspath)
432433
ext := strings.TrimPrefix(extWithDot, ".")
433434
var extIsValid bool
434-
for _, validExt := range viper.SupportedExts {
435-
if ext == validExt {
436-
extIsValid = true
437-
break
438-
}
435+
if slices.Contains(viper.SupportedExts, ext) {
436+
extIsValid = true
439437
}
440438
if !extIsValid {
441439
return fmt.Errorf("config file must have one of the following extensions: %s", strings.Join(viper.SupportedExts, ", "))

pkg/ca/common.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"crypto"
2121
"crypto/x509"
2222
"errors"
23+
"slices"
2324
"time"
2425

2526
"github.com/sigstore/fulcio/pkg/identity"
@@ -89,11 +90,8 @@ func VerifyCertChain(certs []*x509.Certificate, signer crypto.Signer) error {
8990
// usage is set to satify extended key usage chainging
9091
if len(certs) > 1 {
9192
var hasExtKeyUsageCodeSigning bool
92-
for _, extKeyUsage := range certs[0].ExtKeyUsage {
93-
if extKeyUsage == x509.ExtKeyUsageCodeSigning {
94-
hasExtKeyUsageCodeSigning = true
95-
break
96-
}
93+
if slices.Contains(certs[0].ExtKeyUsage, x509.ExtKeyUsageCodeSigning) {
94+
hasExtKeyUsageCodeSigning = true
9795
}
9896
if !hasExtKeyUsageCodeSigning {
9997
return errors.New(`certificate must have extended key usage code signing set to sign code signing certificates`)

pkg/certmaker/template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var intermediateTemplate string
4040
//go:embed templates/leaf-template.json
4141
var leafTemplate string
4242

43-
func ParseTemplate(input interface{}, parent *x509.Certificate, notAfter time.Time, publicKey crypto.PublicKey, commonName string) (*x509.Certificate, error) {
43+
func ParseTemplate(input any, parent *x509.Certificate, notAfter time.Time, publicKey crypto.PublicKey, commonName string) (*x509.Certificate, error) {
4444
var content string
4545

4646
switch v := input.(type) {

pkg/certmaker/template_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func TestParseTemplate(t *testing.T) {
102102

103103
for _, tt := range tests {
104104
t.Run(tt.name, func(t *testing.T) {
105-
var content interface{}
105+
var content any
106106
if tt.filename == "nonexistent.json" {
107107
content = struct{}{} // Use invalid type to trigger type error
108108
} else {

pkg/config/config_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,8 @@ func TestVerifierCacheWithCustomCA(t *testing.T) {
891891
})
892892
case "/keys":
893893
w.Header().Set("Content-Type", "application/json")
894-
json.NewEncoder(w).Encode(map[string]interface{}{
895-
"keys": []interface{}{},
894+
json.NewEncoder(w).Encode(map[string]any{
895+
"keys": []any{},
896896
})
897897
default:
898898
http.NotFound(w, r)
@@ -988,8 +988,8 @@ func TestVerifyK8sDefaultIssuer(t *testing.T) {
988988
})
989989
case "/keys":
990990
w.Header().Set("Content-Type", "application/json")
991-
json.NewEncoder(w).Encode(map[string]interface{}{
992-
"keys": []interface{}{},
991+
json.NewEncoder(w).Encode(map[string]any{
992+
"keys": []any{},
993993
})
994994
default:
995995
http.NotFound(w, r)

pkg/ctl/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestBuildCTChain(t *testing.T) {
3737
t.Fatalf("CT chain length does not equal certificate chain length, got %v, expected %v", len(ctChain), len(certs))
3838
}
3939

40-
for i := 0; i < len(certs); i++ {
40+
for i := range certs {
4141
if !reflect.DeepEqual(ctChain[i].Data, certs[i].Raw) {
4242
t.Fatal("CT certificate and certificate do not match")
4343
}

pkg/identity/buildkite/issuer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestIssuer(t *testing.T) {
4444
Issuer: "https://iss.example.com",
4545
Subject: "organization:acme-inc:pipeline:bash-example:ref:refs/heads/main:commit:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:step:build",
4646
}
47-
claims, err := json.Marshal(map[string]interface{}{
47+
claims, err := json.Marshal(map[string]any{
4848
"aud": "sigstore",
4949
"exp": 0,
5050
"iss": "https://agent.buildkite.com",

pkg/identity/buildkite/principal_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ import (
3333

3434
func TestJobPrincipalFromIDToken(t *testing.T) {
3535
tests := map[string]struct {
36-
Claims map[string]interface{}
36+
Claims map[string]any
3737
ExpectPrincipal jobPrincipal
3838
WantErr bool
3939
ErrContains string
4040
}{
4141
`Valid token authenticates with correct claims`: {
42-
Claims: map[string]interface{}{
42+
Claims: map[string]any{
4343
"aud": "sigstore",
4444
"exp": 0,
4545
"iss": "https://agent.buildkite.com",
@@ -55,7 +55,7 @@ func TestJobPrincipalFromIDToken(t *testing.T) {
5555
WantErr: false,
5656
},
5757
`Token missing organization_slug claim should be rejected`: {
58-
Claims: map[string]interface{}{
58+
Claims: map[string]any{
5959
"aud": "sigstore",
6060
"exp": 0,
6161
"iss": "https://agent.buildkite.com",
@@ -66,7 +66,7 @@ func TestJobPrincipalFromIDToken(t *testing.T) {
6666
ErrContains: "organization_slug",
6767
},
6868
`Token missing pipeline_slug claim should be rejected`: {
69-
Claims: map[string]interface{}{
69+
Claims: map[string]any{
7070
"aud": "sigstore",
7171
"exp": 0,
7272
"iss": "https://agent.buildkite.com",
@@ -127,11 +127,11 @@ func withClaims(token *oidc.IDToken, data []byte) {
127127

128128
func TestName(t *testing.T) {
129129
tests := map[string]struct {
130-
Claims map[string]interface{}
130+
Claims map[string]any
131131
ExpectName string
132132
}{
133133
`Valid token authenticates with correct claims`: {
134-
Claims: map[string]interface{}{
134+
Claims: map[string]any{
135135
"aud": "sigstore",
136136
"exp": 0,
137137
"iss": "https://agent.buildkite.com",

pkg/identity/chainguard/issuer_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestIssuer(t *testing.T) {
5151
Issuer: "https://iss.example.com",
5252
Subject: id.String(),
5353
}
54-
claims, err := json.Marshal(map[string]interface{}{
54+
claims, err := json.Marshal(map[string]any{
5555
"iss": "https://iss.example.com",
5656
"sub": id.String(),
5757

@@ -63,7 +63,7 @@ func TestIssuer(t *testing.T) {
6363
"sub": fmt.Sprintf("catalog-syncer:%s", group.String()),
6464
"aud": "chainguard",
6565
},
66-
"internal": map[string]interface{}{
66+
"internal": map[string]any{
6767
"service-principal": "CATALOG_SYNCER",
6868
},
6969
})

0 commit comments

Comments
 (0)