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:
Colin Adler
2024-01-16 18:19:16 -06:00
committed by GitHub
parent 1196f83ebd
commit be43d6247d
17 changed files with 1329 additions and 28 deletions
+5 -11
View File
@@ -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)
}
+2 -1
View File
@@ -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)