Skip to content

Commit

Permalink
removed flags
Browse files Browse the repository at this point in the history
  • Loading branch information
pghildiyal committed Aug 24, 2021
1 parent b1a7c36 commit 038bc6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ var RootCmd = &cobra.Command{
if len(args) > 0 || len(directories) > 0 {
success = processFiles(args)
} else {
processCluster()
success = processCluster()
}

if !success {
os.Exit(1)
}
Expand Down Expand Up @@ -249,6 +248,9 @@ func removeIgnoredKeys(results []pkg.ValidationResult) []pkg.ValidationResult {
// contain errors.
func hasErrors(res []pkg.ValidationResult) bool {
for _, r := range res {
if r.Deleted || r.Deprecated {
return true
}
if len(r.ErrorsForOriginal) > 0 || len(r.ErrorsForLatest) > 0 {
return true
}
Expand Down Expand Up @@ -329,8 +331,8 @@ func init() {

viper.SetEnvPrefix("KUBEADD")
viper.AutomaticEnv()
viper.BindPFlag("schema_location", RootCmd.Flags().Lookup("schema-location"))
viper.BindPFlag("filename", RootCmd.Flags().Lookup("filename"))
//viper.BindPFlag("schema_location", RootCmd.Flags().Lookup("schema-location"))
//viper.BindPFlag("filename", RootCmd.Flags().Lookup("filename"))
}

func main() {
Expand Down
17 changes: 8 additions & 9 deletions pkg/Config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package pkg

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

Expand Down Expand Up @@ -111,18 +110,18 @@ func NewDefaultConfig() *Config {

// AddKubeaddFlags adds the default flags for kubedd to cmd
func AddKubeaddFlags(cmd *cobra.Command, config *Config) *cobra.Command {
cmd.Flags().StringVarP(&config.FileName, "filename", "f", "stdin", "filename to be displayed when testing manifests read from stdin")
cmd.Flags().StringVarP(&config.TargetSchemaLocation, "target-schema-location", "", "", "TargetSchemaLocation is the base URL of target kubernetes version.")
cmd.Flags().StringVarP(&config.SourceSchemaLocation, "source-schema-location", "", "", "SourceSchemaLocation is the base URL of source kubernetes versions.")
cmd.Flags().StringVarP(&config.TargetKubernetesVersion, "target-kubernetes-version", "", "1.22", "Version of Kubernetes to migrate to")
cmd.Flags().StringVarP(&config.SourceKubernetesVersion, "source-kubernetes-version", "", "", "Version of Kubernetes on which kubernetes objects are deployed currently, ignored in case cluster is provided")
cmd.Flags().StringVarP(&config.OutputFormat, "output", "o", "", fmt.Sprintf("The format of the output of this script. Options are: %v", validOutputs()))
cmd.Flags().BoolVar(&config.Quiet, "quiet", false, "Silences any output aside from the direct results")
//cmd.Flags().StringVarP(&config.FileName, "filename", "f", "stdin", "Filename to be displayed when testing manifests read from stdin")
cmd.Flags().StringVarP(&config.TargetSchemaLocation, "target-schema-location", "", "", "TargetSchemaLocation is the file path of kubernetes version of the target cluster for these manifests. Use this in air-gapped environment where it internet access is unavailable.")
cmd.Flags().StringVarP(&config.SourceSchemaLocation, "source-schema-location", "", "", "SourceSchemaLocation is the file path of kubernetes versions of the cluster on which manifests are deployed. Use this in air-gapped environment where it internet access is unavailable.")
cmd.Flags().StringVarP(&config.TargetKubernetesVersion, "target-kubernetes-version", "", "1.22", "Version of Kubernetes to migrate to eg 1.22, 1.21, 1.12")
cmd.Flags().StringVarP(&config.SourceKubernetesVersion, "source-kubernetes-version", "", "", "Version of Kubernetes of the cluster on which kubernetes objects are deployed currently, ignored in case cluster is provided. In case of directory defaults to same as target-kubernetes-version.")
//cmd.Flags().StringVarP(&config.OutputFormat, "output", "o", "", fmt.Sprintf("The format of the output of this script. Options are: %v", "stdOut"))
//cmd.Flags().BoolVar(&config.Quiet, "quiet", false, "Silences any output aside from the direct results")
cmd.Flags().BoolVar(&config.InsecureSkipTLSVerify, "insecure-skip-tls-verify", false, "If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure")
cmd.Flags().StringSliceVarP(&config.SelectNamespaces, "select-namespaces", "", []string{}, "A comma-separated list of namespaces to be selected, if left empty all namespaces are selected")
cmd.Flags().StringSliceVarP(&config.IgnoreNamespaces, "ignore-namespaces", "", []string{"kube-system"}, "A comma-separated list of namespaces to be skipped")
cmd.Flags().StringSliceVarP(&config.IgnoreKinds, "ignore-kinds", "", []string{"event","CustomResourceDefinition"}, "A comma-separated list of kinds to be skipped")
cmd.Flags().StringSliceVarP(&config.SelectKinds, "select-kinds", "", []string{}, "A comma-separated list of kinds to be selected, if left empty all namespaces are selected")
cmd.Flags().StringSliceVarP(&config.SelectKinds, "select-kinds", "", []string{}, "A comma-separated list of kinds to be selected, if left empty all kinds are selected")
cmd.Flags().StringSliceVarP(&config.IgnoreKeysFromDeprecation, "ignore-keys-for-deprecation", "", []string{"metadata*", "status*"}, "A comma-separated list of keys to be ignored for depreciation check")
cmd.Flags().StringSliceVarP(&config.IgnoreKeysFromValidation, "ignore-keys-for-validation", "", []string{"status*", "metadata*"}, "A comma-separated list of keys to be ignored for validation check")
cmd.Flags().BoolVar(&config.IgnoreNullErrors, "ignore-null-errors", true, "Ignore null value errors")
Expand Down

0 comments on commit 038bc6b

Please sign in to comment.