-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Manabu McCloskey <[email protected]>
- Loading branch information
Showing
6 changed files
with
48 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,44 @@ | ||
package delete | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
|
||
"github.com/cnoe-io/idpbuilder/pkg/cmd/helpers" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||
"sigs.k8s.io/kind/pkg/cluster" | ||
) | ||
|
||
var ( | ||
// Flags | ||
buildName string | ||
name string | ||
) | ||
|
||
var DeleteCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete an IDP cluster", | ||
Long: ``, | ||
RunE: delete, | ||
RunE: deleteE, | ||
PreRunE: preDeleteE, | ||
} | ||
|
||
func init() { | ||
DeleteCmd.PersistentFlags().StringVar(&buildName, "build-name", "localdev", "Name of the kind cluster to be deleted.") | ||
|
||
zapfs := flag.NewFlagSet("zap", flag.ExitOnError) | ||
opts := zap.Options{ | ||
Development: true, | ||
} | ||
opts.BindFlags(zapfs) | ||
DeleteCmd.Flags().AddGoFlagSet(zapfs) | ||
DeleteCmd.PersistentFlags().StringVar(&name, "name", "localdev", "Name of the kind cluster to be deleted.") | ||
} | ||
|
||
func preDeleteE(cmd *cobra.Command, args []string) error { | ||
return helpers.SetLogger() | ||
} | ||
|
||
func delete(cmd *cobra.Command, args []string) error { | ||
func deleteE(cmd *cobra.Command, args []string) error { | ||
logger := helpers.CmdLogger | ||
logger.Info("deleting cluster", "clusterName", name) | ||
detectOpt, err := cluster.DetectNodeProvider() | ||
if err != nil { | ||
return err | ||
} | ||
provider := cluster.NewProvider(detectOpt) | ||
if err := provider.Delete(buildName, ""); err != nil { | ||
return errors.Wrapf(err, "failed to delete cluster %q", buildName) | ||
if err := provider.Delete(name, ""); err != nil { | ||
return fmt.Errorf("failed to delete cluster %s: %w", name, err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package get | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cnoe-io/idpbuilder/pkg/cmd/helpers" | ||
"github.com/spf13/cobra" | ||
"sigs.k8s.io/kind/pkg/cluster" | ||
) | ||
|
||
var ClustersCmd = &cobra.Command{ | ||
Use: "clusters", | ||
Short: "Get idp clusters", | ||
Long: ``, | ||
RunE: list, | ||
PreRunE: preClustersE, | ||
} | ||
|
||
func preClustersE(cmd *cobra.Command, args []string) error { | ||
return helpers.SetLogger() | ||
} | ||
|
||
func list(cmd *cobra.Command, args []string) error { | ||
provider := cluster.NewProvider(cluster.ProviderWithDocker()) | ||
clusters, err := provider.List() | ||
if err != nil { | ||
return fmt.Errorf("failed to list clusters: %w", err) | ||
} | ||
|
||
for _, c := range clusters { | ||
fmt.Println(c) | ||
} | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters