Skip to content

Commit 30443b4

Browse files
committed
refactor(compute/deploy): prompt user to continue
1 parent 8a10547 commit 30443b4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pkg/commands/compute/deploy.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ func (c *DeployCommand) NewService(manifestFilename string, spinner text.Spinner
526526
// There is no service and so we'll do a one time creation of the service
527527
//
528528
// NOTE: we're shadowing the `serviceID` and `serviceVersion` variables.
529-
serviceID, serviceVersion, err = createService(c.Globals, serviceName, spinner, out)
529+
serviceID, serviceVersion, err = createService(c.Globals, serviceName, spinner, in, out)
530530
if err != nil {
531531
c.Globals.ErrLog.AddWithContext(err, map[string]any{
532532
"Service name": serviceName,
@@ -556,7 +556,7 @@ func (c *DeployCommand) NewService(manifestFilename string, spinner text.Spinner
556556
}
557557

558558
// createService creates a service to associate with the compute package.
559-
func createService(g *global.Data, serviceName string, spinner text.Spinner, out io.Writer) (serviceID string, serviceVersion *fastly.Version, err error) {
559+
func createService(g *global.Data, serviceName string, spinner text.Spinner, in io.Reader, out io.Writer) (serviceID string, serviceVersion *fastly.Version, err error) {
560560
f := g.Flags
561561
apiClient := g.APIClient
562562
errLog := g.ErrLog
@@ -608,6 +608,13 @@ func createService(g *global.Data, serviceName string, spinner text.Spinner, out
608608

609609
if !epr.HasAccess {
610610
text.Info(out, "\n"+undocumented.EntitledProductMessageCompute+"\n\n")
611+
cont, err := text.AskYesNo(out, "Are you sure you want to continue? [y/N]: ", in)
612+
if err != nil {
613+
return "", nil, err
614+
}
615+
if !cont {
616+
return "", nil, fsterr.ErrComputeTrialStopped
617+
}
611618
}
612619

613620
err = spinner.Start()

pkg/errors/errors.go

+4
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,7 @@ var ErrInvalidEnableDisableFlagCombo = RemediationError{
171171
Inner: fmt.Errorf("invalid flag combination: --enable and --disable"),
172172
Remediation: "Use either --enable or --disable, not both.",
173173
}
174+
175+
// ErrComputeTrialStopped means the user declined to go ahead and create a trial
176+
// account to deploy their Compute application.
177+
var ErrComputeTrialStopped = errors.New("deploy stopped by user")

0 commit comments

Comments
 (0)