Merge pull request #4895 from KnVerey/remove-local-last

Remove local-only resources at the last minute
This commit is contained in:
Kubernetes Prow Robot
2022-12-01 13:20:00 -08:00
committed by GitHub
2 changed files with 120 additions and 4 deletions

View File

@@ -158,6 +158,11 @@ func (kt *KustTarget) makeCustomizedResMap() (resmap.ResMap, error) {
return nil, err
}
err = kt.IgnoreLocal(ra)
if err != nil {
return nil, err
}
return ra.ResMap(), nil
}
@@ -238,10 +243,6 @@ func (kt *KustTarget) accumulateTarget(ra *accumulator.ResAccumulator) (
return nil, errors.Wrapf(
err, "merging vars %v", kt.kustomization.Vars)
}
err = kt.IgnoreLocal(ra)
if err != nil {
return nil, err
}
return ra, nil
}

View File

@@ -671,3 +671,118 @@ metadata:
name: newNs
`)
}
func TestIssue4884_UseLocalConfigAsNameRefSource(t *testing.T) {
th := kusttest_test.MakeHarness(t)
th.WriteK(".", `
resources:
- resources.yaml
namePrefix: prefix-
configurations:
- kustomize-nameref.yaml
`)
th.WriteF("kustomize-nameref.yaml", `
nameReference:
- kind: IngressHost
fieldSpecs:
- path: spec/rules/host
kind: Ingress
- path: spec/tls/hosts
kind: Ingress
- path: spec/template/spec/containers/env/value
kind: Deployment
- kind: IngressSecret
fieldSpecs:
- path: spec/tls/secretName
kind: Ingress
namePrefix:
- path: metadata/name
kind: IngressHost
- path: metadata/name
kind: IngressSecret
`)
th.WriteF("resources.yaml", `
apiVersion: local/v1
kind: IngressHost
metadata:
name: test.fakedomain.com
namespace: test
annotations:
config.kubernetes.io/local-config: "true"
---
apiVersion: local/v1
kind: IngressSecret
metadata:
name: test-secret
namespace: test
annotations:
config.kubernetes.io/local-config: "true"
---
apiVersion: v1
kind: Ingress
metadata:
name: test-ingress
namespace: test
spec:
rules:
- host: test.fakedomain.com
- host: do-not-touch.otherdomain.com
tls:
- hosts:
- test.fakedomain.com
secretName: test-secret
- hosts:
- do-not-touch.otherdomain.com
secretname: do-not-touch
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
namespace: test
spec:
template:
spec:
containers:
- name: tester
env:
- name: domain-name
value: test.fakedomain.com
`)
m := th.Run(".", th.MakeDefaultOptions())
th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Ingress
metadata:
name: test-ingress
namespace: test
spec:
rules:
- host: prefix-test.fakedomain.com
- host: do-not-touch.otherdomain.com
tls:
- hosts:
- prefix-test.fakedomain.com
secretName: prefix-test-secret
- hosts:
- do-not-touch.otherdomain.com
secretname: do-not-touch
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
namespace: test
spec:
template:
spec:
containers:
- env:
- name: domain-name
value: prefix-test.fakedomain.com
name: tester
`)
}