Skip to content

Commit

Permalink
Merge pull request #377 from eclipse-tractusx/fix/helm_render
Browse files Browse the repository at this point in the history
fix: helm chart rendering
  • Loading branch information
tomaszbarwicki authored Dec 13, 2023
2 parents fa74441 + 0b24dcf commit 75e21ac
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions release-automation/internal/helm/resource_mgmt_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ func (r *ResourceMgmt) Test() *tractusx.QualityResult {
}

var errorDescription string
for _, helmchart := range helmCharts {
if !helmchart.IsDir() {
for _, helmChart := range helmCharts {
helmChartPath := path.Join(chartDir, helmChart.Name())
if !helmChart.IsDir() || !IsChartDirectory(helmChartPath) {
continue
}

renderedChartManifests, errDesc := renderChart(path.Join(chartDir, helmchart.Name()))
renderedChartManifests, errDesc := renderChart(helmChartPath)
if renderedChartManifests == nil {
errorDescription += errDesc.Error()
continue
Expand Down Expand Up @@ -145,6 +146,25 @@ func renderChart(chartPath string) (map[string]string, error) {
return nil, errors.New(fmt.Sprintf("\n\tCan't read %s helm chart.", chartPath))
}

subChartsPath := path.Join(chartPath,"charts")
if fi, err := os.Stat(subChartsPath); err == nil && fi.IsDir() {
subCharts, err := os.ReadDir(subChartsPath)
if err == nil && len(subCharts) > 0 {
for _, subChart := range subCharts {
subChartPath := path.Join(subChartsPath, subChart.Name())
if !subChart.IsDir() || !IsChartDirectory(subChartPath) {
continue
}

loadedSubChart,err := loader.Load(path.Join(subChartsPath, subChart.Name()))
if err != nil {
return nil, errors.New(fmt.Sprintf("\n\tCan't read %s helm subchart.", subChartPath))
}
loadedChart.Values[subChart.Name()] = loadedSubChart.Values
}
}
}

finalValues := map[string]interface{}{
"Values": loadedChart.Values,
"Release": map[string]string{"Namespace": "tractusx-check"},
Expand Down

0 comments on commit 75e21ac

Please sign in to comment.