Skip to content

Commit

Permalink
Add warning on some CLI commands that orbs cannot be deleted once the…
Browse files Browse the repository at this point in the history
…y are created
  • Loading branch information
rlegan committed Apr 14, 2023
1 parent 66c2bfe commit 39b8109
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ Please note that at this time all orbs created in the registry are world-readabl
},
}

orbCommand.AddCommand(listCommand)
orbCommand.AddCommand(listCommand) //yeah
orbCommand.AddCommand(orbCreate)
orbCommand.AddCommand(validateCommand)
orbCommand.AddCommand(processCommand)
Expand Down Expand Up @@ -719,6 +719,13 @@ func processOrb(opts orbOptions) error {
}

func publishOrb(opts orbOptions) error {
willingToContinue, err := orbConfirmOrbCannotBeDeletedMessage()
if err != nil {
return err
}
if !willingToContinue {
return nil
}
path := opts.args[0]
ref := opts.args[1]
namespace, orb, version, err := references.SplitIntoOrbNamespaceAndVersion(ref)
Expand Down Expand Up @@ -794,6 +801,14 @@ func validateSegmentArg(label string) error {
}

func incrementOrb(opts orbOptions) error {
willingToContinue, err := orbConfirmOrbCannotBeDeletedMessage()
if err != nil {
return err
}
if !willingToContinue {
return nil
}

ref := opts.args[1]
segment := opts.args[2]

Expand Down Expand Up @@ -822,6 +837,14 @@ func incrementOrb(opts orbOptions) error {
}

func promoteOrb(opts orbOptions) error {
willingToContinue, err := orbConfirmOrbCannotBeDeletedMessage()
if err != nil {
return err
}
if !willingToContinue {
return nil
}

ref := opts.args[0]
segment := opts.args[1]

Expand Down Expand Up @@ -1104,6 +1127,14 @@ func initOrb(opts orbOptions) error {
var err error
fmt.Println("Note: This command is in preview. Please report any bugs! https://github.com/CircleCI-Public/circleci-cli/issues/new/choose")

willingToContinue, err := orbConfirmOrbCannotBeDeletedMessage()
if err != nil {
return err
}
if !willingToContinue {
return nil
}

fullyAutomated := 0
prompt := &survey.Select{
Message: "Would you like to perform an automated setup of this orb?",
Expand Down Expand Up @@ -1734,3 +1765,20 @@ func stringifyDiff(diff gotextdiff.Unified, colorOpt string) string {
color.NoColor = oldNoColor
return strings.Join(lines, "\n")
}

func orbConfirmOrbCannotBeDeletedMessage() (bool, error) {
fmt.Println("Once an orb is created it cannot be deleted. Orbs are semver compliant, and each published version is immutable. Publicly released orbs are potential dependencies for other projects.")
fmt.Println("Therefore, allowing orb deletion would make users susceptible to unexpected loss of functionality.")

willingToContinue := 0
prompt := &survey.Select{
Message: "Are you sure you want to continue?",
Options: []string{"Yes", "No"},
}
err := survey.AskOne(prompt, &willingToContinue)
if err != nil {
return false, errors.Wrap(err, "Unexpected error")
}

return willingToContinue == 0, nil
}

0 comments on commit 39b8109

Please sign in to comment.