Murtaza Udaipurwala ba8265bc5c
feat: new talosctl config remove to remove context
Adds a new sub-command to talosctl config. It takes in the context to be
deleted as argument and supports glob matching.

A local flag --noconfirm|-y can be passed to bypass the confirmation
prompt.

It also supports dry run by passing the --dry-run flag similar to
apply-config and edit commands.

Example:

    $ talosctl config remove 'ctx-*'
    Remove context ctx-a? (y/N): y
    Remove context ctx-b? (y/N): y

Signed-off-by: Murtaza Udaipurwala <murtaza@murtazau.xyz>
Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
2022-12-29 13:39:12 +03:00

31 lines
627 B
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package helpers
import (
"fmt"
"strings"
)
var okays = []string{"y", "yes"}
// Confirm asks the user to confirm their action. Anything other than
// `y` and `yes` returns false.
func Confirm(prompt string) bool {
var inp string
fmt.Printf("%s (y/N): ", prompt)
fmt.Scanf("%s", &inp)
inp = strings.TrimSpace(inp)
for _, ok := range okays {
if strings.EqualFold(inp, ok) {
return true
}
}
return false
}