Skip to content

Commit eeb7bc4

Browse files
committed
removes flags
1 parent 97227ba commit eeb7bc4

File tree

3 files changed

+6
-55
lines changed

3 files changed

+6
-55
lines changed

docs/command/atlas-auth-login.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ Options
4242
- Type
4343
- Required
4444
- Description
45-
* - --authType
46-
- string
47-
- false
48-
- Authentication type to use. Valid values are 'UserAccount' and 'APIKeys'.
4945
* - --gov
5046
-
5147
- false

internal/cli/auth/login.go

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,15 @@ type LoginOpts struct {
7575
RefreshToken string
7676
IsGov bool
7777
NoBrowser bool
78-
AuthType string
78+
authType string
7979
force bool
8080
SkipConfig bool
8181
config LoginConfig
8282
}
8383

84-
func (opts *LoginOpts) validateAuthTypeFlag() error {
85-
if opts.AuthType != "" && opts.AuthType != userAccountAuth && opts.AuthType != apiKeysAuth {
86-
return fmt.Errorf("the authentication type is invalid: %s", opts.AuthType)
87-
}
88-
return nil
89-
}
90-
9184
func (opts *LoginOpts) promptAuthType() error {
9285
if opts.force {
93-
opts.AuthType = userAccountAuth
86+
opts.authType = userAccountAuth
9487
return nil
9588
}
9689
authTypePrompt := &survey.Select{
@@ -101,24 +94,7 @@ func (opts *LoginOpts) promptAuthType() error {
10194
return authTypeDescription[value]
10295
},
10396
}
104-
return telemetry.TrackAskOne(authTypePrompt, &opts.AuthType)
105-
}
106-
107-
func (opts *LoginOpts) validateAndPrompt() error {
108-
err := opts.validateAuthTypeFlag()
109-
if err != nil {
110-
return err
111-
}
112-
113-
// if opts.AuthType is empty, we prompt the user to select an auth type
114-
if opts.AuthType == "" {
115-
err := opts.promptAuthType()
116-
if err != nil {
117-
return fmt.Errorf("failed to select authentication type: %w", err)
118-
}
119-
}
120-
121-
return nil
97+
return telemetry.TrackAskOne(authTypePrompt, &opts.authType)
12298
}
12399

124100
func (opts *LoginOpts) SetUpAccess() {
@@ -259,11 +235,11 @@ func (opts *LoginOpts) runUserAccountLogin(ctx context.Context) error {
259235
}
260236

261237
func (opts *LoginOpts) LoginRun(ctx context.Context) error {
262-
if err := opts.validateAndPrompt(); err != nil {
263-
return err
238+
if err := opts.promptAuthType(); err != nil {
239+
return fmt.Errorf("failed to select authentication type: %w", err)
264240
}
265241

266-
if opts.AuthType == apiKeysAuth {
242+
if opts.authType == apiKeysAuth {
267243
return opts.runAPIKeysLogin(ctx)
268244
}
269245

@@ -444,14 +420,11 @@ func LoginBuilder() *cobra.Command {
444420
Args: require.NoArgs,
445421
}
446422

447-
cmd.Flags().StringVar(&opts.AuthType, "authType", "", "Authentication type to use. Valid values are 'UserAccount' and 'APIKeys'.")
448423
cmd.Flags().BoolVar(&opts.IsGov, "gov", false, "Log in to Atlas for Government.")
449424
cmd.Flags().BoolVar(&opts.NoBrowser, "noBrowser", false, "Don't try to open a browser session to authenticate your User Account.")
450425
cmd.Flags().BoolVar(&opts.SkipConfig, "skipConfig", false, "Skip profile configuration.")
451426
_ = cmd.Flags().MarkDeprecated("skipConfig", "if you configured a profile, the command skips the config step by default.")
452427
cmd.Flags().BoolVar(&opts.force, flag.Force, false, usage.Force)
453428
_ = cmd.Flags().MarkHidden(flag.Force)
454-
_ = cmd.Flags().MarkHidden(flag.Debug)
455-
456429
return cmd
457430
}

internal/cli/auth/login_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,3 @@ func Test_shouldRetryAuthenticate(t *testing.T) {
195195
})
196196
}
197197
}
198-
199-
// func Test_loginOpts_runAPIKeysLogin (t *testing.T) {
200-
// ctrl := gomock.NewController(t)
201-
// mockConfig := NewMockLoginConfig(ctrl)
202-
// mockFlow := mocks.NewMockRefresher(ctrl)
203-
204-
// opts := &LoginOpts{
205-
// config: mockConfig,
206-
// NoBrowser: true,
207-
// }
208-
// opts.WithFlow(mockFlow)
209-
210-
// ctx := t.Context()
211-
// mockFlow.
212-
// EXPECT().
213-
// RequestCode(ctx).
214-
// Return(nil, nil, errors.New("failed to request code")).
215-
// Times(1)

0 commit comments

Comments
 (0)