Skip to content

Commit 7c8dc9b

Browse files
author
Aaron Schlesinger
committed
fix(pkg/gitreceive/storage/auth.go): swap out AnonymousCredentials for an emptyCreds struct
1 parent 0182a46 commit 7c8dc9b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

pkg/gitreceive/storage/auth.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ const (
1616
var (
1717
errMissingKey = fmt.Errorf("missing %s", accessKeyIDFile)
1818
errMissingSecret = fmt.Errorf("missing %s", accessSecretKeyFile)
19-
emptyAuth = credentials.AnonymousCredentials
19+
emptyCreds = creds{}
2020
)
2121

2222
type creds struct {
2323
accessKeyID string
2424
accessKeySecret string
2525
}
2626

27+
func (c *creds) isZero() bool {
28+
return c.accessKeyID == "" && c.accessKeySecret == ""
29+
}
30+
2731
// getAuth gets storage credentials from accessKeyIDFile and accessSecretKeyFile.
2832
// if a key exists but not a secret, or vice-versa, returns an error.
2933
// if both don't exist returns emptyAuth.
@@ -32,7 +36,7 @@ func getAuth(fs sys.FS) (*credentials.Credentials, error) {
3236
accessKeyIDBytes, accessKeyErr := fs.ReadFile(accessKeyIDFile)
3337
accessSecretKeyBytes, accessSecretKeyErr := fs.ReadFile(accessSecretKeyFile)
3438
if accessKeyErr == os.ErrNotExist && accessSecretKeyErr == os.ErrNotExist {
35-
return emptyAuth, nil
39+
return &emptyCreds, nil
3640
}
3741
if accessKeyErr != nil && accessSecretKeyErr == nil {
3842
return nil, errMissingKey

0 commit comments

Comments
 (0)