-
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: Greg Haynes <[email protected]>
- Loading branch information
1 parent
632490d
commit af755fd
Showing
6 changed files
with
103 additions
and
7 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
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,51 @@ | ||
package delete | ||
|
||
import ( | ||
"flag" | ||
|
||
"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 | ||
) | ||
|
||
var DeleteCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete an IDP cluster", | ||
Long: ``, | ||
RunE: delete, | ||
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) | ||
} | ||
|
||
func preDeleteE(cmd *cobra.Command, args []string) error { | ||
return helpers.SetLogger() | ||
} | ||
|
||
func delete(cmd *cobra.Command, args []string) error { | ||
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) | ||
} | ||
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,43 @@ | ||
package clusters | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||
"sigs.k8s.io/kind/pkg/cluster" | ||
) | ||
|
||
var ClustersCmd = &cobra.Command{ | ||
Use: "clusters", | ||
Short: "Get idp clusters", | ||
Long: ``, | ||
RunE: list, | ||
} | ||
|
||
func init() { | ||
zapfs := flag.NewFlagSet("zap", flag.ExitOnError) | ||
opts := zap.Options{ | ||
Development: true, | ||
} | ||
opts.BindFlags(zapfs) | ||
ClustersCmd.Flags().AddGoFlagSet(zapfs) | ||
|
||
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) | ||
} | ||
|
||
func list(cmd *cobra.Command, args []string) error { | ||
provider := cluster.NewProvider(cluster.ProviderWithDocker()) | ||
clusters, err := provider.List() | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to list clusters") | ||
} | ||
|
||
for _, cluster := range clusters { | ||
fmt.Println(cluster) | ||
} | ||
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
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