use fmt pkg for Errorf calls in chartfile.go

Signed-off-by: James Sheppard <jgsheppa@protonmail.com>
pull/12063/head
James Sheppard 2 years ago
parent f0f25656d2
commit 357b867046

@ -17,10 +17,10 @@ limitations under the License.
package chartutil package chartutil
import ( import (
"fmt"
"os" "os"
"path/filepath" "path/filepath"
"github.com/pkg/errors"
"sigs.k8s.io/yaml" "sigs.k8s.io/yaml"
"helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chart"
@ -64,17 +64,17 @@ func IsChartDir(dirName string) (bool, error) {
if fi, err := os.Stat(dirName); err != nil { if fi, err := os.Stat(dirName); err != nil {
return false, err return false, err
} else if !fi.IsDir() { } else if !fi.IsDir() {
return false, errors.Errorf("%q is not a directory", dirName) return false, fmt.Errorf("%q is not a directory", dirName)
} }
chartYaml := filepath.Join(dirName, ChartfileName) chartYaml := filepath.Join(dirName, ChartfileName)
if _, err := os.Stat(chartYaml); os.IsNotExist(err) { if _, err := os.Stat(chartYaml); os.IsNotExist(err) {
return false, errors.Errorf("no %s exists in directory %q", ChartfileName, dirName) return false, fmt.Errorf("no %s exists in directory %q", ChartfileName, dirName)
} }
chartYamlContent, err := os.ReadFile(chartYaml) chartYamlContent, err := os.ReadFile(chartYaml)
if err != nil { if err != nil {
return false, errors.Errorf("cannot read %s in directory %q", ChartfileName, dirName) return false, fmt.Errorf("cannot read %s in directory %q", ChartfileName, dirName)
} }
chartContent := new(chart.Metadata) chartContent := new(chart.Metadata)
@ -82,10 +82,10 @@ func IsChartDir(dirName string) (bool, error) {
return false, err return false, err
} }
if chartContent == nil { if chartContent == nil {
return false, errors.Errorf("chart metadata (%s) missing", ChartfileName) return false, fmt.Errorf("chart metadata (%s) missing", ChartfileName)
} }
if chartContent.Name == "" { if chartContent.Name == "" {
return false, errors.Errorf("invalid chart (%s): name must not be empty", ChartfileName) return false, fmt.Errorf("invalid chart (%s): name must not be empty", ChartfileName)
} }
return true, nil return true, nil

Loading…
Cancel
Save