Skip to content

Commit

Permalink
always output b64sig, only output to one place
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Sanders <[email protected]>
  • Loading branch information
Jake Sanders committed Nov 22, 2021
1 parent 2b302b9 commit d986e3c
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions cmd/cosign/cli/sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,20 @@ func signDigest(ctx context.Context, digest name.Digest, payload []byte, ko KeyO
}
b64sig := base64.StdEncoding.EncodeToString(signature)

if !upload {
fmt.Println(b64sig)
return nil
}

out := os.Stdout
if output != "" {
f, err := os.Create(output)
out, err = os.Create(output)
if err != nil {
return errors.Wrap(err, "create signature file")
}
defer f.Close()
_, err = f.Write([]byte(b64sig))

if err != nil {
return errors.Wrap(err, "write signature to file")
}
defer out.Close()
}
if _, err := out.Write([]byte(b64sig)); err != nil {
return errors.Wrap(err, "write signature to file")
}

fmt.Fprintf(os.Stderr, "Signature wrote to the file %s\n", f.Name())
if !upload {
return nil
}

opts := []static.Option{}
Expand Down

0 comments on commit d986e3c

Please sign in to comment.