Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaf7cf3b

Browse files
committed
remove trial params as env
1 parent10ccce1 commitaf7cf3b

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
passwordstring
150150
trialbool
151151
useTokenForSessionbool
152-
153-
firstNamestring
154-
lastNamestring
155-
phoneNumberstring
156-
jobTitlestring
157-
companyNamestring
158-
countrystring
159-
developersstring
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+
vartrialInfo codersdk.CreateFirstUserTrialInfo
278271
iftrial {
279-
iffirstName=="" {
280-
firstName,err=promptTrialInfo(inv,"firstName")
272+
iftrialInfo.FirstName=="" {
273+
trialInfo.FirstName,err=promptTrialInfo(inv,"firstName")
281274
iferr!=nil {
282275
returnerr
283276
}
284277
}
285-
iflastName=="" {
286-
lastName,err=promptTrialInfo(inv,"lastName")
278+
iftrialInfo.LastName=="" {
279+
trialInfo.LastName,err=promptTrialInfo(inv,"lastName")
287280
iferr!=nil {
288281
returnerr
289282
}
290283
}
291-
ifphoneNumber=="" {
292-
phoneNumber,err=promptTrialInfo(inv,"phoneNumber")
284+
iftrialInfo.PhoneNumber=="" {
285+
trialInfo.PhoneNumber,err=promptTrialInfo(inv,"phoneNumber")
293286
iferr!=nil {
294287
returnerr
295288
}
296289
}
297-
ifjobTitle=="" {
298-
jobTitle,err=promptTrialInfo(inv,"jobTitle")
290+
iftrialInfo.JobTitle=="" {
291+
trialInfo.JobTitle,err=promptTrialInfo(inv,"jobTitle")
299292
iferr!=nil {
300293
returnerr
301294
}
302295
}
303-
ifcompanyName=="" {
304-
companyName,err=promptTrialInfo(inv,"companyName")
296+
iftrialInfo.CompanyName=="" {
297+
trialInfo.CompanyName,err=promptTrialInfo(inv,"companyName")
305298
iferr!=nil {
306299
returnerr
307300
}
308301
}
309-
ifcountry=="" {
310-
country,err=promptCountry(inv)
302+
iftrialInfo.Country=="" {
303+
trialInfo.Country,err=promptCountry(inv)
311304
iferr!=nil {
312305
returnerr
313306
}
314307
}
315-
ifdevelopers=="" {
316-
developers,err=promptDevelopers(inv)
308+
iftrialInfo.Developers=="" {
309+
trialInfo.Developers,err=promptDevelopers(inv)
317310
iferr!=nil {
318311
returnerr
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
iferr!=nil {
340325
returnxerrors.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
returncmd
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 aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp