pull/31302/merge
Terry Howe 1 day ago committed by GitHub
commit f67b52e71a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -28,7 +28,6 @@ import (
// It provides the implementation of 'helm verify'. // It provides the implementation of 'helm verify'.
type Verify struct { type Verify struct {
Keyring string Keyring string
Out string
} }
// NewVerify creates a new Verify object with the given configuration. // NewVerify creates a new Verify object with the given configuration.
@ -37,23 +36,18 @@ func NewVerify() *Verify {
} }
// Run executes 'helm verify'. // Run executes 'helm verify'.
func (v *Verify) Run(chartfile string) error { func (v *Verify) Run(chartfile string) (string, error) {
var out strings.Builder var out strings.Builder
p, err := downloader.VerifyChart(chartfile, chartfile+".prov", v.Keyring) p, err := downloader.VerifyChart(chartfile, chartfile+".prov", v.Keyring)
if err != nil { if err != nil {
return err return "", err
} }
for name := range p.SignedBy.Identities { for name := range p.SignedBy.Identities {
fmt.Fprintf(&out, "Signed by: %v\n", name) _, _ = fmt.Fprintf(&out, "Signed by: %v\n", name)
} }
fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", p.SignedBy.PrimaryKey.Fingerprint) _, _ = fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", p.SignedBy.PrimaryKey.Fingerprint)
fmt.Fprintf(&out, "Chart Hash Verified: %s\n", p.FileHash) _, _ = fmt.Fprintf(&out, "Chart Hash Verified: %s\n", p.FileHash)
// TODO(mattfarina): The output is set as a property rather than returned return out.String(), err
// to maintain the Go API. In Helm v4 this function should return the out
// and the property on the struct can be removed.
v.Out = out.String()
return nil
} }

@ -53,12 +53,12 @@ func newVerifyCmd(out io.Writer) *cobra.Command {
return noMoreArgsComp() return noMoreArgsComp()
}, },
RunE: func(_ *cobra.Command, args []string) error { RunE: func(_ *cobra.Command, args []string) error {
err := client.Run(args[0]) result, err := client.Run(args[0])
if err != nil { if err != nil {
return err return err
} }
fmt.Fprint(out, client.Out) fmt.Fprint(out, result)
return nil return nil
}, },

Loading…
Cancel
Save