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

feat: add additional fields to first time setup trial flow#11533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.gitattributes
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,3 +12,4 @@ provisionersdk/proto/*.go linguist-generated=true
*.tfstate.dot linguist-generated=true
*.tfplan.dot linguist-generated=true
site/src/api/typesGenerated.ts linguist-generated=true
site/src/pages/SetupPage/countries.tsx linguist-generated=true
3 changes: 2 additions & 1 deletion.github/workflows/typos.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ darcula = "darcula"
Hashi = "Hashi"
trialer = "trialer"
encrypter = "encrypter"
hel = "hel" # as in helsinki
hel = "hel"# as in helsinki

[files]
extend-exclude = [
Expand All@@ -31,4 +31,5 @@ extend-exclude = [
"**/*.test.tsx",
"**/pnpm-lock.yaml",
"tailnet/testdata/**",
"site/src/pages/SetupPage/countries.tsx",
]
29 changes: 29 additions & 0 deletionscoderd/apidoc/docs.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

29 changes: 29 additions & 0 deletionscoderd/apidoc/swagger.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 1 addition & 1 deletioncoderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -123,7 +123,7 @@ type Options struct {
TracerProvider trace.TracerProvider
ExternalAuthConfigs []*externalauth.Config
RealIPConfig *httpmw.RealIPConfig
TrialGenerator func(ctx context.Context,email string) error
TrialGenerator func(ctx context.Context,body codersdk.LicensorTrialRequest) error
// TLSCertificates is used to mesh DERP servers securely.
TLSCertificates []tls.Certificate
TailnetCoordinator tailnet.Coordinator
Expand Down
2 changes: 1 addition & 1 deletioncoderd/coderdtest/coderdtest.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ type Options struct {
Auditor audit.Auditor
TLSCertificates []tls.Certificate
ExternalAuthConfigs []*externalauth.Config
TrialGenerator func(context.Context,string) error
TrialGenerator func(ctxcontext.Context,body codersdk.LicensorTrialRequest) error
TemplateScheduleStore schedule.TemplateScheduleStore
Coordinator tailnet.Coordinator

Expand Down
2 changes: 1 addition & 1 deletioncoderd/externalauth/externalauth.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -325,7 +325,7 @@ func (c *DeviceAuth) AuthorizeDevice(ctx context.Context) (*codersdk.ExternalAut
// return a better error.
switch resp.StatusCode {
case http.StatusTooManyRequests:
return nil,fmt.Errorf("rate limit hit, unable to authorize device. please try again later")
return nil,xerrors.New("rate limit hit, unable to authorize device. please try again later")
default:
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletioncoderd/httpapi/websocket.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,8 +4,9 @@ import (
"context"
"time"

"cdr.dev/slog"
"nhooyr.io/websocket"

"cdr.dev/slog"
)

// Heartbeat loops to ping a WebSocket to keep it alive.
Expand Down
5 changes: 3 additions & 2 deletionscoderd/promoauth/github.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
package promoauth

import (
"fmt"
"net/http"
"strconv"
"time"

"golang.org/x/xerrors"
)

type rateLimits struct {
Expand DownExpand Up@@ -81,7 +82,7 @@ func (p *headerParser) string(key string) string {

v := p.header.Get(key)
if v == "" {
p.errors[key] =fmt.Errorf("missing header %q", key)
p.errors[key] =xerrors.Errorf("missing header %q", key)
}
return v
}
Expand Down
11 changes: 10 additions & 1 deletioncoderd/users.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -152,7 +152,16 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) {
}

if createUser.Trial && api.TrialGenerator != nil {
err = api.TrialGenerator(ctx, createUser.Email)
err = api.TrialGenerator(ctx, codersdk.LicensorTrialRequest{
Email: createUser.Email,
FirstName: createUser.TrialInfo.FirstName,
LastName: createUser.TrialInfo.LastName,
PhoneNumber: createUser.TrialInfo.PhoneNumber,
JobTitle: createUser.TrialInfo.JobTitle,
CompanyName: createUser.TrialInfo.CompanyName,
Country: createUser.TrialInfo.Country,
Developers: createUser.TrialInfo.Developers,
})
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Failed to generate trial",
Expand Down
2 changes: 1 addition & 1 deletioncoderd/users_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,7 +76,7 @@ func TestFirstUser(t *testing.T) {
t.Parallel()
called := make(chan struct{})
client := coderdtest.New(t, &coderdtest.Options{
TrialGenerator: func(ctxcontext.Context,s string) error {
TrialGenerator: func(context.Context,codersdk.LicensorTrialRequest) error {
close(called)
return nil
},
Expand Down
35 changes: 31 additions & 4 deletionscodersdk/users.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,11 +63,38 @@ type GetUsersResponse struct {
Count int `json:"count"`
}

// @typescript-ignore LicensorTrialRequest
type LicensorTrialRequest struct {
DeploymentID string `json:"deployment_id"`
Email string `json:"email"`
Source string `json:"source"`

// Personal details.
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
PhoneNumber string `json:"phone_number"`
JobTitle string `json:"job_title"`
CompanyName string `json:"company_name"`
Country string `json:"country"`
Developers string `json:"developers"`
}

type CreateFirstUserRequest struct {
Email string `json:"email" validate:"required,email"`
Username string `json:"username" validate:"required,username"`
Password string `json:"password" validate:"required"`
Trial bool `json:"trial"`
Email string `json:"email" validate:"required,email"`
Username string `json:"username" validate:"required,username"`
Password string `json:"password" validate:"required"`
Trial bool `json:"trial"`
TrialInfo CreateFirstUserTrialInfo `json:"trial_info"`
}

type CreateFirstUserTrialInfo struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
PhoneNumber string `json:"phone_number"`
JobTitle string `json:"job_title"`
CompanyName string `json:"company_name"`
Country string `json:"country"`
Developers string `json:"developers"`
}

// CreateFirstUserResponse contains IDs for newly created user info.
Expand Down
48 changes: 42 additions & 6 deletionsdocs/api/schemas.md
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

9 changes: 9 additions & 0 deletionsdocs/api/users.md
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

16 changes: 5 additions & 11 deletionsenterprise/trialer/trialer.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,25 +14,19 @@ import (

"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/enterprise/coderd/license"
)

type request struct {
DeploymentID string `json:"deployment_id"`
Email string `json:"email"`
}

// New creates a handler that can issue trial licenses!
func New(db database.Store, url string, keys map[string]ed25519.PublicKey) func(ctx context.Context,email string) error {
return func(ctx context.Context,email string) error {
func New(db database.Store, url string, keys map[string]ed25519.PublicKey) func(ctx context.Context,body codersdk.LicensorTrialRequest) error {
return func(ctx context.Context,body codersdk.LicensorTrialRequest) error {
deploymentID, err := db.GetDeploymentID(ctx)
if err != nil {
return xerrors.Errorf("get deployment id: %w", err)
}
data, err := json.Marshal(request{
DeploymentID: deploymentID,
Email: email,
})
body.DeploymentID = deploymentID
data, err := json.Marshal(body)
if err != nil {
return xerrors.Errorf("marshal: %w", err)
}
Expand Down
3 changes: 2 additions & 1 deletionenterprise/trialer/trialer_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/coder/coder/v2/coderd/database/dbmem"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
"github.com/coder/coder/v2/enterprise/trialer"
)
Expand All@@ -26,7 +27,7 @@ func TestTrialer(t *testing.T) {
db := dbmem.New()

gen := trialer.New(db, srv.URL, coderdenttest.Keys)
err := gen(context.Background(), "kyle@coder.com")
err := gen(context.Background(),codersdk.LicensorTrialRequest{Email:"kyle+colin@coder.com"})
require.NoError(t, err)
licenses, err := db.GetLicenses(context.Background())
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletiongo.mod
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -206,7 +206,7 @@ require (

require go.uber.org/mock v0.4.0

require github.com/benbjohnson/clock v1.3.5 // indirect
require github.com/benbjohnson/clock v1.3.5

require (
cloud.google.com/go/compute v1.23.3 // indirect
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp