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

move generating commands under 'ksctl generate' sub-command #29

Merged
merged 3 commits into from
Apr 3, 2024
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
2 changes: 0 additions & 2 deletions pkg/cmd/adm/adm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/adm/setup.go → pkg/cmd/generate/admin-manifests.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"os"
Expand All @@ -19,12 +19,12 @@
singleCluster bool
}

func NewSetupCmd() *cobra.Command {
func NewAdminManifestsCmd() *cobra.Command {

Check warning on line 22 in pkg/cmd/generate/admin-manifests.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/generate/admin-manifests.go#L22

Added line #L22 was not covered by tests
f := setupFlags{}
command := &cobra.Command{
Use: "setup --kubesaw-admins=<path-to-kubesaw-admins-file> --out-dir <path-to-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=<path-to-kubesaw-admins-file> --out-dir <path-to-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`,

Check warning on line 27 in pkg/cmd/generate/admin-manifests.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/generate/admin-manifests.go#L25-L27

Added lines #L25 - L27 were not covered by tests
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),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"context"
Expand Down Expand Up @@ -33,10 +33,10 @@
kubeconfigs []string
}

func NewGenerateCliConfigsCmd() *cobra.Command {
func NewCliConfigsCmd() *cobra.Command {

Check warning on line 36 in pkg/cmd/generate/cli_configs.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/generate/cli_configs.go#L36

Added line #L36 was not covered by tests
f := generateFlags{}
command := &cobra.Command{
Use: "generate-cli-configs --kubesaw-admins=<path-to-kubesaw-admins-file>",
Use: "cli-configs --kubesaw-admins=<path-to-kubesaw-admins-file>",

Check warning on line 39 in pkg/cmd/generate/cli_configs.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/generate/cli_configs.go#L39

Added line #L39 was not covered by tests
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),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"github.com/kubesaw/ksctl/pkg/configuration"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"fmt"
Expand Down
20 changes: 20 additions & 0 deletions pkg/cmd/generate/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package generate

import (
"github.com/spf13/cobra"
)

func NewGenerateCmd() *cobra.Command {
admCommand := &cobra.Command{
Use: "generate",
Short: "Generate Commands",
Long: `Actions for generating manifests and files.`,

Check warning on line 11 in pkg/cmd/generate/generate.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/generate/generate.go#L7-L11

Added lines #L7 - L11 were not covered by tests
MatousJobanek marked this conversation as resolved.
Show resolved Hide resolved
}
registerCommands(admCommand)
return admCommand

Check warning on line 14 in pkg/cmd/generate/generate.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/generate/generate.go#L13-L14

Added lines #L13 - L14 were not covered by tests
}

func registerCommands(admCommand *cobra.Command) {
admCommand.AddCommand(NewAdminManifestsCmd())
admCommand.AddCommand(NewCliConfigsCmd())

Check warning on line 19 in pkg/cmd/generate/generate.go

View check run for this annotation

Codecov / codecov/patch

pkg/cmd/generate/generate.go#L17-L19

Added lines #L17 - L19 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/adm/setup_util.go → pkg/cmd/generate/util.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adm
package generate

import (
"fmt"
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
Loading