-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,567 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
.vscode | ||
*.iml | ||
.idea/ | ||
.vscode/ | ||
dist/** | ||
main.exe | ||
coverage.txt | ||
coverage.* | ||
build/ | ||
kor | ||
!kor/ | ||
*.swp | ||
hack/exceptions | ||
.envrc |
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
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,50 @@ | ||
package kor | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/yonahd/kor/pkg/kor" | ||
"github.com/yonahd/kor/pkg/utils" | ||
) | ||
|
||
var namespaceCmd = &cobra.Command{ | ||
Use: "namespace", | ||
Aliases: []string{"ns", "namespaces"}, | ||
Short: "Gets unused namespaces", | ||
Args: cobra.ExactArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
ctx := context.Background() | ||
clientset := kor.GetKubeClient(kubeconfig) | ||
dynamicClient := kor.GetDynamicClient(kubeconfig) | ||
|
||
if response, err := kor.GetUnusedNamespaces( | ||
ctx, | ||
filterOptions, | ||
clientset, | ||
dynamicClient, | ||
outputFormat, | ||
opts, | ||
); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
utils.PrintLogo(outputFormat) | ||
fmt.Println(response) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
namespaceCmd.PersistentFlags().StringSliceVarP( | ||
&filterOptions.IgnoreResourceTypes, | ||
"ignore-resource-types", | ||
"i", | ||
filterOptions.IgnoreResourceTypes, | ||
"Child resource type selector to filter out from namespace emptiness evaluation,"+ | ||
" example: --ignore-resource-types secrets,configmaps."+ | ||
" Types should be specified in a format printed out in NAME column by 'kubectl api-resources --namespaced=true'.", | ||
) | ||
rootCmd.AddCommand(namespaceCmd) | ||
} |
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
Oops, something went wrong.