Skip to content

Commit

Permalink
handling renamed (removed prefix) chart directory (#2346)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreygolden committed Nov 18, 2021
1 parent 691d543 commit c41b97b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 11 additions & 3 deletions pkg/pull/pull.go
Expand Up @@ -424,11 +424,19 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
// for writing Common Midstream, every chart and subchart is in this map as Helm Midstreams will be processed later in the code
commonWriteMidstreamOptions.UseHelmInstall = map[string]bool{}
for _, v := range newHelmCharts {
commonWriteMidstreamOptions.UseHelmInstall[v.Spec.Chart.Name] = v.Spec.UseHelmInstall
chartBaseName := v.Spec.Chart.Name
// the helmBase may have a chart name prefix removed - we must find the base name instead of the original chart name
for _, helmBase := range helmBases {
chartName := strings.Split(helmBase.Path, "/")[len(strings.Split(helmBase.Path, "/"))-1]
if strings.HasSuffix(v.Spec.Chart.Name, chartName) {
chartBaseName = chartName
}
}
commonWriteMidstreamOptions.UseHelmInstall[chartBaseName] = v.Spec.UseHelmInstall
if v.Spec.UseHelmInstall {
subcharts, err := base.FindHelmSubChartsFromBase(writeBaseOptions.BaseDir, v.Spec.Chart.Name)
subcharts, err := base.FindHelmSubChartsFromBase(writeBaseOptions.BaseDir, chartBaseName)
if err != nil {
return "", errors.Wrapf(err, "failed to find subcharts for parent chart %s", v.Spec.Chart.Name)
return "", errors.Wrapf(err, "failed to find subcharts for parent chart %s", chartBaseName)
}
for _, subchart := range subcharts.SubCharts {
commonWriteMidstreamOptions.UseHelmInstall[subchart] = v.Spec.UseHelmInstall
Expand Down
14 changes: 11 additions & 3 deletions pkg/rewrite/rewrite.go
Expand Up @@ -229,11 +229,19 @@ func Rewrite(rewriteOptions RewriteOptions) error {
// for writing Common Midstream, every chart and subchart is in this map as Helm Midstreams will be processed later in the code
commonWriteMidstreamOptions.UseHelmInstall = map[string]bool{}
for _, v := range newHelmCharts {
commonWriteMidstreamOptions.UseHelmInstall[v.Spec.Chart.Name] = v.Spec.UseHelmInstall
chartBaseName := v.Spec.Chart.Name
// the helmBase may have a chart name prefix removed - we must find the base name instead of the original chart name
for _, helmBase := range helmBases {
chartName := strings.Split(helmBase.Path, "/")[len(strings.Split(helmBase.Path, "/"))-1]
if strings.HasSuffix(chartBaseName, chartName) {
chartBaseName = chartName
}
}
commonWriteMidstreamOptions.UseHelmInstall[chartBaseName] = v.Spec.UseHelmInstall
if v.Spec.UseHelmInstall {
subcharts, err := base.FindHelmSubChartsFromBase(writeBaseOptions.BaseDir, v.Spec.Chart.Name)
subcharts, err := base.FindHelmSubChartsFromBase(writeBaseOptions.BaseDir, chartBaseName)
if err != nil {
return errors.Wrapf(err, "failed to find subcharts for parent chart %s", v.Spec.Chart.Name)
return errors.Wrapf(err, "failed to find subcharts for parent chart %s", chartBaseName)
}
for _, subchart := range subcharts.SubCharts {
commonWriteMidstreamOptions.UseHelmInstall[subchart] = v.Spec.UseHelmInstall
Expand Down

0 comments on commit c41b97b

Please sign in to comment.