mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-09-18 13:22:17 +00:00
Remove local-only resources at the last minute
This allows name references to them to be correctly resolved
This commit is contained in:
@@ -158,6 +158,11 @@ func (kt *KustTarget) makeCustomizedResMap() (resmap.ResMap, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = kt.IgnoreLocal(ra)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return ra.ResMap(), nil
|
return ra.ResMap(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,10 +243,6 @@ func (kt *KustTarget) accumulateTarget(ra *accumulator.ResAccumulator) (
|
|||||||
return nil, errors.Wrapf(
|
return nil, errors.Wrapf(
|
||||||
err, "merging vars %v", kt.kustomization.Vars)
|
err, "merging vars %v", kt.kustomization.Vars)
|
||||||
}
|
}
|
||||||
err = kt.IgnoreLocal(ra)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return ra, nil
|
return ra, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -671,3 +671,118 @@ metadata:
|
|||||||
name: newNs
|
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
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user