Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue where kustomization files are empty #3094

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/pkg/packager/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ func (p *Packager) findImages(ctx context.Context) (map[string][]string, error)
for idx, k := range manifest.Kustomizations {
// Generate manifests from kustomizations and place in the package
kname := fmt.Sprintf("kustomization-%s-%d.yaml", manifest.Name, idx)
destination := filepath.Join(componentPaths.Manifests, kname)
// Use the temp folder because if "helpers.CreatePathAndCopy" is provider with the same path it will result in the file being empty
destination := filepath.Join(componentPaths.Temp, kname)
if err := kustomize.Build(k, destination, manifest.KustomizeAllowAnyDirectory); err != nil {
return nil, fmt.Errorf("unable to build the kustomization for %s: %w", k, err)
}
Expand Down
14 changes: 14 additions & 0 deletions src/pkg/packager/prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ func TestFindImages(t *testing.T) {
},
},
},
{
name: "kustomization",
cfg: &types.PackagerConfig{
CreateOpts: types.ZarfCreateOptions{
BaseDir: "./testdata/find-images/kustomize",
},
},
expectedImages: map[string][]string{
"baseline": {
"ghcr.io/zarf-dev/zarf/agent:v0.38.1",
"ghcr.io/zarf-dev/zarf/agent:sha256-f8b1c2f99349516ae1bd0711a19697abcc41555076b0ae90f1a70ca6b50dcbd8.sig",
},
},
},
{
name: "image not found",
cfg: &types.PackagerConfig{
Expand Down
16 changes: 16 additions & 0 deletions src/pkg/packager/testdata/find-images/kustomize/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: agent
spec:
selector:
matchLabels:
app: agent
template:
metadata:
labels:
app: agent
spec:
containers:
- name: agent
image: ghcr.io/zarf-dev/zarf/agent:v0.38.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
12 changes: 12 additions & 0 deletions src/pkg/packager/testdata/find-images/kustomize/zarf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: ZarfPackageConfig
metadata:
name: agent
version: 1.0.0
components:
- name: baseline
required: true
manifests:
- name: agent
namespace: default
kustomizations:
- ./.