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

Commitf9eca5a

Browse files
committed
feat: add additional fields to first time setup trial flow
1 parentf9f94b5 commitf9eca5a

File tree

21 files changed

+1336
-33
lines changed

21 files changed

+1336
-33
lines changed

‎.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ provisionersdk/proto/*.go linguist-generated=true
1212
*.tfstate.dotlinguist-generated=true
1313
*.tfplan.dotlinguist-generated=true
1414
site/src/api/typesGenerated.tslinguist-generated=true
15+
site/src/pages/SetupPage/countries.tsxlinguist-generated=true

‎.github/workflows/typos.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ darcula = "darcula"
1414
Hashi ="Hashi"
1515
trialer ="trialer"
1616
encrypter ="encrypter"
17-
hel ="hel"# as in helsinki
17+
hel ="hel"# as in helsinki
1818

1919
[files]
2020
extend-exclude = [
@@ -31,4 +31,5 @@ extend-exclude = [
3131
"**/*.test.tsx",
3232
"**/pnpm-lock.yaml",
3333
"tailnet/testdata/**",
34+
"site/src/pages/SetupPage/countries.tsx",
3435
]

‎coderd/apidoc/docs.go

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

‎coderd/apidoc/swagger.json

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

‎coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ type Options struct {
123123
TracerProvider trace.TracerProvider
124124
ExternalAuthConfigs []*externalauth.Config
125125
RealIPConfig*httpmw.RealIPConfig
126-
TrialGeneratorfunc(ctx context.Context,emailstring)error
126+
TrialGeneratorfunc(ctx context.Context,body codersdk.LicensorTrialRequest)error
127127
// TLSCertificates is used to mesh DERP servers securely.
128128
TLSCertificates []tls.Certificate
129129
TailnetCoordinator tailnet.Coordinator

‎coderd/coderdtest/coderdtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ type Options struct {
107107
Auditor audit.Auditor
108108
TLSCertificates []tls.Certificate
109109
ExternalAuthConfigs []*externalauth.Config
110-
TrialGeneratorfunc(context.Context,string)error
110+
TrialGeneratorfunc(ctxcontext.Context,body codersdk.LicensorTrialRequest)error
111111
TemplateScheduleStore schedule.TemplateScheduleStore
112112
Coordinator tailnet.Coordinator
113113

‎coderd/externalauth/externalauth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func (c *DeviceAuth) AuthorizeDevice(ctx context.Context) (*codersdk.ExternalAut
325325
// return a better error.
326326
switchresp.StatusCode {
327327
casehttp.StatusTooManyRequests:
328-
returnnil,fmt.Errorf("rate limit hit, unable to authorize device. please try again later")
328+
returnnil,xerrors.New("rate limit hit, unable to authorize device. please try again later")
329329
default:
330330
returnnil,err
331331
}

‎coderd/httpapi/websocket.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"context"
55
"time"
66

7-
"cdr.dev/slog"
87
"nhooyr.io/websocket"
8+
9+
"cdr.dev/slog"
910
)
1011

1112
// Heartbeat loops to ping a WebSocket to keep it alive.

‎coderd/promoauth/github.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package promoauth
22

33
import (
4-
"fmt"
54
"net/http"
65
"strconv"
76
"time"
7+
8+
"golang.org/x/xerrors"
89
)
910

1011
typerateLimitsstruct {
@@ -81,7 +82,7 @@ func (p *headerParser) string(key string) string {
8182

8283
v:=p.header.Get(key)
8384
ifv=="" {
84-
p.errors[key]=fmt.Errorf("missing header %q",key)
85+
p.errors[key]=xerrors.Errorf("missing header %q",key)
8586
}
8687
returnv
8788
}

‎coderd/users.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,16 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) {
152152
}
153153

154154
ifcreateUser.Trial&&api.TrialGenerator!=nil {
155-
err=api.TrialGenerator(ctx,createUser.Email)
155+
err=api.TrialGenerator(ctx, codersdk.LicensorTrialRequest{
156+
Email:createUser.Email,
157+
FirstName:createUser.TrialInfo.FirstName,
158+
LastName:createUser.TrialInfo.LastName,
159+
PhoneNumber:createUser.TrialInfo.PhoneNumber,
160+
JobTitle:createUser.TrialInfo.JobTitle,
161+
CompanyName:createUser.TrialInfo.CompanyName,
162+
Country:createUser.TrialInfo.CompanyName,
163+
Developers:createUser.TrialInfo.Developers,
164+
})
156165
iferr!=nil {
157166
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
158167
Message:"Failed to generate trial",

‎coderd/users_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestFirstUser(t *testing.T) {
7676
t.Parallel()
7777
called:=make(chanstruct{})
7878
client:=coderdtest.New(t,&coderdtest.Options{
79-
TrialGenerator:func(ctxcontext.Context,sstring)error {
79+
TrialGenerator:func(context.Context,codersdk.LicensorTrialRequest)error {
8080
close(called)
8181
returnnil
8282
},

‎codersdk/users.go

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,38 @@ type GetUsersResponse struct {
6363
Countint`json:"count"`
6464
}
6565

66+
// @typescript-ignore LicensorTrialRequest
67+
typeLicensorTrialRequeststruct {
68+
DeploymentIDstring`json:"deployment_id"`
69+
Emailstring`json:"email"`
70+
Sourcestring`json:"source"`
71+
72+
// Personal details.
73+
FirstNamestring`json:"first_name"`
74+
LastNamestring`json:"last_name"`
75+
PhoneNumberstring`json:"phone_number"`
76+
JobTitlestring`json:"job_title"`
77+
CompanyNamestring`json:"company_name"`
78+
Countrystring`json:"country"`
79+
Developersstring`json:"developers"`
80+
}
81+
6682
typeCreateFirstUserRequeststruct {
67-
Emailstring`json:"email" validate:"required,email"`
68-
Usernamestring`json:"username" validate:"required,username"`
69-
Passwordstring`json:"password" validate:"required"`
70-
Trialbool`json:"trial"`
83+
Emailstring`json:"email" validate:"required,email"`
84+
Usernamestring`json:"username" validate:"required,username"`
85+
Passwordstring`json:"password" validate:"required"`
86+
Trialbool`json:"trial"`
87+
TrialInfoCreateFirstUserTrialInfo`json:"trial_info"`
88+
}
89+
90+
typeCreateFirstUserTrialInfostruct {
91+
FirstNamestring`json:"first_name"`
92+
LastNamestring`json:"last_name"`
93+
PhoneNumberstring`json:"phone_number"`
94+
JobTitlestring`json:"job_title"`
95+
CompanyNamestring`json:"company_name"`
96+
Countrystring`json:"country"`
97+
Developersstring`json:"developers"`
7198
}
7299

73100
// CreateFirstUserResponse contains IDs for newly created user info.

‎docs/api/schemas.md

Lines changed: 42 additions & 6 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/api/users.md

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

‎enterprise/trialer/trialer.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,19 @@ import (
1414

1515
"github.com/coder/coder/v2/coderd/database"
1616
"github.com/coder/coder/v2/coderd/database/dbtime"
17+
"github.com/coder/coder/v2/codersdk"
1718
"github.com/coder/coder/v2/enterprise/coderd/license"
1819
)
1920

20-
typerequeststruct {
21-
DeploymentIDstring`json:"deployment_id"`
22-
Emailstring`json:"email"`
23-
}
24-
2521
// New creates a handler that can issue trial licenses!
26-
funcNew(db database.Store,urlstring,keysmap[string]ed25519.PublicKey)func(ctx context.Context,emailstring)error {
27-
returnfunc(ctx context.Context,emailstring)error {
22+
funcNew(db database.Store,urlstring,keysmap[string]ed25519.PublicKey)func(ctx context.Context,body codersdk.LicensorTrialRequest)error {
23+
returnfunc(ctx context.Context,body codersdk.LicensorTrialRequest)error {
2824
deploymentID,err:=db.GetDeploymentID(ctx)
2925
iferr!=nil {
3026
returnxerrors.Errorf("get deployment id: %w",err)
3127
}
32-
data,err:=json.Marshal(request{
33-
DeploymentID:deploymentID,
34-
Email:email,
35-
})
28+
body.DeploymentID=deploymentID
29+
data,err:=json.Marshal(body)
3630
iferr!=nil {
3731
returnxerrors.Errorf("marshal: %w",err)
3832
}

‎enterprise/trialer/trialer_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/stretchr/testify/require"
1010

1111
"github.com/coder/coder/v2/coderd/database/dbmem"
12+
"github.com/coder/coder/v2/codersdk"
1213
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
1314
"github.com/coder/coder/v2/enterprise/trialer"
1415
)
@@ -26,7 +27,7 @@ func TestTrialer(t *testing.T) {
2627
db:=dbmem.New()
2728

2829
gen:=trialer.New(db,srv.URL,coderdenttest.Keys)
29-
err:=gen(context.Background(),"kyle@coder.com")
30+
err:=gen(context.Background(),codersdk.LicensorTrialRequest{Email:"kyle+colin@coder.com"})
3031
require.NoError(t,err)
3132
licenses,err:=db.GetLicenses(context.Background())
3233
require.NoError(t,err)

‎go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ require (
206206

207207
requirego.uber.org/mockv0.4.0
208208

209-
requiregithub.com/benbjohnson/clockv1.3.5// indirect
209+
requiregithub.com/benbjohnson/clockv1.3.5
210210

211211
require (
212212
cloud.google.com/go/computev1.23.3// indirect

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp