...

Source file src/helm.sh/helm/v3/pkg/action/verify.go

Documentation: helm.sh/helm/v3/pkg/action

     1  /*
     2  Copyright The Helm Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package action
    18  
    19  import (
    20  	"fmt"
    21  	"strings"
    22  
    23  	"helm.sh/helm/v3/pkg/downloader"
    24  )
    25  
    26  // Verify is the action for building a given chart's Verify tree.
    27  //
    28  // It provides the implementation of 'helm verify'.
    29  type Verify struct {
    30  	Keyring string
    31  	Out     string
    32  }
    33  
    34  // NewVerify creates a new Verify object with the given configuration.
    35  func NewVerify() *Verify {
    36  	return &Verify{}
    37  }
    38  
    39  // Run executes 'helm verify'.
    40  func (v *Verify) Run(chartfile string) error {
    41  	var out strings.Builder
    42  	p, err := downloader.VerifyChart(chartfile, v.Keyring)
    43  	if err != nil {
    44  		return err
    45  	}
    46  
    47  	for name := range p.SignedBy.Identities {
    48  		fmt.Fprintf(&out, "Signed by: %v\n", name)
    49  	}
    50  	fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", p.SignedBy.PrimaryKey.Fingerprint)
    51  	fmt.Fprintf(&out, "Chart Hash Verified: %s\n", p.FileHash)
    52  
    53  	// TODO(mattfarina): The output is set as a property rather than returned
    54  	// to maintain the Go API. In Helm v4 this function should return the out
    55  	// and the property on the struct can be removed.
    56  	v.Out = out.String()
    57  
    58  	return nil
    59  }
    60  

View as plain text