mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 18:10:59 +00:00
Add test showing shared patches disallowed.
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package target_test
|
package target_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -181,6 +182,36 @@ spec:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSharedPatchDisAllowed(t *testing.T) {
|
||||||
|
th := NewKustTestHarness(t, "/app/overlay")
|
||||||
|
writeSmallBase(th)
|
||||||
|
th.writeK("/app/overlay", `
|
||||||
|
commonLabels:
|
||||||
|
env: prod
|
||||||
|
bases:
|
||||||
|
- ../base
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- ../shared/deployment-patch.yaml
|
||||||
|
`)
|
||||||
|
th.writeF("/app/shared/deployment-patch.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: myDeployment
|
||||||
|
spec:
|
||||||
|
replicas: 1000
|
||||||
|
`)
|
||||||
|
_, err := th.makeKustTarget().MakeCustomizedResMap()
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("expected error")
|
||||||
|
}
|
||||||
|
if !strings.Contains(
|
||||||
|
err.Error(),
|
||||||
|
"security; file '../shared/deployment-patch.yaml' is not in or below '/app/overlay'") {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSmallOverlayJSONPatch(t *testing.T) {
|
func TestSmallOverlayJSONPatch(t *testing.T) {
|
||||||
th := NewKustTestHarness(t, "/app/overlay")
|
th := NewKustTestHarness(t, "/app/overlay")
|
||||||
writeSmallBase(th)
|
writeSmallBase(th)
|
||||||
|
|||||||
Reference in New Issue
Block a user