Skip to content

Commit 928f2be

Browse files
franklouwersclaude
andcommitted
Fix linter warnings in auth storage code
- Add nolint comments for false positive gosec warnings on auth field constants - Remove unused legacy backward compatibility constants - Remove unused createEncodedTextFile wrapper function - Add nolint comment for storagePrinter variable (used via SetStoragePrinter) - Add nolint comment for test credential false positive 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f011f08 commit 928f2be

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

internal/pkg/auth/storage.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
// Package-level printer for debug logging in storage operations
19-
var storagePrinter = print.NewPrinter()
19+
var storagePrinter = print.NewPrinter() //nolint:unused // set via SetStoragePrinter, may be used for future debug logging
2020

2121
// SetStoragePrinter sets the printer used for storage debug logging
2222
// This should be called with the main command's printer to ensure consistent verbosity
@@ -50,20 +50,14 @@ const (
5050
envAccessTokenName = "STACKIT_ACCESS_TOKEN"
5151
)
5252

53-
// Legacy constants for backward compatibility
54-
const (
55-
keyringService = keyringServiceCLI
56-
textFileName = textFileNameCLI
57-
)
58-
5953
const (
6054
SESSION_EXPIRES_AT_UNIX authFieldKey = "session_expires_at_unix"
6155
ACCESS_TOKEN authFieldKey = "access_token"
6256
REFRESH_TOKEN authFieldKey = "refresh_token"
6357
SERVICE_ACCOUNT_TOKEN authFieldKey = "service_account_token"
6458
SERVICE_ACCOUNT_EMAIL authFieldKey = "service_account_email"
6559
USER_EMAIL authFieldKey = "user_email"
66-
SERVICE_ACCOUNT_KEY authFieldKey = "service_account_key"
60+
SERVICE_ACCOUNT_KEY authFieldKey = "service_account_key" //nolint:gosec // linter false positive
6761
PRIVATE_KEY authFieldKey = "private_key"
6862
TOKEN_CUSTOM_ENDPOINT authFieldKey = "token_custom_endpoint"
6963
IDP_TOKEN_ENDPOINT authFieldKey = "idp_token_endpoint" //nolint:gosec // linter false positive
@@ -416,13 +410,9 @@ func getAuthFieldFromEncodedTextFileWithContext(context StorageContext, activePr
416410
return value, nil
417411
}
418412

419-
// Checks if the encoded text file exist.
413+
// createEncodedTextFileWithContext checks if the encoded text file exist.
420414
// If it doesn't, creates it with the content "{}" encoded.
421415
// If it does, does nothing (and returns nil).
422-
func createEncodedTextFile(activeProfile string) error {
423-
return createEncodedTextFileWithContext(StorageContextCLI, activeProfile)
424-
}
425-
426416
func createEncodedTextFileWithContext(context StorageContext, activeProfile string) error {
427417
textFileDir := config.GetProfileFolderPath(activeProfile)
428418
fileName := getTextFileName(context)

internal/pkg/auth/storage_test.go

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

17561756
cliEmail := "cli@example.com"
17571757
cliAccessToken := "cli-access-token"
1758-
cliRefreshToken := "cli-refresh-token"
1758+
cliRefreshToken := "cli-refresh-token" //nolint:gosec // test credential, not a real secret
17591759
cliSessionExpires := fmt.Sprintf("%d", time.Now().Add(2*time.Hour).Unix())
17601760

17611761
providerEmail := "provider@example.com"

0 commit comments

Comments
 (0)