@@ -154,12 +154,12 @@ func LogoutBuilder() *cobra.Command {
154
154
` ,
155
155
PreRunE : func (cmd * cobra.Command , _ []string ) error {
156
156
opts .OutWriter = cmd .OutOrStdout ()
157
- opts .config = config .Default ()
158
-
159
157
// If the profile is set in the context, use it instead of the default profile
160
158
profile , ok := config .ProfileFromContext (cmd .Context ())
161
159
if ok {
162
160
opts .config = profile
161
+ } else {
162
+ opts .config = config .Default ()
163
163
}
164
164
165
165
// Only initialize OAuth flow if we have OAuth-based auth
@@ -173,13 +173,14 @@ func LogoutBuilder() *cobra.Command {
173
173
var message , entry string
174
174
var err error
175
175
176
+ logoutMessage := "Are you sure you want to log out of profile " + opts .config .Name ()
176
177
switch opts .config .AuthType () {
177
178
case config .APIKeys :
178
179
entry = opts .config .PublicAPIKey ()
179
- message = "Are you sure you want to log out of account with public API key %s?"
180
+ message = logoutMessage + " with public API key %s?"
180
181
case config .ServiceAccount :
181
182
entry = opts .config .ClientID ()
182
- message = "Are you sure you want to log out of service account %s?"
183
+ message = logoutMessage + " with service account %s?"
183
184
case config .UserAccount :
184
185
entry , err = opts .config .AccessTokenSubject ()
185
186
if err != nil {
@@ -190,10 +191,10 @@ func LogoutBuilder() *cobra.Command {
190
191
return ErrUnauthenticated
191
192
}
192
193
193
- message = "Are you sure you want to log out of account %s?"
194
+ message = logoutMessage + " with user account %s?"
194
195
case config .NoAuth , "" :
195
196
entry = opts .config .Name ()
196
- message = "Are you sure you want to clear profile %s ?"
197
+ message = logoutMessage + " ?"
197
198
}
198
199
199
200
opts .Entry = entry
0 commit comments