@ -17,6 +17,9 @@ limitations under the License.
package action
package action
import (
import (
"fmt"
"strings"
"helm.sh/helm/v3/pkg/downloader"
"helm.sh/helm/v3/pkg/downloader"
)
)
@ -25,6 +28,7 @@ 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.
@ -34,6 +38,22 @@ func NewVerify() *Verify {
// Run executes 'helm verify'.
// Run executes 'helm verify'.
func ( v * Verify ) Run ( chartfile string ) error {
func ( v * Verify ) Run ( chartfile string ) error {
_ , err := downloader . VerifyChart ( chartfile , v . Keyring )
var out strings . Builder
return err
p , err := downloader . VerifyChart ( chartfile , v . Keyring )
if err != nil {
return err
}
for name := range p . SignedBy . Identities {
fmt . Fprintf ( & out , "Signed by: %v\n" , name )
}
fmt . Fprintf ( & out , "Using Key With Fingerprint: %X\n" , p . SignedBy . PrimaryKey . Fingerprint )
fmt . Fprintf ( & out , "Chart Hash Verified: %s\n" , p . FileHash )
// TODO(mattfarina): The output is set as a property rather than returned
// 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
}
}