From 2f45720f1ef48c7c1d3c4bf99daaceef017732c8 Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Fri, 5 Nov 2021 13:27:00 +0100 Subject: [PATCH] fix: return correct not signed in error --- template.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/template.go b/template.go index 0ebf0c0..d751110 100644 --- a/template.go +++ b/template.go @@ -195,6 +195,8 @@ func onePassword(ctx context.Context, templateVars interface{}, errorOnMissing b } else { onePasswordCache[cacheKey] = res } + } else if err != nil { + return "", err } else { onePasswordCache[cacheKey] = res } @@ -226,10 +228,10 @@ func onePasswordGet(ctx context.Context, uuid string) (map[string]string, error) } `json:"fields"` } `json:"details"` } - if res, err := exec.CommandContext(ctx, "op", "--cache", "get", "item", uuid).CombinedOutput(); err != nil { - return nil, err - } else if strings.Contains(string(res), "You are not currently signed in") { + if res, err := exec.CommandContext(ctx, "op", "--cache", "get", "item", uuid).CombinedOutput(); err != nil && strings.Contains(string(res), "You are not currently signed in") { return nil, ErrOnePasswordNotSignedIn + } else if err != nil { + return nil, err } else if err := json.Unmarshal(res, &v); err != nil { return nil, err } else {