Skip to content

Commit 05e41e4

Browse files
committed
fix(deploy): subcharts rendered incorrectly
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
1 parent fa28d3c commit 05e41e4

File tree

5 files changed

+15
-27
lines changed

5 files changed

+15
-27
lines changed

cmd/werf/bundle/publish/publish.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ func createNewBundle(
493493
}
494494

495495
if destDir == "" {
496-
destDir = wc.HelmChart.Metadata.Name
496+
destDir = chrt.Metadata.Name
497497
}
498498

499499
if err := os.RemoveAll(destDir); err != nil {
@@ -517,11 +517,11 @@ func createNewBundle(
517517
}
518518
}
519519

520-
if wc.HelmChart.Metadata == nil {
520+
if chrt.Metadata == nil {
521521
panic("unexpected condition")
522522
}
523523

524-
bundleMetadata := *wc.HelmChart.Metadata
524+
bundleMetadata := *chrt.Metadata
525525
// Force api v2
526526
bundleMetadata.APIVersion = chart.APIVersionV2
527527
bundleMetadata.Version = chartVersion
@@ -533,9 +533,9 @@ func createNewBundle(
533533
return nil, fmt.Errorf("unable to write %q: %w", chartYamlFile, err)
534534
}
535535

536-
if wc.HelmChart.Lock != nil {
536+
if chrt.Lock != nil {
537537
chartLockFile := filepath.Join(destDir, "Chart.lock")
538-
if data, err := json.Marshal(wc.HelmChart.Lock); err != nil {
538+
if data, err := json.Marshal(chrt.Lock); err != nil {
539539
return nil, fmt.Errorf("unable to prepare Chart.lock data: %w", err)
540540
} else if err := ioutil.WriteFile(chartLockFile, append(data, []byte("\n")...), os.ModePerm); err != nil {
541541
return nil, fmt.Errorf("unable to write %q: %w", chartLockFile, err)
@@ -547,7 +547,7 @@ func createNewBundle(
547547
return nil, fmt.Errorf("unable to create dir %q: %w", templatesDir, err)
548548
}
549549

550-
for _, f := range wc.HelmChart.Templates {
550+
for _, f := range chrt.Templates {
551551
if err := writeChartFile(ctx, destDir, f.Name, f.Data); err != nil {
552552
return nil, fmt.Errorf("error writing chart template: %w", err)
553553
}
@@ -568,7 +568,7 @@ func createNewBundle(
568568
}
569569

570570
WritingFiles:
571-
for _, f := range wc.HelmChart.Files {
571+
for _, f := range chrt.Files {
572572
for _, ignoreValuesFile := range ignoreChartValuesFiles {
573573
if f.Name == ignoreValuesFile {
574574
continue WritingFiles
@@ -580,7 +580,7 @@ WritingFiles:
580580
}
581581
}
582582

583-
for _, dep := range wc.HelmChart.Metadata.Dependencies {
583+
for _, dep := range chrt.Metadata.Dependencies {
584584
var depPath string
585585

586586
switch {
@@ -592,7 +592,7 @@ WritingFiles:
592592
depPath = fmt.Sprintf("charts/%s-%s.tgz", dep.Name, dep.Version)
593593
}
594594

595-
for _, f := range wc.HelmChart.Raw {
595+
for _, f := range chrt.Raw {
596596
if strings.HasPrefix(f.Name, depPath) {
597597
if err := writeChartFile(ctx, destDir, f.Name, f.Data); err != nil {
598598
return nil, fmt.Errorf("error writing subchart file: %w", err)
@@ -601,12 +601,12 @@ WritingFiles:
601601
}
602602
}
603603

604-
if wc.HelmChart.Schema != nil {
604+
if chrt.Schema != nil {
605605
schemaFile := filepath.Join(destDir, "values.schema.json")
606-
if err := writeChartFile(ctx, destDir, "values.schema.json", wc.HelmChart.Schema); err != nil {
606+
if err := writeChartFile(ctx, destDir, "values.schema.json", chrt.Schema); err != nil {
607607
return nil, fmt.Errorf("error writing chart values schema: %w", err)
608608
}
609-
if err := ioutil.WriteFile(schemaFile, wc.HelmChart.Schema, os.ModePerm); err != nil {
609+
if err := ioutil.WriteFile(schemaFile, chrt.Schema, os.ModePerm); err != nil {
610610
return nil, fmt.Errorf("unable to write %q: %w", schemaFile, err)
611611
}
612612
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ require (
6060
github.com/sirupsen/logrus v1.9.3
6161
github.com/spf13/cobra v1.8.0
6262
github.com/spf13/pflag v1.0.5
63-
github.com/werf/3p-helm v0.0.0-20250204105623-50b0062dce93
63+
github.com/werf/3p-helm v0.0.0-20250204120453-e5dd1167f834
6464
github.com/werf/3p-helm-for-werf-helm v0.0.0-20241217155820-089f92cd5c9d
6565
github.com/werf/common-go v0.0.0-20250115100423-863829c6587b
6666
github.com/werf/copy-recurse v0.2.7

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1433,8 +1433,8 @@ github.com/werf/3p-buildah v1.35.2-0.20241120093816-5b80b7b735de h1:adTANOZyNmmn
14331433
github.com/werf/3p-buildah v1.35.2-0.20241120093816-5b80b7b735de/go.mod h1:vVSVUlTu8+99H5j43gBJscpkb/quZvdJg78+6X1HeTM=
14341434
github.com/werf/3p-docker-buildx v0.13.0-rc2.0.20241111114615-d77c2e1444ad h1:FBDNACfjjpDBwXhALF5LgvEiu08HpUurb/2G323SVsQ=
14351435
github.com/werf/3p-docker-buildx v0.13.0-rc2.0.20241111114615-d77c2e1444ad/go.mod h1:Q3gtkv8D3sdaa5LJXbzMooYR/A5vBiEB2yQ56wywohM=
1436-
github.com/werf/3p-helm v0.0.0-20250204105623-50b0062dce93 h1:HKcFfuYjLxaLob8x8Jl3+ocXBVUb5bDP6/UvmOKlU6E=
1437-
github.com/werf/3p-helm v0.0.0-20250204105623-50b0062dce93/go.mod h1:LoLuFhwWr1El/R/tqwUn2ZmRZdThnSlUmkdDPDE+udk=
1436+
github.com/werf/3p-helm v0.0.0-20250204120453-e5dd1167f834 h1:uZdBQJ1TtBdZ5h4Sd3XCH1ZmMnt/g/0strNCzwafwBU=
1437+
github.com/werf/3p-helm v0.0.0-20250204120453-e5dd1167f834/go.mod h1:LoLuFhwWr1El/R/tqwUn2ZmRZdThnSlUmkdDPDE+udk=
14381438
github.com/werf/3p-helm-for-werf-helm v0.0.0-20241217155820-089f92cd5c9d h1:HN9jmAG2Gyhf8hJca9yoAO2xawNZQ/6OYDomxkKr5Sw=
14391439
github.com/werf/3p-helm-for-werf-helm v0.0.0-20241217155820-089f92cd5c9d/go.mod h1:fozJ+C/Llp1e+jHxrJOZUu+D4QEw+laQK6W6RFqvTsg=
14401440
github.com/werf/3p-oras v0.9.1-0.20240115121544-03962ecbd40a h1:PsU9szHZlIH+CjcuIuPXRLc5dsdoaFldvYjS6YHI7YQ=

pkg/deploy/helm/chart_extender/bundle.go

-5
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,12 @@ func NewBundle(
3939
type Bundle struct {
4040
Dir string
4141
SecretValueFiles []string
42-
HelmChart *chart.Chart
4342
BuildChartDependenciesOpts chart.BuildChartDependenciesOptions
4443
DisableDefaultValues bool
4544

4645
*helpers.ChartExtenderServiceValuesData
4746
}
4847

49-
func (bundle *Bundle) SetHelmChart(c *chart.Chart) {
50-
bundle.HelmChart = c
51-
}
52-
5348
func (bundle *Bundle) Type() string {
5449
return "bundle"
5550
}

pkg/deploy/helm/chart_extender/werf_chart.go

-7
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ func NewWerfChart(
4040
}
4141

4242
type WerfChart struct {
43-
HelmChart *chart.Chart
44-
4543
ChartDir string
4644
ProjectDir string
4745
SecretValueFiles []string
@@ -53,11 +51,6 @@ type WerfChart struct {
5351
*helpers.ChartExtenderServiceValuesData
5452
}
5553

56-
// SetHelmChart method for the chart.Extender interface
57-
func (wc *WerfChart) SetHelmChart(c *chart.Chart) {
58-
wc.HelmChart = c
59-
}
60-
6154
func (wc *WerfChart) Type() string {
6255
return "chart"
6356
}

0 commit comments

Comments
 (0)