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: kustomize render should support components #9636

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
19 changes: 16 additions & 3 deletions integration/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1438,19 +1438,31 @@ patchesStrategicMerge:

resources:
- ../../base

components:
- ../../components/label
`, "overlays/dev/deployment.yaml": `apiVersion: apps/v1
kind: Deployment
metadata:
name: skaffold-kustomize
labels:
env: dev # from-param: ${env2}
`, "components/label/kustomization.yaml": `apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

labels:
- includeTemplates: true
includeSelectors: false
pairs:
region: 333a
`}, expectedOut: `
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: 111a
env: 222a
region: 333a
name: skaffold-kustomize-dev
spec:
selector:
Expand All @@ -1460,6 +1472,7 @@ spec:
metadata:
labels:
app: skaffold-kustomize
region: 333a
spec:
containers:
- image: skaffold-kustomize
Expand Down Expand Up @@ -2064,7 +2077,7 @@ metadata:
labels:
app1: after-change-1
app2: before-change-2

spec:
containers:
- image: us-central1-docker.pkg.dev/k8s-skaffold/testing/multi-config-module1:customtag
Expand Down Expand Up @@ -2332,7 +2345,7 @@ spec:
kind: Deployment
metadata:
name: my-nginx
annotations:
annotations:
color: orange
fruit: apple
spec:
Expand All @@ -2342,7 +2355,7 @@ spec:
app: nginx
template:
metadata:
annotations:
annotations:
color: orange
fruit: apple
labels:
Expand Down
15 changes: 15 additions & 0 deletions pkg/skaffold/render/renderer/kustomize/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ func (k Kustomize) mirror(kusDir string, fs TmpFS) error {
if err := k.mirrorConfigMapGenerators(kusDir, fs, kustomization.ConfigMapGenerator); err != nil {
return err
}
if err := k.mirrorComponents(kusDir, fs, kustomization.Components); err != nil {
return err
}

return nil
}
Expand Down Expand Up @@ -295,6 +298,18 @@ func (k Kustomize) mirrorResources(kusDir string, fs TmpFS, resources []string)
return nil
}

func (k Kustomize) mirrorComponents(kusDir string, fs TmpFS, components []string) error {
for _, c := range components {
// note that c is relative to kustomization file not working dir here
cPath := filepath.Join(kusDir, c)

if err := k.mirror(cPath, fs); err != nil {
return err
}
}
return nil
}

func (k Kustomize) mirrorFile(kusDir string, fs TmpFS, path string) error {
if sUtil.IsURL(path) {
return nil
Expand Down
Loading