Skip to content

Commit 8dc864c

Browse files
eklatzerzackbradys
andauthored
feat: extend charts resource by platform (#657)
Signed-off-by: Eric Klatzer <eric@klatzer.at> Co-authored-by: Zack Brady <zackbrady123@gmail.com>
1 parent 06ab061 commit 8dc864c

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
sudo apt-get update
8888
sudo apt-get install -y unzip
8989
sudo apt-get install -y tree
90+
sudo apt-get install -y jq
9091
9192
- name: Download Artifacts
9293
uses: actions/download-artifact@v6
@@ -316,6 +317,8 @@ jobs:
316317
hauler store sync --filename testdata/hauler-manifest-pipeline.yaml
317318
# verify images are present
318319
hauler store info | grep 'musl'
320+
# verify that only one kube-vip image with the correct platform is present
321+
hauler store info --output json | jq -e '.artifacts | map(select(.type=="image" and .reference=="ghcr.io/kube-vip/kube-vip:v1.0.4")) | length == 1' >/dev/null
319322
# verify via sync with multiple files
320323
hauler store sync --filename testdata/hauler-manifest-pipeline.yaml --filename testdata/hauler-manifest.yaml
321324
# need more tests here

cmd/hauler/cli/store/sync.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,14 @@ func processContent(ctx context.Context, fi *os.File, o *flags.SyncOpts, s *stor
501501
valuesFiles = append(valuesFiles, filepath.Join(filepath.Dir(fi.Name()), path))
502502
}
503503

504+
platform := o.Platform
505+
if annotation != nil && annotation[consts.ImageAnnotationPlatform] != "" {
506+
platform = annotation[consts.ImageAnnotationPlatform]
507+
}
508+
if ch.Platform != "" {
509+
platform = ch.Platform
510+
}
511+
504512
if err := storeChart(ctx, s, ch,
505513
&flags.AddChartOpts{
506514
ChartOpts: &action.ChartPathOptions{
@@ -511,7 +519,7 @@ func processContent(ctx context.Context, fi *os.File, o *flags.SyncOpts, s *stor
511519
AddDependencies: ch.AddDependencies,
512520
ExcludeExtras: excludeExtras,
513521
Registry: registry,
514-
Platform: o.Platform,
522+
Platform: platform,
515523
ValuesFiles: valuesFiles,
516524
},
517525
rso, ro,

pkg/apis/hauler.cattle.io/v1/chart.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Chart struct {
2121
Version string `json:"version,omitempty"`
2222
Rewrite string `json:"rewrite,omitempty"`
2323
ValuesFiles []string `json:"valuesFiles,omitempty"`
24+
Platform string `json:"platform,omitempty"`
2425

2526
AddImages bool `json:"add-images,omitempty"`
2627
AddDependencies bool `json:"add-dependencies,omitempty"`

testdata/hauler-manifest-pipeline.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ spec:
4545
valuesFiles:
4646
- "chart-with-file-dependency-chart-required-values-2.yaml"
4747
- "chart-with-file-dependency-chart-required-values.yaml"
48+
- name: kube-vip
49+
repoURL: https://kube-vip.github.io/helm-charts/
50+
version: 0.9.9
51+
add-images: true
52+
platform: linux/amd64
4853
---
4954
apiVersion: content.hauler.cattle.io/v1
5055
kind: Files

0 commit comments

Comments
 (0)