Skip to content

Commit

Permalink
early return
Browse files Browse the repository at this point in the history
  • Loading branch information
keisku committed Dec 17, 2021
1 parent 0d1b66a commit 9f5220a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions find.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ func run(ctx context.Context, name string, opt options) error {
if err != nil {
return err
}
if opt.Regex != "" {
secrets := make([]v1.Secret, 0, len(ss))
for _, s := range ss {
match, err := regexp.MatchString(opt.Regex, s.Name)
if err != nil {
return err
}
if match {
secrets = append(secrets, s)
}
if opt.Regex == "" {
return printSecrets(ss, opt.Output)
}
secrets := make([]v1.Secret, 0, len(ss))
for _, s := range ss {
match, err := regexp.MatchString(opt.Regex, s.Name)
if err != nil {
return err
}
if match {
secrets = append(secrets, s)
}
return printSecrets(secrets, opt.Output)
}
return printSecrets(ss, opt.Output)
return printSecrets(secrets, opt.Output)
}

func findSecrets(ctx context.Context, name string, opt options) ([]v1.Secret, error) {
Expand Down

0 comments on commit 9f5220a

Please sign in to comment.