Modify tests to present expected data in unsorted order.

Modify all `build` tests to use the raw,
non-sorted output of build.  This makes every test
provide coverage for how kustomize re-orders (or
doesn't reorder) resources during processing.

Going forward, the ordering of resources in
_expected_ output should match the depth-first
ordering specified in the `resources:` field used
in the test's kustomization file.

The only exception to this rule would be tests
that actually confirmed some other output
ordering, e.g. the test of the
`LegacyOrderTransformer` plugin.

Fixes #756
Related #821
This commit is contained in:
Jeffrey Regan
2019-06-17 14:41:43 -07:00
parent ed21e77fb1
commit 0b555e1b2c
21 changed files with 613 additions and 582 deletions

BIN
docs/images/sorted.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -6,6 +6,7 @@
[imgModules]: images/goModules.png [imgModules]: images/goModules.png
[imgPlugins]: images/plugins.png [imgPlugins]: images/plugins.png
[imgPruning]: images/pruning.png [imgPruning]: images/pruning.png
[imgSorted]: images/sorted.png
[imgWheels]: images/abandonedTrainingWheels.png [imgWheels]: images/abandonedTrainingWheels.png
[kustomization]: glossary.md#kustomization [kustomization]: glossary.md#kustomization
[_kustomization_]: glossary.md#kustomization [_kustomization_]: glossary.md#kustomization
@@ -25,8 +26,6 @@ _Summary_: Go modules, inventory, plugins, eased
loading restrictions, and about ~80 issues closed loading restrictions, and about ~80 issues closed
since [v2.0.3] (over 300 commits). since [v2.0.3] (over 300 commits).
## Go modules ## Go modules
![gopher with boxes][imgModules] ![gopher with boxes][imgModules]
@@ -38,23 +37,27 @@ as one or more [Go modules] for use in other
programs (kubectl, kubebuilder, etc.) and in programs (kubectl, kubebuilder, etc.) and in
kustomize plugins (see below). kustomize plugins (see below).
## Resource ordering
## Inventory generation for pruning ![sort order retained][imgSorted]
![pruning dead branches][imgPruning] Kustomize now retains the depth-first order of
resources as read.
Users can add an `inventory` stanza to their The `build` command now accepts a `--reorder`
kustomization file, to add a special _inventory flag with values `legacy` and `none`,
object_ to the `build` result. with a default value of `legacy`.
This object applies to the cluster along with `legacy` means apply an ordering based on
everything else in the build result and can be GVK, that currently emits `Namespace` objects
used by other clients to intelligently _prune_ first, and `ValidatingWebhookConfiguration`
orphaned cluster resources. objects last.
For more information see the
[kustomize inventory object documentation].
`none` means do not reorder the resources before
output. This means kustomize respects the input
order of the data, giving the user a means to
control output order. Generated resources always
come last.
## Generator and transformer plugins ## Generator and transformer plugins
@@ -82,7 +85,7 @@ requests for kustomize revolve around changing the
behavior of the builtin generators and behavior of the builtin generators and
transformers. transformers.
[v2.1.0] adds a _alpha_ plugin framework, that [v2.1.0] adds an _alpha_ plugin framework, that
encourages users to write their own generators or encourages users to write their own generators or
transformers, _declaring them as kubernetes transformers, _declaring them as kubernetes
objects just like everything else_, and apply them objects just like everything else_, and apply them
@@ -93,7 +96,7 @@ confirm that the plugin framework can offer plugin
authors the same capabilities as builtin authors the same capabilities as builtin
operations, all the builtin generators and operations, all the builtin generators and
tranformers have been converted to plugin form tranformers have been converted to plugin form
(with a few exceptions awaiting Go module (with one exceptions awaiting Go module
refinements). This means that adding, say, a refinements). This means that adding, say, a
`secretGenerator` or `commonAnnotations` directive `secretGenerator` or `commonAnnotations` directive
to your kustomization will (in [v2.1.0]) trigger to your kustomization will (in [v2.1.0]) trigger
@@ -126,34 +129,79 @@ patch file. To share _resources_, use a relative
path or URL to a kustomization directory in the path or URL to a kustomization directory in the
`resources` directive. `resources` directive.
## Inventory generation for pruning
![pruning dead branches][imgPruning]
_Alpha_
Users can add an `inventory` stanza to their
kustomization file, to add a special _inventory
object_ to the `build` result.
This object applies to the cluster along with
everything else in the build result and can be
used by other clients to intelligently _prune_
orphaned cluster resources.
For more information see the
[kustomize inventory object documentation].
## Field changes / deprecations ## Field changes / deprecations
* Generalized `resources` field. * Generalized `resources` field.
The `resources` field has been generalized, and The `resources` field has been generalized; it
can now accept what formerly could only now accepts what formerly could only be
be specified in the `bases` field. specified in the `bases` field.
This change was made so that the `resources`, This change was made so that the `resources`,
`generators` and `transformers` fields all `generators` and `transformers` fields all
accept the same argument format. accept the same argument format.
Each field's argument is a _string list_, where > Each field's argument is a _string list_,
each entry is either a _resource_ (a relative > where each entry is either a _resource_ (a
path to a YAML file) or a [_kustomization_] (a > relative path to a YAML file) or a
relative path or URL pointing to a directory > [_kustomization_] (a relative path or URL
with a kustomization file). A kustomization > pointing to a directory with a kustomization
directory used in this context is called a > file). A kustomization directory used in this
[_base_]. > context is called a [_base_].
The `bases` field still works, but is no longer The `bases` field still works, but is
necessary, and will likely be deprecated in the deprecated. Deal with this by simply moving the
next release. The _base_ as a concept is as arguments of the `bases` field to the
important as ever, it's just that two new fields `resources` field in the desired order, e.g.
(`generators` and `tranformers`) and one existing
field (`resources`) now accept arguments > ```
that were once accepted only by `bases`. > resources:
> - someResouceFile.yaml
> - someOtherResourceFile.yaml
> bases:
> - ../../someBaseDir
> ```
could become
> ```
> resources:
> - someResouceFile.yaml
> - ../../someBaseDir
> - someOtherResourceFile.yaml
> ```
The depth-first traversal order of items in the
`resources:` field is respected by
kustomize, allowing one to, say, process
`someBaseDir` between the two resource files.
See this discussion of
[the `build --reorder` flag](#resource-ordering).
The _base_ as a concept is as important as ever,
it's just that two new fields (`generators` and
`tranformers`) and one existing field
(`resources`) now accept arguments that were
once accepted only by `bases`.
The fact that the `generators` and The fact that the `generators` and
`transformers` field accept [bases] `transformers` field accept [bases]

View File

@@ -20,7 +20,6 @@ import (
"sigs.k8s.io/kustomize/pkg/target" "sigs.k8s.io/kustomize/pkg/target"
"sigs.k8s.io/kustomize/pkg/transformers/config/defaultconfig" "sigs.k8s.io/kustomize/pkg/transformers/config/defaultconfig"
"sigs.k8s.io/kustomize/pkg/types" "sigs.k8s.io/kustomize/pkg/types"
"sigs.k8s.io/kustomize/plugin/builtin"
) )
// KustTestHarness helps test kustomization generation and transformation. // KustTestHarness helps test kustomization generation and transformation.
@@ -190,16 +189,6 @@ func hint(a, b string) string {
func (th *KustTestHarness) AssertActualEqualsExpected( func (th *KustTestHarness) AssertActualEqualsExpected(
m resmap.ResMap, expected string) { m resmap.ResMap, expected string) {
th.assertActualEqualsExpected(m, expected, true)
}
func (th *KustTestHarness) AssertActualEqualsExpectedNoSort(
m resmap.ResMap, expected string) {
th.assertActualEqualsExpected(m, expected, false)
}
func (th *KustTestHarness) assertActualEqualsExpected(
m resmap.ResMap, expected string, doLegacySort bool) {
if m == nil { if m == nil {
th.t.Fatalf("Map should not be nil.") th.t.Fatalf("Map should not be nil.")
} }
@@ -208,9 +197,6 @@ func (th *KustTestHarness) assertActualEqualsExpected(
if len(expected) > 0 && expected[0] == 10 { if len(expected) > 0 && expected[0] == 10 {
expected = expected[1:] expected = expected[1:]
} }
if doLegacySort {
builtin.NewLegacyOrderTransformerPlugin().Transform(m)
}
actual, err := m.AsYaml() actual, err := m.AsYaml()
if err != nil { if err != nil {
th.t.Fatalf("Unexpected err: %v", err) th.t.Fatalf("Unexpected err: %v", err)

View File

@@ -79,22 +79,6 @@ func TestMediumBase(t *testing.T) {
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Service
metadata:
annotations:
baseAnno: This is a base annotation
labels:
app: mungebot
foo: bar
name: baseprefix-mungebot-service
spec:
ports:
- port: 7002
selector:
app: mungebot
foo: bar
---
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -125,6 +109,22 @@ spec:
name: nginx name: nginx
ports: ports:
- containerPort: 80 - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
annotations:
baseAnno: This is a base annotation
labels:
app: mungebot
foo: bar
name: baseprefix-mungebot-service
spec:
ports:
- port: 7002
selector:
app: mungebot
foo: bar
`) `)
} }
@@ -139,7 +139,7 @@ commonLabels:
repo: test-infra repo: test-infra
commonAnnotations: commonAnnotations:
note: This is a test annotation note: This is a test annotation
bases: resources:
- ../base - ../base
patchesStrategicMerge: patchesStrategicMerge:
- deployment/deployment.yaml - deployment/deployment.yaml
@@ -210,63 +210,7 @@ spec:
if err != nil { if err != nil {
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
// TODO(#669): The name of the patched Deployment is
// test-infra-baseprefix-mungebot, retaining the base
// prefix (example of correct behavior).
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
data:
nonsense: "Lorem ipsum dolor sit amet, consectetur\nadipiscing elit, sed do eiusmod
tempor\nincididunt ut labore et dolore magna aliqua. \n"
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mungebot
org: kubernetes
repo: test-infra
name: test-infra-app-config-f462h769f9
---
apiVersion: v1
data:
DB_PASSWORD: somepw
DB_USERNAME: admin
ENERGY: electronvolt
FRUIT: banana
LEGUME: chickpea
LENGTH: kilometer
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mungebot
org: kubernetes
repo: test-infra
name: test-infra-app-env-ffmd9b969m
---
apiVersion: v1
kind: Service
metadata:
annotations:
baseAnno: This is a base annotation
note: This is a test annotation
labels:
app: mungebot
foo: bar
org: kubernetes
repo: test-infra
name: test-infra-baseprefix-mungebot-service
spec:
ports:
- port: 7002
selector:
app: mungebot
foo: bar
org: kubernetes
repo: test-infra
---
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -325,5 +269,58 @@ spec:
- configMap: - configMap:
name: test-infra-app-env-ffmd9b969m name: test-infra-app-env-ffmd9b969m
name: app-env name: app-env
---
apiVersion: v1
kind: Service
metadata:
annotations:
baseAnno: This is a base annotation
note: This is a test annotation
labels:
app: mungebot
foo: bar
org: kubernetes
repo: test-infra
name: test-infra-baseprefix-mungebot-service
spec:
ports:
- port: 7002
selector:
app: mungebot
foo: bar
org: kubernetes
repo: test-infra
---
apiVersion: v1
data:
DB_PASSWORD: somepw
DB_USERNAME: admin
ENERGY: electronvolt
FRUIT: banana
LEGUME: chickpea
LENGTH: kilometer
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mungebot
org: kubernetes
repo: test-infra
name: test-infra-app-env-ffmd9b969m
---
apiVersion: v1
data:
nonsense: "Lorem ipsum dolor sit amet, consectetur\nadipiscing elit, sed do eiusmod
tempor\nincididunt ut labore et dolore magna aliqua. \n"
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mungebot
org: kubernetes
repo: test-infra
name: test-infra-app-config-f462h769f9
`) `)
} }

View File

@@ -83,7 +83,7 @@ metadata:
if err != nil { if err != nil {
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpectedNoSort(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1 apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
@@ -197,19 +197,6 @@ func TestSmallBase(t *testing.T) {
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Service
metadata:
labels:
app: myApp
name: a-myService
spec:
ports:
- port: 7002
selector:
app: myApp
backend: bungie
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -229,6 +216,19 @@ spec:
containers: containers:
- image: whatever - image: whatever
name: whatever name: whatever
---
apiVersion: v1
kind: Service
metadata:
labels:
app: myApp
name: a-myService
spec:
ports:
- port: 7002
selector:
app: myApp
backend: bungie
`) `)
} }
@@ -239,7 +239,7 @@ func TestSmallOverlay(t *testing.T) {
namePrefix: b- namePrefix: b-
commonLabels: commonLabels:
env: prod env: prod
bases: resources:
- ../base - ../base
patchesStrategicMerge: patchesStrategicMerge:
- deployment/deployment.yaml - deployment/deployment.yaml
@@ -268,25 +268,7 @@ spec:
if err != nil { if err != nil {
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
// TODO(#669): The name of the patched Deployment is
// b-a-myDeployment, retaining the base prefix
// (example of correct behavior).
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Service
metadata:
labels:
app: myApp
env: prod
name: b-a-myService
spec:
ports:
- port: 7002
selector:
app: myApp
backend: bungie
env: prod
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -310,6 +292,21 @@ spec:
containers: containers:
- image: whatever:1.8.0 - image: whatever:1.8.0
name: whatever name: whatever
---
apiVersion: v1
kind: Service
metadata:
labels:
app: myApp
env: prod
name: b-a-myService
spec:
ports:
- port: 7002
selector:
app: myApp
backend: bungie
env: prod
`) `)
} }
@@ -321,7 +318,7 @@ func TestSharedPatchDisAllowed(t *testing.T) {
th.WriteK("/app/overlay", ` th.WriteK("/app/overlay", `
commonLabels: commonLabels:
env: prod env: prod
bases: resources:
- ../base - ../base
patchesStrategicMerge: patchesStrategicMerge:
- ../shared/deployment-patch.yaml - ../shared/deployment-patch.yaml
@@ -353,7 +350,7 @@ func TestSharedPatchAllowed(t *testing.T) {
th.WriteK("/app/overlay", ` th.WriteK("/app/overlay", `
commonLabels: commonLabels:
env: prod env: prod
bases: resources:
- ../base - ../base
patchesStrategicMerge: patchesStrategicMerge:
- ../shared/deployment-patch.yaml - ../shared/deployment-patch.yaml
@@ -371,21 +368,6 @@ spec:
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Service
metadata:
labels:
app: myApp
env: prod
name: a-myService
spec:
ports:
- port: 7002
selector:
app: myApp
backend: bungie
env: prod
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -409,6 +391,21 @@ spec:
containers: containers:
- image: whatever - image: whatever
name: whatever name: whatever
---
apiVersion: v1
kind: Service
metadata:
labels:
app: myApp
env: prod
name: a-myService
spec:
ports:
- port: 7002
selector:
app: myApp
backend: bungie
env: prod
`) `)
} }
@@ -416,7 +413,7 @@ func TestSmallOverlayJSONPatch(t *testing.T) {
th := kusttest_test.NewKustTestHarness(t, "/app/overlay") th := kusttest_test.NewKustTestHarness(t, "/app/overlay")
writeSmallBase(th) writeSmallBase(th)
th.WriteK("/app/overlay", ` th.WriteK("/app/overlay", `
bases: resources:
- ../base - ../base
patchesJson6902: patchesJson6902:
- target: - target:
@@ -436,19 +433,6 @@ patchesJson6902:
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Service
metadata:
labels:
app: myApp
name: a-myService
spec:
ports:
- port: 7002
selector:
app: myApp
backend: beagle
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -468,5 +452,18 @@ spec:
containers: containers:
- image: whatever - image: whatever
name: whatever name: whatever
---
apiVersion: v1
kind: Service
metadata:
labels:
app: myApp
name: a-myService
spec:
ports:
- port: 7002
selector:
app: myApp
backend: beagle
`) `)
} }

View File

@@ -68,6 +68,24 @@ metadata:
type: Opaque type: Opaque
--- ---
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.alpha.kubernetes.io/storage-class: default
labels:
app: release-name-minecraft
chart: minecraft-1.0.3
heritage: Tiller
release: release-name
name: LOOOOOOOONG-release-name-minecraft-datadir
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service kind: Service
metadata: metadata:
labels: labels:
@@ -85,23 +103,5 @@ spec:
selector: selector:
app: release-name-minecraft app: release-name-minecraft
type: LoadBalancer type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.alpha.kubernetes.io/storage-class: default
labels:
app: release-name-minecraft
chart: minecraft-1.0.3
heritage: Tiller
release: release-name
name: LOOOOOOOONG-release-name-minecraft-datadir
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
`) `)
} }

View File

@@ -190,7 +190,7 @@ configMapGenerator:
- from=base - from=base
`) `)
th.WriteK("/app/overlay/o1", ` th.WriteK("/app/overlay/o1", `
bases: resources:
- ../../base1 - ../../base1
configMapGenerator: configMapGenerator:
- name: com1 - name: com1
@@ -199,7 +199,7 @@ configMapGenerator:
- from=overlay - from=overlay
`) `)
th.WriteK("/app/overlay/o2", ` th.WriteK("/app/overlay/o2", `
bases: resources:
- ../../base2 - ../../base2
configMapGenerator: configMapGenerator:
- name: com2 - name: com2
@@ -208,7 +208,7 @@ configMapGenerator:
- from=overlay - from=overlay
`) `)
th.WriteK("/app/overlay", ` th.WriteK("/app/overlay", `
bases: resources:
- o1 - o1
- o2 - o2
configMapGenerator: configMapGenerator:

View File

@@ -278,7 +278,7 @@ func TestCrdWithOverlay(t *testing.T) {
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
namePrefix: prod- namePrefix: prod-
bases: resources:
- ../base - ../base
patchesStrategicMerge: patchesStrategicMerge:
- bee.yaml - bee.yaml
@@ -330,7 +330,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- crd.yaml - crd.yaml
images: images:
- name: test/test - name: test/test
newName: registry.gitlab.com/test newName: registry.gitlab.com/test

View File

@@ -41,27 +41,27 @@ vars:
fieldref: fieldref:
fieldpath: spec.diet fieldpath: spec.diet
resources: resources:
- animalPark.yaml
- giraffes.yaml - giraffes.yaml
- gorilla.yaml - gorilla.yaml
- animalPark.yaml
configurations: configurations:
- config/defaults.yaml - config/defaults.yaml
- config/custom.yaml - config/custom.yaml
`) `)
th.WriteF("/app/base/giraffes.yaml", ` th.WriteF("/app/base/giraffes.yaml", `
kind: Giraffe kind: Giraffe
metadata:
name: may
spec:
diet: acacia
location: SE
---
kind: Giraffe
metadata: metadata:
name: april name: april
spec: spec:
diet: mimosa diet: mimosa
location: NE location: NE
---
kind: Giraffe
metadata:
name: may
spec:
diet: acacia
location: SE
`) `)
th.WriteF("/app/base/gorilla.yaml", ` th.WriteF("/app/base/gorilla.yaml", `
kind: Gorilla kind: Gorilla
@@ -248,9 +248,8 @@ commonLabels:
patchesStrategicMerge: patchesStrategicMerge:
- animalPark.yaml - animalPark.yaml
resources: resources:
- ursus.yaml
bases:
- ../base - ../base
- ursus.yaml
`) `)
th.WriteF("/app/overlay/ursus.yaml", ` th.WriteF("/app/overlay/ursus.yaml", `
kind: Gorilla kind: Gorilla
@@ -312,15 +311,6 @@ spec:
location: SE location: SE
--- ---
kind: Gorilla kind: Gorilla
metadata:
labels:
movie: planetOfTheApes
name: o-ursus
spec:
diet: heston
location: Arizona
---
kind: Gorilla
metadata: metadata:
labels: labels:
app: myApp app: myApp
@@ -329,5 +319,14 @@ metadata:
spec: spec:
diet: bambooshoots diet: bambooshoots
location: SW location: SW
---
kind: Gorilla
metadata:
labels:
movie: planetOfTheApes
name: o-ursus
spec:
diet: heston
location: Arizona
`) `)
} }

View File

@@ -36,9 +36,9 @@ commonLabels:
commonAnnotations: commonAnnotations:
note: This is a test annotation note: This is a test annotation
resources: resources:
- service.yaml
- deployment.yaml - deployment.yaml
- networkpolicy.yaml - networkpolicy.yaml
- service.yaml
`) `)
th.WriteF("/app/base/service.yaml", ` th.WriteF("/app/base/service.yaml", `
apiVersion: v1 apiVersion: v1
@@ -237,52 +237,6 @@ func TestBaseWithGeneratorsAlone(t *testing.T) {
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
data:
foo: bar
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
org: example.com
team: foo
name: team-foo-configmap-in-base-bbdmdh7m8t
---
apiVersion: v1
data:
password: c29tZXB3
username: YWRtaW4=
kind: Secret
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
org: example.com
team: foo
name: team-foo-secret-in-base-tkm7hhtf8d
type: Opaque
---
apiVersion: v1
kind: Service
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
org: example.com
team: foo
name: team-foo-nginx
spec:
ports:
- port: 80
selector:
app: mynginx
org: example.com
team: foo
---
apiVersion: apps/v1beta2 apiVersion: apps/v1beta2
kind: Deployment kind: Deployment
metadata: metadata:
@@ -320,6 +274,52 @@ spec:
- configMap: - configMap:
name: team-foo-configmap-in-base-bbdmdh7m8t name: team-foo-configmap-in-base-bbdmdh7m8t
name: configmap-in-base name: configmap-in-base
---
apiVersion: v1
kind: Service
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
org: example.com
team: foo
name: team-foo-nginx
spec:
ports:
- port: 80
selector:
app: mynginx
org: example.com
team: foo
---
apiVersion: v1
data:
foo: bar
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
org: example.com
team: foo
name: team-foo-configmap-in-base-bbdmdh7m8t
---
apiVersion: v1
data:
password: c29tZXB3
username: YWRtaW4=
kind: Secret
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
org: example.com
team: foo
name: team-foo-secret-in-base-tkm7hhtf8d
type: Opaque
`) `)
} }
@@ -351,9 +351,9 @@ commonLabels:
env: staging env: staging
team: override-foo team: override-foo
patchesStrategicMerge: patchesStrategicMerge:
- deployment.yaml - deployment.yaml
bases: resources:
- ../app - ../app
configMapGenerator: configMapGenerator:
- name: configmap-in-overlay - name: configmap-in-overlay
literals: literals:
@@ -373,67 +373,6 @@ secretGenerator:
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
data:
hello: world
kind: ConfigMap
metadata:
labels:
env: staging
team: override-foo
name: staging-configmap-in-overlay-k7cbc75tg8
---
apiVersion: v1
data:
foo: override-bar
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: override-foo
name: staging-team-foo-configmap-in-base-gh9d7t85gb
---
apiVersion: v1
data:
password: c29tZXB3
proxy: aGFwcm94eQ==
username: YWRtaW4=
kind: Secret
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: override-foo
name: staging-team-foo-secret-in-base-c8db7gk2m2
type: Opaque
---
apiVersion: v1
kind: Service
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: override-foo
name: staging-team-foo-nginx
spec:
ports:
- port: 80
selector:
app: mynginx
env: staging
org: example.com
team: override-foo
---
apiVersion: apps/v1beta2 apiVersion: apps/v1beta2
kind: Deployment kind: Deployment
metadata: metadata:
@@ -478,6 +417,67 @@ spec:
- configMap: - configMap:
name: staging-team-foo-configmap-in-base-gh9d7t85gb name: staging-team-foo-configmap-in-base-gh9d7t85gb
name: configmap-in-base name: configmap-in-base
---
apiVersion: v1
kind: Service
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: override-foo
name: staging-team-foo-nginx
spec:
ports:
- port: 80
selector:
app: mynginx
env: staging
org: example.com
team: override-foo
---
apiVersion: v1
data:
foo: override-bar
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: override-foo
name: staging-team-foo-configmap-in-base-gh9d7t85gb
---
apiVersion: v1
data:
password: c29tZXB3
proxy: aGFwcm94eQ==
username: YWRtaW4=
kind: Secret
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: override-foo
name: staging-team-foo-secret-in-base-c8db7gk2m2
type: Opaque
---
apiVersion: v1
data:
hello: world
kind: ConfigMap
metadata:
labels:
env: staging
team: override-foo
name: staging-configmap-in-overlay-k7cbc75tg8
`) `)
} }

View File

@@ -78,7 +78,7 @@ configMapGenerator:
th.WriteK("/app/overlay", ` th.WriteK("/app/overlay", `
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
bases: resources:
- ../base - ../base
generatorOptions: generatorOptions:
disableNameSuffixHash: false disableNameSuffixHash: false
@@ -95,15 +95,6 @@ configMapGenerator:
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1 apiVersion: v1
data:
fruit: apple
kind: ConfigMap
metadata:
labels:
fruit: apple
name: shouldHaveHash-2k9hc848ff
---
apiVersion: v1
data: data:
foo: bar foo: bar
kind: ConfigMap kind: ConfigMap
@@ -111,5 +102,14 @@ metadata:
labels: labels:
foo: bar foo: bar
name: shouldNotHaveHash name: shouldNotHaveHash
---
apiVersion: v1
data:
fruit: apple
kind: ConfigMap
metadata:
labels:
fruit: apple
name: shouldHaveHash-2k9hc848ff
`) `)
} }

View File

@@ -256,15 +256,15 @@ func TestIssue596AllowDirectoriesThatAreSubstringsOfEachOther(t *testing.T) {
th := kusttest_test.NewKustTestHarness(t, "/app/overlays/aws-sandbox2.us-east-1") th := kusttest_test.NewKustTestHarness(t, "/app/overlays/aws-sandbox2.us-east-1")
th.WriteK("/app/base", "") th.WriteK("/app/base", "")
th.WriteK("/app/overlays/aws", ` th.WriteK("/app/overlays/aws", `
bases: resources:
- ../../base - ../../base
`) `)
th.WriteK("/app/overlays/aws-nonprod", ` th.WriteK("/app/overlays/aws-nonprod", `
bases: resources:
- ../aws - ../aws
`) `)
th.WriteK("/app/overlays/aws-sandbox2.us-east-1", ` th.WriteK("/app/overlays/aws-sandbox2.us-east-1", `
bases: resources:
- ../aws-nonprod - ../aws-nonprod
`) `)
m, err := th.MakeKustTarget().MakeCustomizedResMap() m, err := th.MakeKustTarget().MakeCustomizedResMap()
@@ -363,7 +363,7 @@ vars:
objref: objref:
kind: Service kind: Service
name: apple name: apple
bases: resources:
- ../../base - ../../base
`) `)
th.WriteK("/app/overlays/o2", ` th.WriteK("/app/overlays/o2", `
@@ -372,7 +372,7 @@ vars:
objref: objref:
kind: Leafy kind: Leafy
name: kale name: kale
bases: resources:
- ../o1 - ../o1
`) `)
ra, err := th.MakeKustTarget().AccumulateTarget() ra, err := th.MakeKustTarget().AccumulateTarget()
@@ -416,7 +416,7 @@ vars:
objref: objref:
kind: Service kind: Service
name: academy name: academy
bases: resources:
- ../../base - ../../base
`) `)
th.WriteK("/app/overlays/o2", ` th.WriteK("/app/overlays/o2", `
@@ -425,7 +425,7 @@ vars:
objref: objref:
kind: Leafy kind: Leafy
name: kale name: kale
bases: resources:
- ../o1 - ../o1
`) `)
_, err := th.MakeKustTarget().AccumulateTarget() _, err := th.MakeKustTarget().AccumulateTarget()

View File

@@ -90,7 +90,7 @@ commonLabels:
patchesStrategicMerge: patchesStrategicMerge:
- deployment-patch1.yaml - deployment-patch1.yaml
- deployment-patch2.yaml - deployment-patch2.yaml
bases: resources:
- ../../base - ../../base
configMapGenerator: configMapGenerator:
- name: configmap-in-overlay - name: configmap-in-overlay
@@ -148,49 +148,6 @@ spec:
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
data:
hello: world
kind: ConfigMap
metadata:
labels:
env: staging
name: staging-configmap-in-overlay-k7cbc75tg8
---
apiVersion: v1
data:
foo: bar
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: foo
name: staging-team-foo-configmap-in-base-g7k6gt2889
---
apiVersion: v1
kind: Service
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: foo
name: staging-team-foo-nginx
spec:
ports:
- port: 80
selector:
app: mynginx
env: staging
org: example.com
team: foo
---
apiVersion: apps/v1beta2 apiVersion: apps/v1beta2
kind: Deployment kind: Deployment
metadata: metadata:
@@ -242,6 +199,49 @@ spec:
- configMap: - configMap:
name: staging-team-foo-configmap-in-base-g7k6gt2889 name: staging-team-foo-configmap-in-base-g7k6gt2889
name: configmap-in-base name: configmap-in-base
---
apiVersion: v1
kind: Service
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: foo
name: staging-team-foo-nginx
spec:
ports:
- port: 80
selector:
app: mynginx
env: staging
org: example.com
team: foo
---
apiVersion: v1
data:
foo: bar
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: foo
name: staging-team-foo-configmap-in-base-g7k6gt2889
---
apiVersion: v1
data:
hello: world
kind: ConfigMap
metadata:
labels:
env: staging
name: staging-configmap-in-overlay-k7cbc75tg8
`) `)
} }

View File

@@ -107,38 +107,6 @@ data:
} }
//nolint //nolint
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
kustomize.config.k8s.io/Inventory: '{"current":{"apps_v1beta2_Deployment|default|my-mysql":null,"~G_v1_Secret|default|my-pass":[{"group":"apps","version":"v1beta2","kind":"Deployment","name":"my-mysql","namespace":"default"}],"~G_v1_Service|default|my-mmmysql":null}}'
kustomize.config.k8s.io/InventoryHash: kd67f7ht8t
name: haha
namespace: default
---
apiVersion: v1
data:
password: YWRtaW4=
username: jingfang
kind: Secret
metadata:
name: my-pass
namespace: default
type: Opaque
---
apiVersion: v1
kind: Service
metadata:
labels:
app: mysql
name: my-mmmysql
namespace: default
spec:
ports:
- port: 3306
selector:
app: mysql
---
apiVersion: apps/v1beta2 apiVersion: apps/v1beta2
kind: Deployment kind: Deployment
metadata: metadata:
@@ -175,5 +143,37 @@ spec:
volumes: volumes:
- emptyDir: {} - emptyDir: {}
name: mysql-persistent-storage name: mysql-persistent-storage
---
apiVersion: v1
kind: Service
metadata:
labels:
app: mysql
name: my-mmmysql
namespace: default
spec:
ports:
- port: 3306
selector:
app: mysql
---
apiVersion: v1
data:
password: YWRtaW4=
username: jingfang
kind: Secret
metadata:
name: my-pass
namespace: default
type: Opaque
---
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
kustomize.config.k8s.io/Inventory: '{"current":{"apps_v1beta2_Deployment|default|my-mysql":null,"~G_v1_Secret|default|my-pass":[{"group":"apps","version":"v1beta2","kind":"Deployment","name":"my-mysql","namespace":"default"}],"~G_v1_Service|default|my-mmmysql":null}}'
kustomize.config.k8s.io/InventoryHash: kd67f7ht8t
name: haha
namespace: default
`) `)
} }

View File

@@ -42,13 +42,13 @@ subjects:
func writeMidOverlays(th *kusttest_test.KustTestHarness) { func writeMidOverlays(th *kusttest_test.KustTestHarness) {
// Mid-level overlays // Mid-level overlays
th.WriteK("/app/overlays/a", ` th.WriteK("/app/overlays/a", `
bases: resources:
- ../../base - ../../base
namePrefix: a- namePrefix: a-
nameSuffix: -suffixA nameSuffix: -suffixA
`) `)
th.WriteK("/app/overlays/b", ` th.WriteK("/app/overlays/b", `
bases: resources:
- ../../base - ../../base
namePrefix: b- namePrefix: b-
nameSuffix: -suffixB nameSuffix: -suffixB
@@ -58,7 +58,7 @@ nameSuffix: -suffixB
func writeTopOverlay(th *kusttest_test.KustTestHarness) { func writeTopOverlay(th *kusttest_test.KustTestHarness) {
// Top overlay, combining the mid-level overlays // Top overlay, combining the mid-level overlays
th.WriteK("/app/combined", ` th.WriteK("/app/combined", `
bases: resources:
- ../overlays/a - ../overlays/a
- ../overlays/b - ../overlays/b
`) `)
@@ -162,11 +162,6 @@ kind: ServiceAccount
metadata: metadata:
name: a-pfx-serviceaccount-sfx-suffixA name: a-pfx-serviceaccount-sfx-suffixA
--- ---
apiVersion: v1
kind: ServiceAccount
metadata:
name: b-pfx-serviceaccount-sfx-suffixB
---
apiVersion: rbac.authorization.k8s.io/v1beta1 apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
@@ -179,6 +174,11 @@ subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: a-pfx-serviceaccount-sfx-suffixA name: a-pfx-serviceaccount-sfx-suffixA
--- ---
apiVersion: v1
kind: ServiceAccount
metadata:
name: b-pfx-serviceaccount-sfx-suffixB
---
apiVersion: rbac.authorization.k8s.io/v1beta1 apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
@@ -200,12 +200,11 @@ func TestMultibasesWithConflict(t *testing.T) {
writeTopOverlay(th) writeTopOverlay(th)
th.WriteK("/app/overlays/a", ` th.WriteK("/app/overlays/a", `
bases:
- ../../base
namePrefix: a- namePrefix: a-
nameSuffix: -suffixA nameSuffix: -suffixA
resources: resources:
- serviceaccount.yaml - serviceaccount.yaml
- ../../base
`) `)
// Expect an error because this resource in the overlay // Expect an error because this resource in the overlay
// matches a resource in the base. // matches a resource in the base.

View File

@@ -27,8 +27,11 @@ func TestVariableRef(t *testing.T) {
th.WriteK("/app/base", ` th.WriteK("/app/base", `
namePrefix: base- namePrefix: base-
resources: resources:
- cockroachdb-statefulset-secure.yaml - role-stuff.yaml
- cronjob.yaml - services.yaml
- statefulset.yaml
- cronjob.yaml
- pdb.yaml
configMapGenerator: configMapGenerator:
- name: test-config-map - name: test-config-map
literals: literals:
@@ -87,7 +90,54 @@ spec:
- name: CDB_PUBLIC_SVC - name: CDB_PUBLIC_SVC
value: "$(CDB_PUBLIC_SVC)" value: "$(CDB_PUBLIC_SVC)"
`) `)
th.WriteF("/app/base/cockroachdb-statefulset-secure.yaml", ` th.WriteF("/app/base/services.yaml", `
apiVersion: v1
kind: Service
metadata:
name: cockroachdb
labels:
app: cockroachdb
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
# Enable automatic monitoring of all instances when Prometheus is running in the cluster.
prometheus.io/scrape: "true"
prometheus.io/path: "_status/vars"
prometheus.io/port: "8080"
spec:
ports:
- port: 26257
targetPort: 26257
name: grpc
- port: 8080
targetPort: 8080
name: http
clusterIP: None
selector:
app: cockroachdb
---
apiVersion: v1
kind: Service
metadata:
# This service is meant to be used by clients of the database. It exposes a ClusterIP that will
# automatically load balance connections to the different database pods.
name: cockroachdb-public
labels:
app: cockroachdb
spec:
ports:
# The main port, served by gRPC, serves Postgres-flavor SQL, internode
# traffic and the cli.
- port: 26257
targetPort: 26257
name: grpc
# The secondary port serves the UI as well as health and debug endpoints.
- port: 8080
targetPort: 8080
name: http
selector:
app: cockroachdb
`)
th.WriteF("/app/base/role-stuff.yaml", `
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
@@ -155,53 +205,8 @@ subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: cockroachdb name: cockroachdb
namespace: default namespace: default
--- `)
apiVersion: v1 th.WriteF("/app/base/pdb.yaml", `
kind: Service
metadata:
# This service is meant to be used by clients of the database. It exposes a ClusterIP that will
# automatically load balance connections to the different database pods.
name: cockroachdb-public
labels:
app: cockroachdb
spec:
ports:
# The main port, served by gRPC, serves Postgres-flavor SQL, internode
# traffic and the cli.
- port: 26257
targetPort: 26257
name: grpc
# The secondary port serves the UI as well as health and debug endpoints.
- port: 8080
targetPort: 8080
name: http
selector:
app: cockroachdb
---
apiVersion: v1
kind: Service
metadata:
name: cockroachdb
labels:
app: cockroachdb
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
# Enable automatic monitoring of all instances when Prometheus is running in the cluster.
prometheus.io/scrape: "true"
prometheus.io/path: "_status/vars"
prometheus.io/port: "8080"
spec:
ports:
- port: 26257
targetPort: 26257
name: grpc
- port: 8080
targetPort: 8080
name: http
clusterIP: None
selector:
app: cockroachdb
---
apiVersion: policy/v1beta1 apiVersion: policy/v1beta1
kind: PodDisruptionBudget kind: PodDisruptionBudget
metadata: metadata:
@@ -213,7 +218,8 @@ spec:
matchLabels: matchLabels:
app: cockroachdb app: cockroachdb
maxUnavailable: 1 maxUnavailable: 1
--- `)
th.WriteF("/app/base/statefulset.yaml", `
apiVersion: apps/v1beta1 apiVersion: apps/v1beta1
kind: StatefulSet kind: StatefulSet
metadata: metadata:
@@ -324,7 +330,7 @@ spec:
`) `)
th.WriteK("/app/overlay/staging", ` th.WriteK("/app/overlay/staging", `
namePrefix: dev- namePrefix: dev-
bases: resources:
- ../../base - ../../base
`) `)
m, err := th.MakeKustTarget().MakeCustomizedResMap() m, err := th.MakeKustTarget().MakeCustomizedResMap()
@@ -401,14 +407,6 @@ subjects:
namespace: default namespace: default
--- ---
apiVersion: v1 apiVersion: v1
data:
baz: qux
foo: bar
kind: ConfigMap
metadata:
name: dev-base-test-config-map-b2g2dmd64b
---
apiVersion: v1
kind: Service kind: Service
metadata: metadata:
annotations: annotations:
@@ -575,6 +573,14 @@ spec:
selector: selector:
matchLabels: matchLabels:
app: cockroachdb app: cockroachdb
---
apiVersion: v1
data:
baz: qux
foo: bar
kind: ConfigMap
metadata:
name: dev-base-test-config-map-b2g2dmd64b
`) `)
} }
@@ -582,9 +588,9 @@ func TestVariableRefIngress(t *testing.T) {
th := kusttest_test.NewKustTestHarness(t, "/app/overlay") th := kusttest_test.NewKustTestHarness(t, "/app/overlay")
th.WriteK("/app/base", ` th.WriteK("/app/base", `
resources: resources:
- service.yaml
- deployment.yaml - deployment.yaml
- ingress.yaml - ingress.yaml
- service.yaml
vars: vars:
- name: DEPLOYMENT_NAME - name: DEPLOYMENT_NAME
@@ -655,7 +661,7 @@ spec:
`) `)
th.WriteK("/app/overlay", ` th.WriteK("/app/overlay", `
nameprefix: kustomized- nameprefix: kustomized-
bases: resources:
- ../base - ../base
`) `)
m, err := th.MakeKustTarget().MakeCustomizedResMap() m, err := th.MakeKustTarget().MakeCustomizedResMap()
@@ -768,11 +774,6 @@ vars:
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Namespace
metadata:
name: my-namespace
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -792,6 +793,11 @@ spec:
volumes: volumes:
- emptyDir: {} - emptyDir: {}
name: my-volume name: my-volume
---
apiVersion: v1
kind: Namespace
metadata:
name: my-namespace
`) `)
} }
@@ -834,11 +840,6 @@ vars:
t.Fatalf("Err: %v", err) t.Fatalf("Err: %v", err)
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Namespace
metadata:
name: my-namespace
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@@ -851,6 +852,11 @@ spec:
containers: containers:
- image: busybox - image: busybox
name: app name: app
---
apiVersion: v1
kind: Namespace
metadata:
name: my-namespace
`) `)
} }
@@ -858,7 +864,7 @@ func TestVaribaleRefDifferentPrefix(t *testing.T) {
th := kusttest_test.NewKustTestHarness(t, "/app/base") th := kusttest_test.NewKustTestHarness(t, "/app/base")
th.WriteK("/app/base", ` th.WriteK("/app/base", `
namePrefix: base- namePrefix: base-
bases: resources:
- dev - dev
- test - test
`) `)
@@ -948,28 +954,6 @@ spec:
} }
th.AssertActualEqualsExpected(m, ` th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Service
metadata:
name: base-dev-elasticsearch
spec:
clusterIP: None
ports:
- name: transport
port: 9300
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: base-test-elasticsearch
spec:
clusterIP: None
ports:
- name: transport
port: 9300
protocol: TCP
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: StatefulSet kind: StatefulSet
metadata: metadata:
@@ -983,6 +967,17 @@ spec:
value: base-dev-elasticsearch.monitoring.svc.cluster.local value: base-dev-elasticsearch.monitoring.svc.cluster.local
name: elasticsearch name: elasticsearch
--- ---
apiVersion: v1
kind: Service
metadata:
name: base-dev-elasticsearch
spec:
clusterIP: None
ports:
- name: transport
port: 9300
protocol: TCP
---
apiVersion: apps/v1 apiVersion: apps/v1
kind: StatefulSet kind: StatefulSet
metadata: metadata:
@@ -995,5 +990,16 @@ spec:
- name: DISCOVERY_SERVICE - name: DISCOVERY_SERVICE
value: base-test-elasticsearch.monitoring.svc.cluster.local value: base-test-elasticsearch.monitoring.svc.cluster.local
name: elasticsearch name: elasticsearch
---
apiVersion: v1
kind: Service
metadata:
name: base-test-elasticsearch
spec:
clusterIP: None
ports:
- name: transport
port: 9300
protocol: TCP
`) `)
} }

View File

@@ -99,7 +99,7 @@ name: pruneCM
namespace: default namespace: default
`, content) `, content)
th.AssertActualEqualsExpected(rm, inv+"---"+content) th.AssertActualEqualsExpected(rm, content+"---"+inv)
} }
func TestInventoryTransformerDefaultPolicy(t *testing.T) { func TestInventoryTransformerDefaultPolicy(t *testing.T) {
@@ -120,5 +120,5 @@ name: pruneCM
namespace: default namespace: default
`, content) `, content)
th.AssertActualEqualsExpected(rm, inv+"---"+content) th.AssertActualEqualsExpected(rm, content+"---"+inv)
} }

View File

@@ -80,15 +80,22 @@ metadata:
th.AssertActualEqualsExpected(rm, ` th.AssertActualEqualsExpected(rm, `
apiVersion: v1 apiVersion: v1
kind: ConfigMap
metadata:
name: cm1
namespace: test
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cm2
namespace: test
---
apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: ns1 name: ns1
--- ---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: crd
---
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
@@ -116,17 +123,10 @@ subjects:
name: another name: another
namespace: random namespace: random
--- ---
apiVersion: v1 apiVersion: apiextensions.k8s.io/v1beta1
kind: ConfigMap kind: CustomResourceDefinition
metadata: metadata:
name: cm1 name: crd
namespace: test
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cm2
namespace: test
`) `)
} }

View File

@@ -48,6 +48,14 @@ metadata:
`) `)
th.AssertActualEqualsExpected(rm, ` th.AssertActualEqualsExpected(rm, `
apiVersion: v1
kind: Service
metadata:
name: baked-apple-pie
spec:
ports:
- port: 7002
---
apiVersion: apiextensions.k8s.io/v1beta1 apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition kind: CustomResourceDefinition
metadata: metadata:
@@ -57,13 +65,5 @@ apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: baked-cm-pie name: baked-cm-pie
---
apiVersion: v1
kind: Service
metadata:
name: baked-apple-pie
spec:
ports:
- port: 7002
`) `)
} }

View File

@@ -109,16 +109,16 @@ spec:
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: myapp name: otherapp
spec: spec:
replicas: 23 replicas: 5
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: otherapp name: myapp
spec: spec:
replicas: 5 replicas: 23
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: StatefulSet kind: StatefulSet

View File

@@ -49,6 +49,24 @@ metadata:
type: Opaque type: Opaque
--- ---
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.alpha.kubernetes.io/storage-class: default
labels:
app: release-name-minecraft
chart: minecraft-1.0.3
heritage: Tiller
release: release-name
name: release-name-minecraft-datadir
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service kind: Service
metadata: metadata:
labels: labels:
@@ -66,23 +84,5 @@ spec:
selector: selector:
app: release-name-minecraft app: release-name-minecraft
type: LoadBalancer type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.alpha.kubernetes.io/storage-class: default
labels:
app: release-name-minecraft
chart: minecraft-1.0.3
heritage: Tiller
release: release-name
name: release-name-minecraft-datadir
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
`) `)
} }