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

Add --force flag to minio delete command #1687

Merged
merged 9 commits into from
Jul 25, 2023
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
1 change: 1 addition & 0 deletions helm/operator/templates/minio.min.io_tenants.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down
1 change: 1 addition & 0 deletions helm/operator/templates/sts.min.io_policybindings.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down
15 changes: 13 additions & 2 deletions kubectl-minio/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type deleteCmd struct {
errOut io.Writer
output bool
operatorOpts resources.OperatorOptions
force bool
dangerous bool
}

func newDeleteCmd(out io.Writer, errOut io.Writer) *cobra.Command {
Expand All @@ -57,8 +59,15 @@ func newDeleteCmd(out io.Writer, errOut io.Writer) *cobra.Command {
Example: deleteExample,
Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
if !helpers.Ask("Are you sure you want to delete ALL the MinIO Tenants and MinIO Operator, this is not a reversible operation") {
return fmt.Errorf(Bold("Aborting Operator deletion"))
if !o.force {
if !helpers.Ask("This is irreversible, are you sure you want to delete MinIO Operator and all it's tenants") {
return fmt.Errorf("Aborting MinIO Operator deletion")
}
}
if !o.dangerous {
if !helpers.Ask("Please provide the dangerous flag to confirm deletion") {
return fmt.Errorf("Aborting MinIO Operator deletion")
}
}
err := o.run(out)
if err != nil {
Expand All @@ -71,6 +80,8 @@ func newDeleteCmd(out io.Writer, errOut io.Writer) *cobra.Command {
cmd = helpers.DisableHelp(cmd)
f := cmd.Flags()
f.StringVarP(&o.operatorOpts.Namespace, "namespace", "n", helpers.DefaultNamespace, "namespace scope for this request")
f.BoolVarP(&o.force, "force", "f", false, "allow without confirmation")
f.BoolVarP(&o.dangerous, "dangerous", "d", false, "confirm deletion")
return cmd
}

Expand Down
2 changes: 1 addition & 1 deletion kubectl-minio/cmd/kubectl-minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func init() {
}

// New creates a new root command for kubectl-minio
func New(streams genericclioptions.IOStreams) *cobra.Command {
func New(_ genericclioptions.IOStreams) *cobra.Command {
rootCmd = helpers.DisableHelp(rootCmd)
cobra.EnableCommandSorting = false
rootCmd.AddCommand(newInitCmd(rootCmd.OutOrStdout(), rootCmd.ErrOrStderr()))
Expand Down
2 changes: 1 addition & 1 deletion kubectl-minio/cmd/resources/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func NewTenant(opts *TenantOptions, userSecret *v1.Secret) (*miniov2.Tenant, err
return t, t.Validate()
}

func getAutoCertConfig(opts *TenantOptions) *miniov2.CertificateConfig {
func getAutoCertConfig(_ *TenantOptions) *miniov2.CertificateConfig {
return &miniov2.CertificateConfig{
CommonName: "",
OrganizationName: []string{},
Expand Down
2 changes: 1 addition & 1 deletion kubectl-minio/cmd/tenant-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (c *createCmd) validate(args []string) error {
}

// run initializes local config and installs MinIO Operator to Kubernetes cluster.
func (c *createCmd) run(args []string) error {
func (c *createCmd) run(_ []string) error {
// Create operator and kube client
path, _ := rootCmd.Flags().GetString(kubeconfig)
operatorClient, err := helpers.GetKubeOperatorClient(path)
Expand Down
2 changes: 1 addition & 1 deletion kubectl-minio/cmd/tenant-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (d *listCmd) validate(args []string) error {
}

// run initializes local config and installs MinIO Operator to Kubernetes cluster.
func (d *listCmd) run(args []string) error {
func (d *listCmd) run(_ []string) error {
// Create operator client
path, _ := rootCmd.Flags().GetString(kubeconfig)
oclient, err := helpers.GetKubeOperatorClient(path)
Expand Down
2 changes: 1 addition & 1 deletion kubectl-minio/cmd/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func getTenantNamespace(client *operatorv1.Clientset, tenantName string) (string
return "", fmt.Errorf("tenant: %s not found on any namespace", tenantName)
}

func newTenantCmd(out io.Writer, errOut io.Writer) *cobra.Command {
func newTenantCmd(_ io.Writer, _ io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "tenant",
Short: "Manage MinIO tenant(s)",
Expand Down