Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sg: cloud - remove wip notice for ephemeral commands #62568

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion dev/sg/internal/cloud/build_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var BuildEphemeralCommand = cli.Command{
Name: "build",
Usage: "trigger a cloud ephemeral build",
Description: "Triggers a Cloud Ephemeral build of the current branch which will push images to the cloud ephemeral registry",
Action: wipAction(buildCloudEphemeral),
Action: buildCloudEphemeral,
}

func writeAdditionalBuildCommandsSuggestion(version string) {
Expand Down
34 changes: 0 additions & 34 deletions dev/sg/internal/cloud/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ import (
"strings"

"github.com/sourcegraph/run"
"github.com/urfave/cli/v2"

"github.com/sourcegraph/sourcegraph/dev/sg/internal/repo"
"github.com/sourcegraph/sourcegraph/dev/sg/internal/std"
"github.com/sourcegraph/sourcegraph/lib/errors"
"github.com/sourcegraph/sourcegraph/lib/output"
)

var ErrUserCancelled = errors.New("user cancelled")
Expand All @@ -34,37 +31,6 @@ func inferInstanceNameFromBranch(ctx context.Context) (string, error) {
return sanitizeInstanceName(currentBranch), nil
}

func wipAction(actionFn cli.ActionFunc) cli.ActionFunc {
if actionFn == nil {
return nil
}
return func(ctx *cli.Context) error {
if err := printWIPNotice(ctx); err != nil {
return err
}

return actionFn(ctx)
}
}

func printWIPNotice(ctx *cli.Context) error {
if ctx.Bool("skip-wip-notice") {
return nil
}
notice := output.Line("🧪", output.StyleBold, "EXPERIMENTAL COMMAND - Do you want to continue? (yes/no)")

var answer string
if _, err := std.FancyPromptAndScan(std.Out, notice, &answer); err != nil {
return err
}

if oneOfEquals(answer, "yes", "y") {
return nil
}

return ErrUserCancelled
}

func oneOfEquals(value string, i ...string) bool {
for _, item := range i {
if value == item {
Expand Down
2 changes: 1 addition & 1 deletion dev/sg/internal/cloud/delete_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var DeleteEphemeralCommand = cli.Command{
Name: "delete",
Usage: "sg could delete <name/slug>",
Description: "delete ephemeral cloud instance identified either by the current branch or provided as a cli arg",
Action: wipAction(deleteCloudEphemeral),
Action: deleteCloudEphemeral,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Expand Down
2 changes: 1 addition & 1 deletion dev/sg/internal/cloud/deploy_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var DeployEphemeralCommand = cli.Command{
Name: "deploy",
Usage: "create a cloud ephemeral deployment",
Description: "Deploy the specified branch or tag to an ephemeral Sourcegraph Cloud environment",
Action: wipAction(deployCloudEphemeral),
Action: deployCloudEphemeral,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Expand Down
2 changes: 1 addition & 1 deletion dev/sg/internal/cloud/lease_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var LeaseEphemeralCommand = cli.Command{
Usage: "extend or reduce the lease of an ephemeral instance",
UsageText: "sg cloud lease [command options]",
Description: "update the lease time of an ephemeral instance",
Action: wipAction(leaseCloudEphemeral),
Action: leaseCloudEphemeral,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Expand Down
2 changes: 1 addition & 1 deletion dev/sg/internal/cloud/list_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var ListEphemeralCommand = cli.Command{
Name: "list",
Usage: "list ephemeral cloud instances",
Description: "list ephemeral cloud instances attached to your GCP account",
Action: wipAction(listCloudEphemeral),
Action: listCloudEphemeral,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "json",
Expand Down
2 changes: 1 addition & 1 deletion dev/sg/internal/cloud/status_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var StatusEphemeralCommand = cli.Command{
Name: "status",
Usage: "get status of ephemeral cloud instance",
Description: "get the status of the ephemeral cloud instance for this branch or instance with the provided name",
Action: wipAction(statusCloudEphemeral),
Action: statusCloudEphemeral,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Expand Down
2 changes: 1 addition & 1 deletion dev/sg/internal/cloud/upgrade_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var UpgradeEphemeralCommand = cli.Command{
Name: "upgrade",
Usage: "upgrade a cloud ephemeral",
Description: "Upgrade the given Ephemeral deployment with the specified version",
Action: wipAction(upgradeCloudEphemeral),
Action: upgradeCloudEphemeral,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Expand Down
Loading