confirmDefaultCASBackendOverride asks the user to confirm the override of the default CAS backend in the event that there is one already set and its not the same as the one we are setting
(actionOpts *action.ActionsOpts, id string)
| 78 | // confirmDefaultCASBackendOverride asks the user to confirm the override of the default CAS backend |
| 79 | // in the event that there is one already set and its not the same as the one we are setting |
| 80 | func confirmDefaultCASBackendOverride(actionOpts *action.ActionsOpts, id string) (bool, error) { |
| 81 | // get existing backends |
| 82 | backends, err := action.NewCASBackendList(actionOpts).Run() |
| 83 | if err != nil { |
| 84 | return false, fmt.Errorf("failed to list existing CAS backends: %w", err) |
| 85 | } |
| 86 | |
| 87 | // Find the default |
| 88 | var defaultB *action.CASBackendItem |
| 89 | for _, b := range backends { |
| 90 | if b.Default { |
| 91 | defaultB = b |
| 92 | break |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // If there is none or there is but it's the same as the one we are setting, we are ok |
| 97 | if defaultB == nil || (id != "" && id == defaultB.ID) { |
| 98 | return true, nil |
| 99 | } |
| 100 | |
| 101 | // Ask the user to confirm the override |
| 102 | return confirmationPrompt("You are changing the default CAS backend in your organization"), nil |
| 103 | } |
| 104 | |
| 105 | // If we are removing the default we confirm too |
| 106 | func confirmDefaultCASBackendRemoval(actionOpts *action.ActionsOpts, name string) (bool, error) { |
no test coverage detected