Skip to content

Commit

Permalink
Merge pull request #228 from shay1760/enhance
Browse files Browse the repository at this point in the history
enhancement: add sample example in the commands
  • Loading branch information
subhamkrai authored Jan 24, 2024
2 parents b1e9c5f + 1ebed93 commit a519901
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 20 deletions.
14 changes: 8 additions & 6 deletions cmd/commands/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ var DebugCmd = &cobra.Command{
}

var startDebugCmd = &cobra.Command{
Use: "start",
Short: "Start debugging a deployment with an optional alternative ceph container image",
Args: cobra.ExactArgs(1),
Use: "start",
Short: "Start debugging a deployment with an optional alternative ceph container image",
Args: cobra.ExactArgs(1),
Example: "kubectl rook-ceph debug start <deployment_name>",
Run: func(cmd *cobra.Command, args []string) {
alternateImage := cmd.Flag("alternate-image").Value.String()
debug.StartDebug(cmd.Context(), clientSets.Kube, cephClusterNamespace, args[0], alternateImage)
},
}

var stopDebugCmd = &cobra.Command{
Use: "stop",
Short: "Stop debugging a deployment",
Args: cobra.ExactArgs(1),
Use: "stop",
Short: "Stop debugging a deployment",
Args: cobra.ExactArgs(1),
Example: "kubectl rook-ceph debug stop <deployment_name>",
Run: func(cmd *cobra.Command, args []string) {
debug.StopDebug(cmd.Context(), clientSets.Kube, cephClusterNamespace, args[0])
},
Expand Down
1 change: 1 addition & 0 deletions cmd/commands/dr_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var healthCmd = &cobra.Command{
Short: "Print the ceph status of a peer cluster in a mirroring-enabled cluster.",
DisableFlagParsing: true,
Args: cobra.MaximumNArgs(2),
Example: "rook-ceph dr health [Arg]",
Run: func(cmd *cobra.Command, args []string) {
dr.Health(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, args)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/commands/mons.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var RestoreQuorum = &cobra.Command{
Short: "When quorum is lost, restore quorum to the remaining healthy mon",
DisableFlagParsing: true,
Args: cobra.ExactArgs(1),
Example: "kubectl rook-ceph mons restore-quorum <Mon_ID>",
Run: func(cmd *cobra.Command, args []string) {
mons.RestoreQuorum(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, args[0])
},
Expand Down
7 changes: 4 additions & 3 deletions cmd/commands/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ var restartCmd = &cobra.Command{
}

var setCmd = &cobra.Command{
Use: "set",
Short: "Set the property in the rook-ceph-operator-config configmap.",
Args: cobra.ExactArgs(2),
Use: "set",
Short: "Set the property in the rook-ceph-operator-config configmap.",
Example: "kubectl rook-ceph operator set <KEY> <VALUE>",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
k8sutil.UpdateConfigMap(cmd.Context(), clientSets.Kube, operatorNamespace, "rook-ceph-operator-config", args[0], args[1])
},
Expand Down
7 changes: 4 additions & 3 deletions cmd/commands/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import (

// RestoreCmd represents the restore commands
var RestoreCmd = &cobra.Command{
Use: "restore-deleted",
Short: "Restores a CR that was accidentally deleted and is still in terminating state. Ex: restore cephcluster <my-cluster>",
Args: cobra.MinimumNArgs(1),
Use: "restore-deleted",
Short: "Restores a CR that was accidentally deleted and is still in terminating state.",
Args: cobra.RangeArgs(1, 2),
Example: "kubectl rook-ceph restore-deleted <CRD> [CR_Name]",
PreRun: func(cmd *cobra.Command, args []string) {
verifyOperatorPodIsRunning(cmd.Context(), clientSets)
},
Expand Down
11 changes: 6 additions & 5 deletions cmd/commands/rook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
"github.com/spf13/cobra"
)

var json bool

// RookCmd represents the rook commands
var RookCmd = &cobra.Command{
Use: "rook",
Expand All @@ -49,6 +47,7 @@ var purgeCmd = &cobra.Command{
Short: "Permanently remove an OSD from the cluster. Multiple OSDs can be removed with a comma-separated list of IDs, for example, purge-osd 0,1",
PreRunE: validateOsdID,
Args: cobra.ExactArgs(1),
Example: "kubectl rook-ceph rook purge-osd <OSD_ID>",
PreRun: func(cmd *cobra.Command, args []string) {
verifyOperatorPodIsRunning(cmd.Context(), clientSets)
},
Expand All @@ -60,8 +59,10 @@ var purgeCmd = &cobra.Command{
}

var statusCmd = &cobra.Command{
Use: "status",
Short: "Print the phase and conditions of the CephCluster CR",
Use: "status",
Short: "Print the phase and conditions of the CephCluster CR",
Args: cobra.MaximumNArgs(1),
Example: "kubectl rook-ceph rook status [CR_Name]",
Run: func(cmd *cobra.Command, args []string) {
json := cmd.Flag("json").Value.String()
jsonValue, err := strconv.ParseBool(json)
Expand All @@ -84,7 +85,7 @@ func validateOsdID(cmd *cobra.Command, args []string) error {
osdID := args[0]
_, err := strconv.Atoi(osdID)
if err != nil {
return fmt.Errorf("Invalid ID %s, the OSD ID must be an integer. %v", osdID, err)
return fmt.Errorf("invalid ID %s, the OSD ID must be an integer. %v", osdID, err)
}

return nil
Expand Down
7 changes: 4 additions & 3 deletions cmd/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package command
import (
"context"
"fmt"
"k8s.io/client-go/dynamic"
"regexp"
"strings"

"k8s.io/client-go/dynamic"

"github.com/rook/kubectl-rook-ceph/pkg/exec"
"github.com/rook/kubectl-rook-ceph/pkg/k8sutil"
"github.com/rook/kubectl-rook-ceph/pkg/logging"
Expand Down Expand Up @@ -113,11 +114,11 @@ func getClientsets(ctx context.Context) *k8sutil.Clientsets {
func preValidationCheck(ctx context.Context, k8sclientset *k8sutil.Clientsets) {
_, err := k8sclientset.Kube.CoreV1().Namespaces().Get(ctx, operatorNamespace, v1.GetOptions{})
if err != nil {
logging.Fatal(fmt.Errorf("Operator namespace '%s' does not exist. %v", operatorNamespace, err))
logging.Fatal(fmt.Errorf("operator namespace '%s' does not exist. %v", operatorNamespace, err))
}
_, err = k8sclientset.Kube.CoreV1().Namespaces().Get(ctx, cephClusterNamespace, v1.GetOptions{})
if err != nil {
logging.Fatal(fmt.Errorf("CephCluster namespace '%s' does not exist. %v", cephClusterNamespace, err))
logging.Fatal(fmt.Errorf("cephCluster namespace '%s' does not exist. %v", cephClusterNamespace, err))
}
}

Expand Down
1 change: 1 addition & 0 deletions cmd/commands/subvolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var deleteCmd = &cobra.Command{
Short: "Deletes a stale subvolume.",
DisableFlagParsing: true,
Args: cobra.ExactArgs(3),
Example: "kubectl rook-ceph delete <subvolumes> <filesystem> <subvolumegroup>",
Run: func(cmd *cobra.Command, args []string) {
ctx := cmd.Context()
subList := args[0]
Expand Down

0 comments on commit a519901

Please sign in to comment.