diff --git a/app.go b/app.go index 4ee6f02..f633aff 100644 --- a/app.go +++ b/app.go @@ -82,8 +82,8 @@ func root() *coral.Command { rootCommand.Flags().StringSliceVar(&opts.ExcludedKinds, "exclude-kind", nil, "resource kind to exclude in the output (singular, case insensitive, glob supported)") rootCommand.Flags().StringSliceVar(&opts.IncludedNames, "include-name", nil, "resource name to include in the output (singular, case insensitive, glob supported)") rootCommand.Flags().StringSliceVar(&opts.ExcludedNames, "exclude-name", nil, "resource name to exclude in the output (singular, case insensitive, glob supported)") - rootCommand.Flags().StringSliceVar(&opts.Included, "include", nil, "resource name to include in the output (format {kind}/${name}, case insensitive, glob supported)") - rootCommand.Flags().StringSliceVar(&opts.Excluded, "exclude", nil, "resource name to exclude in the output (format {kind}/${name}, case insensitive, glob supported)") + rootCommand.Flags().StringSliceVar(&opts.Included, "include", nil, "resource name to include in the output (format /, case insensitive, glob supported)") + rootCommand.Flags().StringSliceVar(&opts.Excluded, "exclude", nil, "resource name to exclude in the output (format /, case insensitive, glob supported)") rootCommand.Flags().BoolVarP(&opts.StrictKubernetes, "skip-non-k8s", "s", false, "if enabled, any YAMLs that don't contain at least an \"apiVersion\", \"kind\" and \"metadata.name\" will be excluded from the split") rootCommand.Flags().BoolVar(&opts.SortByKind, "sort-by-kind", false, "if enabled, resources are sorted by Kind, a la Helm, before saving them to disk") rootCommand.Flags().BoolVar(&opts.OutputToStdout, "stdout", false, "if enabled, no resource is written to disk and all resources are printed to stdout instead") diff --git a/slice/validate.go b/slice/validate.go index 028ca01..78cd9a7 100644 --- a/slice/validate.go +++ b/slice/validate.go @@ -5,7 +5,8 @@ import ( "regexp" ) -const regKN = `^[^/]+/[^/]+$` +var regKN = regexp.MustCompile(`^[^/]+/[^/]+$`) + func (s *Split) init() error { s.log.Printf("Loading file %s", s.opts.InputFile) @@ -65,13 +66,13 @@ func (s *Split) validateFilters() error { // Validate included and excluded filters. for _, included := range s.opts.Included { - if matched, _ := regexp.MatchString(regKN, included); !matched { + if matched := regKN.MatchString(included); !matched { return fmt.Errorf("invalid included pattern %q should be /", included) } } for _, excluded := range s.opts.Excluded { - if matched, _ := regexp.MatchString(regKN, excluded); !matched { + if matched := regKN.MatchString(excluded); !matched { return fmt.Errorf("invalid excluded pattern %q should be /", excluded) } }