Skip to content

Commit

Permalink
refactor(cmd): standardize subcommand aliases with kubectl shortnames (
Browse files Browse the repository at this point in the history
…#300)

* refactor: align kor aliases to kubectl shortnames

* fix: ReplicaSets typo

* docs: use singular form for kor subcommands
  • Loading branch information
doronkg committed Jun 14, 2024
1 parent 1cb3c95 commit 4c3b45d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,24 @@ Kor provides various subcommands to identify and list unused resources. The avai
- `all` - Gets all unused resources for the specified namespace or all namespaces.
- `configmap` - Gets unused ConfigMaps for the specified namespace or all namespaces.
- `secret` - Gets unused Secrets for the specified namespace or all namespaces.
- `services` - Gets unused Services for the specified namespace or all namespaces.
- `service` - Gets unused Services for the specified namespace or all namespaces.
- `serviceaccount` - Gets unused ServiceAccounts for the specified namespace or all namespaces.
- `deployments` - Gets unused Deployments for the specified namespace or all namespaces.
- `statefulsets` - Gets unused StatefulSets for the specified namespace or all namespaces.
- `deployment` - Gets unused Deployments for the specified namespace or all namespaces.
- `statefulset` - Gets unused StatefulSets for the specified namespace or all namespaces.
- `role` - Gets unused Roles for the specified namespace or all namespaces.
- `clusterrole` - Gets unused ClusterRoles for the specified namespace or all namespaces (namespace refers to RoleBinding).
- `hpa` - Gets unused HPAs for the specified namespace or all namespaces.
- `pods` - Gets unused Pods for the specified namespace or all namespaces.
- `pod` - Gets unused Pods for the specified namespace or all namespaces.
- `pvc` - Gets unused PVCs for the specified namespace or all namespaces.
- `pv` - Gets unused PVs in the cluster (non namespaced resource).
- `storageclasses` - Gets unused StorageClasses in the cluster (non namespaced resource).
- `storageclass` - Gets unused StorageClasses in the cluster (non namespaced resource).
- `ingress` - Gets unused Ingresses for the specified namespace or all namespaces.
- `pdb` - Gets unused PDBs for the specified namespace or all namespaces.
- `crd` - Gets unused CRDs in the cluster (non namespaced resource).
- `jobs` - Gets unused jobs for the specified namespace or all namespaces.
- `replicasets` - Gets unused replicaSets for the specified namespace or all namespaces.
- `daemonsets`- Gets unused DaemonSets for the specified namespace or all namespaces.
- `finalizers` - Gets unused pending deletion resources for the specified namespace or all namespaces.
- `job` - Gets unused jobs for the specified namespace or all namespaces.
- `replicaset` - Gets unused replicaSets for the specified namespace or all namespaces.
- `daemonset`- Gets unused DaemonSets for the specified namespace or all namespaces.
- `finalizer` - Gets unused pending deletion resources for the specified namespace or all namespaces.
- `exporter` - Export Prometheus metrics.
- `version` - Print kor version information.

Expand Down Expand Up @@ -217,7 +217,7 @@ Will be cleaned always. This is a good way to mark resources for later cleanup.

### Output Formats

Kor supports three output formats: `table`, `json`, and `yaml`. The default output format is `table`.
Kor supports three output formats: `table`, `json`, and `yaml`. The default output format is `table`.
Additionally, you can use the `--group-by` flag to group the output by `namespace` or `resource`.

#### Group by resource
Expand Down
2 changes: 1 addition & 1 deletion cmd/kor/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var crdCmd = &cobra.Command{
Use: "customresourcedefinition",
Aliases: []string{"crd", "customresourcedefinitions"},
Aliases: []string{"crd", "crds", "customresourcedefinitions"},
Short: "Gets unused crds",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kor/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var jobCmd = &cobra.Command{
Use: "job",
Aliases: []string{"job", "jobs"},
Aliases: []string{"jobs"},
Short: "Gets unused jobs",
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kor/replicasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var replicaSetCmd = &cobra.Command{
Use: "replicaset",
Aliases: []string{"rs", "replicaset", "replicasets"},
Aliases: []string{"rs", "replicasets"},
Short: "Gets unused replicaSets",
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kor/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var secretCmd = &cobra.Command{
Use: "secret",
Aliases: []string{"scrt", "secrets"},
Aliases: []string{"secrets"},
Short: "Gets unused secrets",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kor/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func getUnusedJobs(clientset kubernetes.Interface, namespace string, filterOpts
func getUnusedReplicaSets(clientset kubernetes.Interface, namespace string, filterOpts *filters.Options) ResourceDiff {
replicaSetDiff, err := processNamespaceReplicaSets(clientset, namespace, filterOpts)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to get %s namespace %s: %v\n", "jobs", namespace, err)
fmt.Fprintf(os.Stderr, "Failed to get %s namespace %s: %v\n", "ReplicaSets", namespace, err)
}
namespaceRSDiff := ResourceDiff{
"ReplicaSet",
Expand Down
4 changes: 2 additions & 2 deletions pkg/kor/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func retrieveNoNamespaceDiff(clientset kubernetes.Interface, apiExtClient apiext

for counter, resource := range resourceList {
switch resource {
case "crd", "customresourcedefinition", "customresourcedefinitions":
case "crd", "crds", "customresourcedefinition", "customresourcedefinitions":
crdDiff := getUnusedCrds(apiExtClient, dynamicClient, filterOpts)
noNamespaceDiff = append(noNamespaceDiff, crdDiff)
markedForRemoval[counter] = true
Expand Down Expand Up @@ -60,7 +60,7 @@ func retrieveNamespaceDiffs(clientset kubernetes.Interface, namespace string, re
diffResult = getUnusedCMs(clientset, namespace, filterOpts)
case "svc", "service", "services":
diffResult = getUnusedSVCs(clientset, namespace, filterOpts)
case "scrt", "secret", "secrets":
case "secret", "secrets":
diffResult = getUnusedSecrets(clientset, namespace, filterOpts)
case "sa", "serviceaccount", "serviceaccounts":
diffResult = getUnusedServiceAccounts(clientset, namespace, filterOpts)
Expand Down

0 comments on commit 4c3b45d

Please sign in to comment.