From b5b6aecbd1dbe8bfab314a4e9974f2c2cd4bf768 Mon Sep 17 00:00:00 2001 From: nicholasSSUSE Date: Mon, 4 Nov 2024 23:20:12 -0300 Subject: [PATCH] modififying GetPackage()/GetPackages() Adding new fields: - Auto (bool type) will come from the new package.yaml --- pkg/charts/package.go | 11 ++++++++--- pkg/charts/parse.go | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/charts/package.go b/pkg/charts/package.go index dff648d1..6dd8e4c9 100644 --- a/pkg/charts/package.go +++ b/pkg/charts/package.go @@ -30,6 +30,11 @@ type Package struct { AdditionalCharts []*AdditionalChart `yaml:"additionalCharts,omitempty"` // DoNotRelease represents a boolean flag that indicates a package should not be tracked in make charts DoNotRelease bool `yaml:"doNotRelease,omitempty"` + // Auto triggers the auto chart bump + Auto bool `yaml:"auto,omitempty"` + // AutoGeneratedBumpVersion is the version that the package should be bumped to + // If present, this will override all other versions + AutoGeneratedBumpVersion *semver.Version // fs is a filesystem rooted at the package fs billy.Filesystem @@ -59,7 +64,7 @@ func (p *Package) Prepare() error { } } for _, additionalChart := range p.AdditionalCharts { - if err := additionalChart.Prepare(p.rootFs, p.fs, p.Chart.upstreamChartVersion); err != nil { + if err := additionalChart.Prepare(p.rootFs, p.fs, p.Chart.UpstreamChartVersion); err != nil { return fmt.Errorf("encountered error while preparing additional chart %s: %s", additionalChart.WorkingDir, err) } if err := additionalChart.ApplyMainChanges(p.fs); err != nil { @@ -135,12 +140,12 @@ func (p *Package) GenerateCharts(omitBuildMetadataOnExport bool) error { return fmt.Errorf("encountered error while trying to prepare package: %s", err) } // Add PackageVersion to format - err := p.Chart.GenerateChart(p.rootFs, p.fs, p.PackageVersion, p.Version, omitBuildMetadataOnExport) + err := p.Chart.GenerateChart(p.rootFs, p.fs, p.PackageVersion, p.Version, p.AutoGeneratedBumpVersion, omitBuildMetadataOnExport) if err != nil { return fmt.Errorf("encountered error while exporting main chart: %s", err) } for _, additionalChart := range p.AdditionalCharts { - err = additionalChart.GenerateChart(p.rootFs, p.fs, p.PackageVersion, p.Version, omitBuildMetadataOnExport) + err = additionalChart.GenerateChart(p.rootFs, p.fs, p.PackageVersion, p.Version, p.AutoGeneratedBumpVersion, omitBuildMetadataOnExport) if err != nil { return fmt.Errorf("encountered error while exporting %s: %s", additionalChart.WorkingDir, err) } diff --git a/pkg/charts/parse.go b/pkg/charts/parse.go index 4391688d..cc451335 100644 --- a/pkg/charts/parse.go +++ b/pkg/charts/parse.go @@ -16,7 +16,7 @@ import ( ) // GetPackages returns all packages found within the repository. If there is a specific package provided, it will return just that Package in the list -func GetPackages(repoRoot string, specificPackage string) ([]*Package, error) { +func GetPackages(repoRoot, specificPackage string) ([]*Package, error) { var packageList []string var err error @@ -100,6 +100,7 @@ func GetPackage(rootFs billy.Filesystem, name string) (*Package, error) { if err != nil { return nil, err } + // version and packageVersion can not exist at the same time although both are optional if packageOpt.Version != nil && packageOpt.PackageVersion != nil { return nil, fmt.Errorf("cannot have both version and packageVersion at the same time") @@ -134,6 +135,7 @@ func GetPackage(rootFs billy.Filesystem, name string) (*Package, error) { PackageVersion: packageOpt.PackageVersion, AdditionalCharts: additionalCharts, DoNotRelease: packageOpt.DoNotRelease, + Auto: packageOpt.Auto, fs: pkgFs, rootFs: rootFs, @@ -238,7 +240,7 @@ func GetUpstream(opt options.UpstreamOptions) (puller.Puller, error) { return upstream, nil } if strings.HasSuffix(opt.URL, ".git") { - upstream, err := puller.GetGithubRepository(opt, nil) + upstream, err := puller.GetGithubRepository(opt, opt.ChartRepoBranch) if err != nil { return nil, err }