mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add additional fields to first time setup trial flow (#11533)
* feat: add additional fields to first time setup trial flow * trial generator typo
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user