diff --git a/pkg/cmd/adm/adm.go b/pkg/cmd/adm/adm.go index 19eefb5..fe0cf95 100644 --- a/pkg/cmd/adm/adm.go +++ b/pkg/cmd/adm/adm.go @@ -22,8 +22,6 @@ func NewAdmCmd() *cobra.Command { func registerCommands(admCommand *cobra.Command) { // commands with go runtime client admCommand.AddCommand(NewRestartCmd()) - admCommand.AddCommand(NewSetupCmd()) - admCommand.AddCommand(NewGenerateCliConfigsCmd()) admCommand.AddCommand(NewUnregisterMemberCmd()) admCommand.AddCommand(NewMustGatherNamespaceCmd()) diff --git a/pkg/cmd/adm/setup.go b/pkg/cmd/generate/admin-manifests.go similarity index 87% rename from pkg/cmd/adm/setup.go rename to pkg/cmd/generate/admin-manifests.go index 69d15d7..0e35d91 100644 --- a/pkg/cmd/adm/setup.go +++ b/pkg/cmd/generate/admin-manifests.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "os" @@ -19,12 +19,12 @@ type setupFlags struct { singleCluster bool } -func NewSetupCmd() *cobra.Command { +func NewAdminManifestsCmd() *cobra.Command { f := setupFlags{} command := &cobra.Command{ - Use: "setup --kubesaw-admins= --out-dir ", - Example: `ksctl adm setup ./path/to/kubesaw.openshiftapps.com/kubesaw-admins.yaml --out-dir ./components/auth/kubesaw-production -ksctl adm setup ./path/to/kubesaw-stage.openshiftapps.com/kubesaw-admins.yaml --out-dir ./components/auth/kubesaw-staging -s`, + Use: "admin-manifests --kubesaw-admins= --out-dir ", + Example: `ksctl generate admin-manifests ./path/to/kubesaw.openshiftapps.com/kubesaw-admins.yaml --out-dir ./components/auth/kubesaw-production +ksctl generate admin-manifests ./path/to/kubesaw-stage.openshiftapps.com/kubesaw-admins.yaml --out-dir ./components/auth/kubesaw-staging -s`, Short: "Generates user-management manifests", Long: `Reads the kubesaw-admins.yaml file and based on the content it generates user-management RBAC and manifests.`, Args: cobra.ExactArgs(0), diff --git a/pkg/cmd/adm/setup_test.go b/pkg/cmd/generate/admin-manifests_test.go similarity index 99% rename from pkg/cmd/adm/setup_test.go rename to pkg/cmd/generate/admin-manifests_test.go index e2c8f2a..4c2bdc9 100644 --- a/pkg/cmd/adm/setup_test.go +++ b/pkg/cmd/generate/admin-manifests_test.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "fmt" diff --git a/pkg/cmd/adm/setup_assertion_test.go b/pkg/cmd/generate/assertion_test.go similarity index 99% rename from pkg/cmd/adm/setup_assertion_test.go rename to pkg/cmd/generate/assertion_test.go index 7e93c8b..724da85 100644 --- a/pkg/cmd/adm/setup_assertion_test.go +++ b/pkg/cmd/generate/assertion_test.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "encoding/json" diff --git a/pkg/cmd/adm/generate_cli_configs.go b/pkg/cmd/generate/cli_configs.go similarity index 98% rename from pkg/cmd/adm/generate_cli_configs.go rename to pkg/cmd/generate/cli_configs.go index d5d6dab..d551058 100644 --- a/pkg/cmd/adm/generate_cli_configs.go +++ b/pkg/cmd/generate/cli_configs.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "context" @@ -33,10 +33,10 @@ type generateFlags struct { kubeconfigs []string } -func NewGenerateCliConfigsCmd() *cobra.Command { +func NewCliConfigsCmd() *cobra.Command { f := generateFlags{} command := &cobra.Command{ - Use: "generate-cli-configs --kubesaw-admins=", + Use: "cli-configs --kubesaw-admins=", Short: "Generate ksctl.yaml files", Long: `Generate ksctl.yaml files, that is used by ksctl, for every ServiceAccount defined in the given kubesaw-admins.yaml file`, Args: cobra.ExactArgs(0), diff --git a/pkg/cmd/adm/generate_cli_configs_test.go b/pkg/cmd/generate/cli_configs_test.go similarity index 99% rename from pkg/cmd/adm/generate_cli_configs_test.go rename to pkg/cmd/generate/cli_configs_test.go index 3c9ec34..e26ffb5 100644 --- a/pkg/cmd/adm/generate_cli_configs_test.go +++ b/pkg/cmd/generate/cli_configs_test.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "encoding/json" diff --git a/pkg/cmd/adm/setup_cluster.go b/pkg/cmd/generate/cluster.go similarity index 99% rename from pkg/cmd/adm/setup_cluster.go rename to pkg/cmd/generate/cluster.go index 9eec5fb..c124433 100644 --- a/pkg/cmd/adm/setup_cluster.go +++ b/pkg/cmd/generate/cluster.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "github.com/kubesaw/ksctl/pkg/configuration" diff --git a/pkg/cmd/adm/setup_cluster_test.go b/pkg/cmd/generate/cluster_test.go similarity index 99% rename from pkg/cmd/adm/setup_cluster_test.go rename to pkg/cmd/generate/cluster_test.go index 1660305..44d8fce 100644 --- a/pkg/cmd/adm/setup_cluster_test.go +++ b/pkg/cmd/generate/cluster_test.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "fmt" diff --git a/pkg/cmd/generate/generate.go b/pkg/cmd/generate/generate.go new file mode 100644 index 0000000..ffc1f92 --- /dev/null +++ b/pkg/cmd/generate/generate.go @@ -0,0 +1,20 @@ +package generate + +import ( + "github.com/spf13/cobra" +) + +func NewGenerateCmd() *cobra.Command { + admCommand := &cobra.Command{ + Use: "generate", + Short: "Generate commands", + Long: `Commands to generate manifests and CLI config files`, + } + registerCommands(admCommand) + return admCommand +} + +func registerCommands(admCommand *cobra.Command) { + admCommand.AddCommand(NewAdminManifestsCmd()) + admCommand.AddCommand(NewCliConfigsCmd()) +} diff --git a/pkg/cmd/adm/setup_mock_test.go b/pkg/cmd/generate/mock_test.go similarity index 99% rename from pkg/cmd/adm/setup_mock_test.go rename to pkg/cmd/generate/mock_test.go index fba566f..0ecbba6 100644 --- a/pkg/cmd/adm/setup_mock_test.go +++ b/pkg/cmd/generate/mock_test.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "fmt" diff --git a/pkg/cmd/adm/setup_permissions.go b/pkg/cmd/generate/permissions.go similarity index 99% rename from pkg/cmd/adm/setup_permissions.go rename to pkg/cmd/generate/permissions.go index 8d03c8b..6262fcd 100644 --- a/pkg/cmd/adm/setup_permissions.go +++ b/pkg/cmd/generate/permissions.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "fmt" diff --git a/pkg/cmd/adm/setup_permissions_test.go b/pkg/cmd/generate/permissions_test.go similarity index 99% rename from pkg/cmd/adm/setup_permissions_test.go rename to pkg/cmd/generate/permissions_test.go index 7e94112..cabac7b 100644 --- a/pkg/cmd/adm/setup_permissions_test.go +++ b/pkg/cmd/generate/permissions_test.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "fmt" diff --git a/pkg/cmd/adm/setup_roles_manager.go b/pkg/cmd/generate/roles_manager.go similarity index 98% rename from pkg/cmd/adm/setup_roles_manager.go rename to pkg/cmd/generate/roles_manager.go index 5814b99..a0d2318 100644 --- a/pkg/cmd/adm/setup_roles_manager.go +++ b/pkg/cmd/generate/roles_manager.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "fmt" diff --git a/pkg/cmd/adm/setup_roles_manager_test.go b/pkg/cmd/generate/roles_manager_test.go similarity index 99% rename from pkg/cmd/adm/setup_roles_manager_test.go rename to pkg/cmd/generate/roles_manager_test.go index 0d7e809..3e24dd4 100644 --- a/pkg/cmd/adm/setup_roles_manager_test.go +++ b/pkg/cmd/generate/roles_manager_test.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "testing" diff --git a/pkg/cmd/adm/setup_util.go b/pkg/cmd/generate/util.go similarity index 99% rename from pkg/cmd/adm/setup_util.go rename to pkg/cmd/generate/util.go index dd11550..94fdffe 100644 --- a/pkg/cmd/adm/setup_util.go +++ b/pkg/cmd/generate/util.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "fmt" diff --git a/pkg/cmd/adm/setup_util_test.go b/pkg/cmd/generate/util_test.go similarity index 99% rename from pkg/cmd/adm/setup_util_test.go rename to pkg/cmd/generate/util_test.go index 90d12b1..909b754 100644 --- a/pkg/cmd/adm/setup_util_test.go +++ b/pkg/cmd/generate/util_test.go @@ -1,4 +1,4 @@ -package adm +package generate import ( "fmt" diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 90ca1cf..2648f3b 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -7,6 +7,7 @@ import ( "os" "github.com/kubesaw/ksctl/pkg/cmd/adm" + "github.com/kubesaw/ksctl/pkg/cmd/generate" "github.com/kubesaw/ksctl/pkg/configuration" "github.com/kubesaw/ksctl/pkg/version" "github.com/spf13/cobra" @@ -56,6 +57,7 @@ func init() { // administrative commands rootCmd.AddCommand(adm.NewAdmCmd()) + rootCmd.AddCommand(generate.NewGenerateCmd()) // also, by default, we're configuring the underlying http.Client to accept insecured connections. // but gopkg.in/h2non/gock.v1 may change the client's Transport to intercept the requests.