Skip to content

Commit 0f0275e

Browse files
remove trial params as env
1 parent 10ccce1 commit 0f0275e

File tree

4 files changed

+43
-177
lines changed

4 files changed

+43
-177
lines changed

cli/login.go

Lines changed: 21 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,6 @@ func (r *RootCmd) login() *serpent.Command {
149149
password string
150150
trial bool
151151
useTokenForSession bool
152-
153-
firstName string
154-
lastName string
155-
phoneNumber string
156-
jobTitle string
157-
companyName string
158-
country string
159-
developers string
160152
)
161153
cmd := &serpent.Command{
162154
Use: "login [<url>]",
@@ -275,66 +267,59 @@ func (r *RootCmd) login() *serpent.Command {
275267
trial = v == "yes" || v == "y"
276268
}
277269

270+
var trialInfo codersdk.CreateFirstUserTrialInfo
278271
if trial {
279-
if firstName == "" {
280-
firstName, err = promptTrialInfo(inv, "firstName")
272+
if trialInfo.FirstName == "" {
273+
trialInfo.FirstName, err = promptTrialInfo(inv, "firstName")
281274
if err != nil {
282275
return err
283276
}
284277
}
285-
if lastName == "" {
286-
lastName, err = promptTrialInfo(inv, "lastName")
278+
if trialInfo.LastName == "" {
279+
trialInfo.LastName, err = promptTrialInfo(inv, "lastName")
287280
if err != nil {
288281
return err
289282
}
290283
}
291-
if phoneNumber == "" {
292-
phoneNumber, err = promptTrialInfo(inv, "phoneNumber")
284+
if trialInfo.PhoneNumber == "" {
285+
trialInfo.PhoneNumber, err = promptTrialInfo(inv, "phoneNumber")
293286
if err != nil {
294287
return err
295288
}
296289
}
297-
if jobTitle == "" {
298-
jobTitle, err = promptTrialInfo(inv, "jobTitle")
290+
if trialInfo.JobTitle == "" {
291+
trialInfo.JobTitle, err = promptTrialInfo(inv, "jobTitle")
299292
if err != nil {
300293
return err
301294
}
302295
}
303-
if companyName == "" {
304-
companyName, err = promptTrialInfo(inv, "companyName")
296+
if trialInfo.CompanyName == "" {
297+
trialInfo.CompanyName, err = promptTrialInfo(inv, "companyName")
305298
if err != nil {
306299
return err
307300
}
308301
}
309-
if country == "" {
310-
country, err = promptCountry(inv)
302+
if trialInfo.Country == "" {
303+
trialInfo.Country, err = promptCountry(inv)
311304
if err != nil {
312305
return err
313306
}
314307
}
315-
if developers == "" {
316-
developers, err = promptDevelopers(inv)
308+
if trialInfo.Developers == "" {
309+
trialInfo.Developers, err = promptDevelopers(inv)
317310
if err != nil {
318311
return err
319312
}
320313
}
321314
}
322315

323316
_, err = client.CreateFirstUser(ctx, codersdk.CreateFirstUserRequest{
324-
Email: email,
325-
Username: username,
326-
Name: name,
327-
Password: password,
328-
Trial: trial,
329-
TrialInfo: codersdk.CreateFirstUserTrialInfo{
330-
FirstName: firstName,
331-
LastName: lastName,
332-
PhoneNumber: phoneNumber,
333-
JobTitle: jobTitle,
334-
CompanyName: companyName,
335-
Country: country,
336-
Developers: developers,
337-
},
317+
Email: email,
318+
Username: username,
319+
Name: name,
320+
Password: password,
321+
Trial: trial,
322+
TrialInfo: trialInfo,
338323
})
339324
if err != nil {
340325
return xerrors.Errorf("create initial user: %w", err)
@@ -460,48 +445,6 @@ func (r *RootCmd) login() *serpent.Command {
460445
Description: "By default, the CLI will generate a new session token when logging in. This flag will instead use the provided token as the session token.",
461446
Value: serpent.BoolOf(&useTokenForSession),
462447
},
463-
{
464-
Flag: "first-user-first-name",
465-
Env: "CODER_FIRST_USER_FIRST_NAME",
466-
Description: "Specifies the first name of the user.",
467-
Value: serpent.StringOf(&firstName),
468-
},
469-
{
470-
Flag: "first-user-last-name",
471-
Env: "CODER_FIRST_USER_LAST_NAME",
472-
Description: "Specifies the last name of the user.",
473-
Value: serpent.StringOf(&lastName),
474-
},
475-
{
476-
Flag: "first-user-phone-number",
477-
Env: "CODER_FIRST_USER_PHONE_NUMBER",
478-
Description: "Specifies the phone number of the user.",
479-
Value: serpent.StringOf(&phoneNumber),
480-
},
481-
{
482-
Flag: "first-user-job-title",
483-
Env: "CODER_FIRST_USER_JOB_TITLE",
484-
Description: "Specifies the job title of the user.",
485-
Value: serpent.StringOf(&jobTitle),
486-
},
487-
{
488-
Flag: "first-user-company-name",
489-
Env: "CODER_FIRST_USER_COMPANY_NAME",
490-
Description: "Specifies the company name of the user.",
491-
Value: serpent.StringOf(&companyName),
492-
},
493-
{
494-
Flag: "first-user-country",
495-
Env: "CODER_FIRST_USER_COUNTRY",
496-
Description: "Specifies the country of the user.",
497-
Value: serpent.StringOf(&country),
498-
},
499-
{
500-
Flag: "first-user-developers",
501-
Env: "CODER_FIRST_USER_DEVELOPERS",
502-
Description: "Specifies the number of developers.",
503-
Value: serpent.StringOf(&developers),
504-
},
505448
}
506449
return cmd
507450
}

cli/login_test.go

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,20 @@ func TestLogin(t *testing.T) {
281281
"--first-user-email", coderdtest.FirstUserParams.Email,
282282
"--first-user-password", coderdtest.FirstUserParams.Password,
283283
"--first-user-trial",
284-
"--first-user-first-name", coderdtest.TrialUserParams.FirstName,
285-
"--first-user-last-name", coderdtest.TrialUserParams.LastName,
286-
"--first-user-phone-number", coderdtest.TrialUserParams.PhoneNumber,
287-
"--first-user-job-title", coderdtest.TrialUserParams.JobTitle,
288-
"--first-user-company-name", coderdtest.TrialUserParams.CompanyName,
289-
"--first-user-country", coderdtest.TrialUserParams.Country,
290-
"--first-user-developers", coderdtest.TrialUserParams.Developers,
291284
)
292285
pty := ptytest.New(t).Attach(inv)
293286
w := clitest.StartWithWaiter(t, inv)
287+
pty.ExpectMatch("firstName")
288+
pty.WriteLine(coderdtest.TrialUserParams.FirstName)
289+
pty.ExpectMatch("lastName")
290+
pty.WriteLine(coderdtest.TrialUserParams.LastName)
291+
pty.ExpectMatch("phoneNumber")
292+
pty.WriteLine(coderdtest.TrialUserParams.PhoneNumber)
293+
pty.ExpectMatch("jobTitle")
294+
pty.WriteLine(coderdtest.TrialUserParams.JobTitle)
295+
pty.ExpectMatch("companyName")
296+
pty.WriteLine(coderdtest.TrialUserParams.CompanyName)
297+
// `developers` and `country` `cliui.Select` automatically selects the first option during tests.
294298
pty.ExpectMatch("Welcome to Coder")
295299
w.RequireSuccess()
296300
ctx := testutil.Context(t, testutil.WaitShort)
@@ -316,17 +320,20 @@ func TestLogin(t *testing.T) {
316320
"--first-user-email", coderdtest.FirstUserParams.Email,
317321
"--first-user-password", coderdtest.FirstUserParams.Password,
318322
"--first-user-trial",
319-
"--first-user-first-name", coderdtest.TrialUserParams.FirstName,
320-
"--first-user-last-name", coderdtest.TrialUserParams.LastName,
321-
"--first-user-phone-number", coderdtest.TrialUserParams.PhoneNumber,
322-
"--first-user-job-title", coderdtest.TrialUserParams.JobTitle,
323-
"--first-user-company-name", coderdtest.TrialUserParams.CompanyName,
324-
"--first-user-country", coderdtest.TrialUserParams.Country,
325-
"--first-user-developers", coderdtest.TrialUserParams.Developers,
326-
// `developers` and `country` `cliui.Select` automatically selects the first option during tests.
327323
)
328324
pty := ptytest.New(t).Attach(inv)
329325
w := clitest.StartWithWaiter(t, inv)
326+
pty.ExpectMatch("firstName")
327+
pty.WriteLine(coderdtest.TrialUserParams.FirstName)
328+
pty.ExpectMatch("lastName")
329+
pty.WriteLine(coderdtest.TrialUserParams.LastName)
330+
pty.ExpectMatch("phoneNumber")
331+
pty.WriteLine(coderdtest.TrialUserParams.PhoneNumber)
332+
pty.ExpectMatch("jobTitle")
333+
pty.WriteLine(coderdtest.TrialUserParams.JobTitle)
334+
pty.ExpectMatch("companyName")
335+
pty.WriteLine(coderdtest.TrialUserParams.CompanyName)
336+
// `developers` and `country` `cliui.Select` automatically selects the first option during tests.
330337
pty.ExpectMatch("Welcome to Coder")
331338
w.RequireSuccess()
332339
ctx := testutil.Context(t, testutil.WaitShort)

cli/testdata/coder_login_--help.golden

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,17 @@ USAGE:
66
Authenticate with Coder deployment
77

88
OPTIONS:
9-
--first-user-company-name string, $CODER_FIRST_USER_COMPANY_NAME
10-
Specifies the company name of the user.
11-
12-
--first-user-country string, $CODER_FIRST_USER_COUNTRY
13-
Specifies the country of the user.
14-
15-
--first-user-developers string, $CODER_FIRST_USER_DEVELOPERS
16-
Specifies the number of developers.
17-
189
--first-user-email string, $CODER_FIRST_USER_EMAIL
1910
Specifies an email address to use if creating the first user for the
2011
deployment.
2112

22-
--first-user-first-name string, $CODER_FIRST_USER_FIRST_NAME
23-
Specifies the first name of the user.
24-
2513
--first-user-full-name string, $CODER_FIRST_USER_FULL_NAME
2614
Specifies a human-readable name for the first user of the deployment.
2715

28-
--first-user-job-title string, $CODER_FIRST_USER_JOB_TITLE
29-
Specifies the job title of the user.
30-
31-
--first-user-last-name string, $CODER_FIRST_USER_LAST_NAME
32-
Specifies the last name of the user.
33-
3416
--first-user-password string, $CODER_FIRST_USER_PASSWORD
3517
Specifies a password to use if creating the first user for the
3618
deployment.
3719

38-
--first-user-phone-number string, $CODER_FIRST_USER_PHONE_NUMBER
39-
Specifies the phone number of the user.
40-
4120
--first-user-trial bool, $CODER_FIRST_USER_TRIAL
4221
Specifies whether a trial license should be provisioned for the Coder
4322
deployment or not.

docs/reference/cli/login.md

Lines changed: 0 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy