Skip to content

Commit 6de3a7b

Browse files
Add confirm functionality for bootstrap
* Shows current api server * optionally requests confirmation before proceeding
1 parent 262007a commit 6de3a7b

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
- name: golangci-lint
3434
uses: golangci/golangci-lint-action@v9.2.0
3535
with:
36-
version: latest
3736
skip-cache: true
37+
version: v2.11.4
3838

3939
contract-validation:
4040
name: Validate PR Contracts

cmd/command/cd/cd_clusters.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/pluralsh/plural-cli/pkg/common"
1919
"github.com/pluralsh/plural-cli/pkg/console"
2020
"github.com/pluralsh/plural-cli/pkg/console/errors"
21+
"github.com/pluralsh/plural-cli/pkg/kubernetes"
2122
"github.com/pluralsh/plural-cli/pkg/kubernetes/config"
2223
"github.com/pluralsh/plural-cli/pkg/utils"
2324
)
@@ -113,6 +114,10 @@ func (p *Plural) cdClusterCommands() []cli.Command {
113114
Name: "metadata",
114115
Usage: "Path to metadata file, or '-' to read from stdin",
115116
},
117+
cli.BoolFlag{
118+
Name: "confirm",
119+
Usage: "print the current kubeconfig API server and prompt before creating the cluster and installing the agent",
120+
},
116121
},
117122
},
118123
{
@@ -472,6 +477,18 @@ func (p *Plural) handleClusterBootstrap(c *cli.Context) error {
472477
return err
473478
}
474479

480+
restConf, err := kubernetes.KubeConfig()
481+
if err != nil {
482+
return err
483+
}
484+
utils.Highlight("Current Kubernetes API server to install the agent on: %s\n", restConf.Host)
485+
486+
if c.Bool("confirm") {
487+
if !common.Affirm("Do you want to deploy the agent to this cluster?", "PLURAL_CD_BOOTSTRAP_AFFIRM_CLUSTER") {
488+
return nil
489+
}
490+
}
491+
475492
attrs := gqlclient.ClusterAttributes{Name: c.String("name")}
476493
if c.String("handle") != "" {
477494
attrs.Handle = lo.ToPtr(c.String("handle"))

0 commit comments

Comments
 (0)