@@ -3,6 +3,7 @@ package auth
33import (
44 "encoding/base64"
55 "encoding/json"
6+ "errors"
67 "fmt"
78 "os"
89 "path/filepath"
@@ -45,20 +46,18 @@ const (
4546)
4647
4748// Returns all auth field keys managed by the auth storage
48- func getAllAuthFieldKeys () []authFieldKey {
49- return []authFieldKey {
50- SESSION_EXPIRES_AT_UNIX ,
51- ACCESS_TOKEN ,
52- REFRESH_TOKEN ,
53- SERVICE_ACCOUNT_TOKEN ,
54- SERVICE_ACCOUNT_EMAIL ,
55- USER_EMAIL ,
56- SERVICE_ACCOUNT_KEY ,
57- PRIVATE_KEY ,
58- TOKEN_CUSTOM_ENDPOINT ,
59- JWKS_CUSTOM_ENDPOINT ,
60- authFlowType ,
61- }
49+ var authFieldKeys = []authFieldKey {
50+ SESSION_EXPIRES_AT_UNIX ,
51+ ACCESS_TOKEN ,
52+ REFRESH_TOKEN ,
53+ SERVICE_ACCOUNT_TOKEN ,
54+ SERVICE_ACCOUNT_EMAIL ,
55+ USER_EMAIL ,
56+ SERVICE_ACCOUNT_KEY ,
57+ PRIVATE_KEY ,
58+ TOKEN_CUSTOM_ENDPOINT ,
59+ JWKS_CUSTOM_ENDPOINT ,
60+ authFlowType ,
6261}
6362
6463func SetAuthFlow (value AuthFlow ) error {
@@ -273,18 +272,18 @@ func GetProfileEmail(profile string) string {
273272}
274273
275274func DeleteProfileFromKeyring (profile string ) error {
276- allKeys := getAllAuthFieldKeys ()
277-
278275 err := config .ValidateProfile (profile )
279276 if err != nil {
280277 return fmt .Errorf ("validate profile: %w" , err )
281278 }
282279
283- for _ , key := range allKeys {
280+ for _ , key := range authFieldKeys {
284281 err := deleteAuthFieldInKeyring (profile , key )
285282 if err != nil {
286- // If the key doesn't exist, continue
287- continue
283+ // if the key is not found, we can ignore the error
284+ if ! errors .Is (err , keyring .ErrNotFound ) {
285+ return fmt .Errorf ("delete auth field \" %s\" from keyring: %w" , key , err )
286+ }
288287 }
289288 }
290289
0 commit comments