diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ad3dde9..d53a61a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -87,6 +87,7 @@ jobs: sudo apt-get update sudo apt-get install -y unzip sudo apt-get install -y tree + sudo apt-get install -y jq - name: Download Artifacts uses: actions/download-artifact@v6 @@ -316,6 +317,8 @@ jobs: hauler store sync --filename testdata/hauler-manifest-pipeline.yaml # verify images are present hauler store info | grep 'musl' + # verify that only one kube-vip image with the correct platform is present + 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 # verify via sync with multiple files hauler store sync --filename testdata/hauler-manifest-pipeline.yaml --filename testdata/hauler-manifest.yaml # need more tests here diff --git a/cmd/hauler/cli/store/sync.go b/cmd/hauler/cli/store/sync.go index fcddcd7..e83b27e 100644 --- a/cmd/hauler/cli/store/sync.go +++ b/cmd/hauler/cli/store/sync.go @@ -501,6 +501,14 @@ func processContent(ctx context.Context, fi *os.File, o *flags.SyncOpts, s *stor valuesFiles = append(valuesFiles, filepath.Join(filepath.Dir(fi.Name()), path)) } + platform := o.Platform + if annotation != nil && annotation[consts.ImageAnnotationPlatform] != "" { + platform = annotation[consts.ImageAnnotationPlatform] + } + if ch.Platform != "" { + platform = ch.Platform + } + if err := storeChart(ctx, s, ch, &flags.AddChartOpts{ ChartOpts: &action.ChartPathOptions{ @@ -511,7 +519,7 @@ func processContent(ctx context.Context, fi *os.File, o *flags.SyncOpts, s *stor AddDependencies: ch.AddDependencies, ExcludeExtras: excludeExtras, Registry: registry, - Platform: o.Platform, + Platform: platform, ValuesFiles: valuesFiles, }, rso, ro, diff --git a/pkg/apis/hauler.cattle.io/v1/chart.go b/pkg/apis/hauler.cattle.io/v1/chart.go index ba63ad2..4309a3d 100644 --- a/pkg/apis/hauler.cattle.io/v1/chart.go +++ b/pkg/apis/hauler.cattle.io/v1/chart.go @@ -21,6 +21,7 @@ type Chart struct { Version string `json:"version,omitempty"` Rewrite string `json:"rewrite,omitempty"` ValuesFiles []string `json:"valuesFiles,omitempty"` + Platform string `json:"platform,omitempty"` AddImages bool `json:"add-images,omitempty"` AddDependencies bool `json:"add-dependencies,omitempty"` diff --git a/testdata/hauler-manifest-pipeline.yaml b/testdata/hauler-manifest-pipeline.yaml index 64e738b..a924060 100755 --- a/testdata/hauler-manifest-pipeline.yaml +++ b/testdata/hauler-manifest-pipeline.yaml @@ -45,6 +45,11 @@ spec: valuesFiles: - "chart-with-file-dependency-chart-required-values-2.yaml" - "chart-with-file-dependency-chart-required-values.yaml" + - name: kube-vip + repoURL: https://kube-vip.github.io/helm-charts/ + version: 0.9.9 + add-images: true + platform: linux/amd64 --- apiVersion: content.hauler.cattle.io/v1 kind: Files