Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions pkg/helm/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math"
"os"
"path/filepath"
"strings"

"github.com/blang/semver"
"github.com/go-git/go-billy/v5"
Expand All @@ -30,6 +31,10 @@ var (
// helmChartPath is a relative path (rooted at the package level) that contains the chart.
func ExportHelmChart(rootFs, fs billy.Filesystem, helmChartPath string, packageVersion *int, version *semver.Version, autoGenBumpVersion *semver.Version, upstreamChartVersion string, omitBuildMetadata bool) error {

if err := removeOrigFiles(filesystem.GetAbsPath(fs, helmChartPath)); err != nil {
return fmt.Errorf("failed to remove .orig files: %s", err)
}

chart, err := loadHelmChart(fs, helmChartPath)
if err != nil {
return err
Expand Down Expand Up @@ -65,6 +70,23 @@ func ExportHelmChart(rootFs, fs billy.Filesystem, helmChartPath string, packageV
return nil
}

// removeOrigFiles removes all files ending with .orig in the specified directory
func removeOrigFiles(dir string) error {
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() && strings.HasSuffix(info.Name(), ".orig") {
if err := os.Remove(path); err != nil {
return err
}
logrus.Infof("Removed file: %s", path)
}
return nil
})
return err
}

func loadHelmChart(fs billy.Filesystem, helmChartPath string) (*chart.Chart, error) {
// Try to load the chart to see if it can be exported
absHelmChartPath := filesystem.GetAbsPath(fs, helmChartPath)
Expand Down
Loading