Skip to content

Commit

Permalink
modififying GetPackage()/GetPackages()
Browse files Browse the repository at this point in the history
Adding new fields:
- Auto (bool type) will come from the new package.yaml
- AutoGeneratedBumpVersion that will be calculated at the end of the process

Also Fixed GetGithubRepository branch variable which was not being used
  • Loading branch information
nicholasSUSE committed Nov 5, 2024
1 parent 98ac6fc commit 5b3b386
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions pkg/charts/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {

Check failure on line 67 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / build

p.Chart.UpstreamChartVersion undefined (type Chart has no field or method UpstreamChartVersion, but does have field upstreamChartVersion)

Check failure on line 67 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / lint

p.Chart.UpstreamChartVersion undefined (type Chart has no field or method UpstreamChartVersion, but does have field upstreamChartVersion)

Check failure on line 67 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / lint

p.Chart.UpstreamChartVersion undefined (type Chart has no field or method UpstreamChartVersion, but does have field upstreamChartVersion)

Check failure on line 67 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / test

p.Chart.UpstreamChartVersion undefined (type Chart has no field or method UpstreamChartVersion, but does have field upstreamChartVersion)
return fmt.Errorf("encountered error while preparing additional chart %s: %s", additionalChart.WorkingDir, err)
}
if err := additionalChart.ApplyMainChanges(p.fs); err != nil {
Expand Down Expand Up @@ -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)

Check failure on line 143 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / build

too many arguments in call to p.Chart.GenerateChart

Check failure on line 143 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / lint

too many arguments in call to p.Chart.GenerateChart

Check failure on line 143 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / lint

too many arguments in call to p.Chart.GenerateChart

Check failure on line 143 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / test

too many arguments in call to p.Chart.GenerateChart
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)

Check failure on line 148 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / build

too many arguments in call to additionalChart.GenerateChart

Check failure on line 148 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / lint

too many arguments in call to additionalChart.GenerateChart

Check failure on line 148 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / lint

too many arguments in call to additionalChart.GenerateChart

Check failure on line 148 in pkg/charts/package.go

View workflow job for this annotation

GitHub Actions / test

too many arguments in call to additionalChart.GenerateChart
if err != nil {
return fmt.Errorf("encountered error while exporting %s: %s", additionalChart.WorkingDir, err)
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/charts/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -134,6 +135,7 @@ func GetPackage(rootFs billy.Filesystem, name string) (*Package, error) {
PackageVersion: packageOpt.PackageVersion,
AdditionalCharts: additionalCharts,
DoNotRelease: packageOpt.DoNotRelease,
Auto: packageOpt.Auto,

Check failure on line 138 in pkg/charts/parse.go

View workflow job for this annotation

GitHub Actions / build

packageOpt.Auto undefined (type options.PackageOptions has no field or method Auto)

Check failure on line 138 in pkg/charts/parse.go

View workflow job for this annotation

GitHub Actions / lint

packageOpt.Auto undefined (type options.PackageOptions has no field or method Auto)

Check failure on line 138 in pkg/charts/parse.go

View workflow job for this annotation

GitHub Actions / lint

packageOpt.Auto undefined (type options.PackageOptions has no field or method Auto)

Check failure on line 138 in pkg/charts/parse.go

View workflow job for this annotation

GitHub Actions / test

packageOpt.Auto undefined (type options.PackageOptions has no field or method Auto)

fs: pkgFs,
rootFs: rootFs,
Expand Down Expand Up @@ -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)

Check failure on line 243 in pkg/charts/parse.go

View workflow job for this annotation

GitHub Actions / build

opt.ChartRepoBranch undefined (type options.UpstreamOptions has no field or method ChartRepoBranch)

Check failure on line 243 in pkg/charts/parse.go

View workflow job for this annotation

GitHub Actions / lint

opt.ChartRepoBranch undefined (type options.UpstreamOptions has no field or method ChartRepoBranch) (typecheck)

Check failure on line 243 in pkg/charts/parse.go

View workflow job for this annotation

GitHub Actions / test

opt.ChartRepoBranch undefined (type options.UpstreamOptions has no field or method ChartRepoBranch)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 5b3b386

Please sign in to comment.