From 9f5220ad2d1490cb6d0404dfdb387fdc57b91144 Mon Sep 17 00:00:00 2001 From: kei6u Date: Fri, 17 Dec 2021 20:45:12 +0900 Subject: [PATCH] early return --- find.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/find.go b/find.go index bfbdd21..dadfa38 100644 --- a/find.go +++ b/find.go @@ -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) {