Skip to content

Commit

Permalink
-v3.1.1 - refactor delete
Browse files Browse the repository at this point in the history
  • Loading branch information
kubemq committed Sep 24, 2020
1 parent 9859f8d commit 13887f1
Show file tree
Hide file tree
Showing 10 changed files with 593 additions and 124 deletions.
77 changes: 43 additions & 34 deletions .idea/workspace.xml

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

23 changes: 21 additions & 2 deletions cmd/delete/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/kubemq-io/kubemqctl/pkg/config"
client2 "github.com/kubemq-io/kubemqctl/pkg/k8s/client"
"github.com/kubemq-io/kubemqctl/pkg/k8s/manager/cluster"
"github.com/kubemq-io/kubemqctl/pkg/k8s/manager/operator"
operatorTypes "github.com/kubemq-io/kubemqctl/pkg/k8s/types/operator"
"github.com/kubemq-io/kubemqctl/pkg/utils"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -63,7 +65,10 @@ func (o *DeleteOptions) Run(ctx context.Context) error {
if err != nil {
return err
}

operatorManager, err := operator.NewManager(client)
if err != nil {
return err
}
clusters, err := clusterManager.GetKubemqClusters()
if err != nil {
return err
Expand Down Expand Up @@ -104,7 +109,21 @@ func (o *DeleteOptions) Run(ctx context.Context) error {
return nil
}
for _, selected := range selection {
err := clusterManager.DeleteKubemqCluster(clusters.Cluster(selected))
cluster := clusters.Cluster(selected)
if !operatorManager.IsKubemqOperatorExists(cluster.Namespace) {
operatorDeployment, err := operatorTypes.CreateDeployment("kubemq-operator", cluster.Namespace)
if err != nil {
return err
}
_, _, err = operatorManager.CreateOrUpdateKubemqOperator(operatorDeployment)
if err != nil {
return err
}
utils.Printlnf("Kubemq operator %s/kubemq-operator created.", cluster.Namespace)
} else {
utils.Printlnf("Kubemq operator %s/kubemq-operator exists", cluster.Namespace)
}
err := clusterManager.DeleteKubemqCluster(cluster)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 13887f1

Please sign in to comment.