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

feat: cd install check cluster #471

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 14 additions & 3 deletions cmd/plural/cd.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func (p *Plural) cdCommands() []cli.Command {
},
},
{
Name: "eject",
Action: p.handleEject,
Usage: "ejects cluster scaffolds",
Name: "eject",
Action: p.handleEject,
Usage: "ejects cluster scaffolds",
ArgsUsage: "<cluster-id>",
// TODO: enable once logic is finished
Hidden: true,
Expand Down Expand Up @@ -93,6 +93,17 @@ func (p *Plural) doInstallOperator(url, token string) error {
if err != nil && !apierrors.IsAlreadyExists(err) {
return err
}
consoleClient, err := console.NewConsoleClient(token, url)
if err != nil {
return err
}
myCluster, err := consoleClient.MyCluster()
if err != nil {
return err
}
if !confirm(fmt.Sprintf("Are you sure you want to install deploy operator for %s cluster?", myCluster.MyCluster.Name), "PLURAL_INSTALL_AGENT_CONFIRM") {
zreigz marked this conversation as resolved.
Show resolved Hide resolved
return nil
}
err = console.InstallAgent(url, token, operatorNamespace)
if err == nil {
utils.Success("deployment operator installed successfully\n")
Expand Down
4 changes: 4 additions & 0 deletions pkg/console/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ func (c *consoleClient) CreateCluster(attributes consoleclient.ClusterAttributes
}
return newCluster, nil
}

func (c *consoleClient) MyCluster() (*consoleclient.MyCluster, error) {
return c.client.MyCluster(c.ctx)
}
1 change: 1 addition & 0 deletions pkg/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ConsoleClient interface {
SavePipeline(name string, attrs consoleclient.PipelineAttributes) (*consoleclient.PipelineFragment, error)
CreateCluster(attributes consoleclient.ClusterAttributes) (*consoleclient.CreateCluster, error)
CreateProvider(attr consoleclient.ClusterProviderAttributes) (*consoleclient.CreateClusterProvider, error)
MyCluster() (*consoleclient.MyCluster, error)
}

func NewConsoleClient(token, url string) (ConsoleClient, error) {
Expand Down
66 changes: 66 additions & 0 deletions pkg/test/mocks/ConsoleClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading