Skip to content

Commit 436a047

Browse files
re-enabled TestFnContainerTransformer with e2econtainerconfig container
1 parent bf6e6ad commit 436a047

File tree

1 file changed

+29
-83
lines changed

1 file changed

+29
-83
lines changed

api/krusty/fnplugin_test.go

Lines changed: 29 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -714,103 +714,49 @@ spec:
714714
}
715715

716716
func TestFnContainerTransformer(t *testing.T) {
717-
t.Skip("wait for #3881")
718717
skipIfNoDocker(t)
719-
720-
// Function plugins should not need the env setup done by MakeEnhancedHarness
721718
th := kusttest_test.MakeHarness(t)
722-
723-
th.WriteK(".", `
719+
o := th.MakeOptionsPluginsEnabled()
720+
fSys := filesys.MakeFsOnDisk()
721+
b := MakeKustomizer(&o)
722+
tmpDir, err := filesys.NewTmpConfirmedDir()
723+
assert.NoError(t, err)
724+
assert.NoError(t, fSys.WriteFile(filepath.Join(tmpDir.String(), "kustomization.yaml"), []byte(`
724725
resources:
725-
- data.yaml
726+
- deployment.yaml
726727
transformers:
727-
- transf1.yaml
728-
- transf2.yaml
729-
`)
730-
731-
th.WriteF("data.yaml", `
728+
- e2econtainerconfig.yaml
729+
`)))
730+
assert.NoError(t, fSys.WriteFile(filepath.Join(tmpDir.String(), "deployment.yaml"), []byte(`
732731
apiVersion: apps/v1
733732
kind: Deployment
734733
metadata:
735-
name: nginx
736-
labels:
737-
app: nginx
738-
annotations:
739-
tshirt-size: small # this injects the resource reservations
740-
spec:
741-
selector:
742-
matchLabels:
743-
app: nginx
744-
template:
745-
metadata:
746-
labels:
747-
app: nginx
748-
spec:
749-
containers:
750-
- name: nginx
751-
image: nginx
752-
`)
753-
// This transformer should add resource reservations based on annotation in data.yaml
754-
// See https://github.com/kubernetes-sigs/kustomize/tree/master/functions/examples/injection-tshirt-sizes
755-
th.WriteF("transf1.yaml", `
756-
apiVersion: examples.config.kubernetes.io/v1beta1
757-
kind: Validator
758-
metadata:
759-
name: valid
760-
annotations:
761-
config.kubernetes.io/function: |-
762-
container:
763-
image: gcr.io/kustomize-functions/example-tshirt:v0.2.0
764-
`)
765-
// This transformer will check resources without and won't do any changes
766-
// See https://github.com/kubernetes-sigs/kustomize/tree/master/functions/examples/validator-kubeval
767-
th.WriteF("transf2.yaml", `
768-
apiVersion: examples.config.kubernetes.io/v1beta1
769-
kind: Kubeval
734+
name: foo
735+
`)))
736+
737+
assert.NoError(t, fSys.WriteFile(filepath.Join(tmpDir.String(), "e2econtainerconfig.yaml"), []byte(`
738+
apiVersion: example.com/v1alpha1
739+
kind: Input
770740
metadata:
771-
name: validate
741+
name: foo
772742
annotations:
773743
config.kubernetes.io/function: |
774744
container:
775-
image: gcr.io/kustomize-functions/example-validator-kubeval:v0.1.0
776-
spec:
777-
strict: true
778-
ignoreMissingSchemas: true
779-
780-
# TODO: Update this to use network/volumes features.
781-
# Relevant issues:
782-
# - https://github.com/kubernetes-sigs/kustomize/issues/1901
783-
# - https://github.com/kubernetes-sigs/kustomize/issues/1902
784-
kubernetesVersion: "1.16.0"
785-
schemaLocation: "file:///schemas"
786-
`)
787-
m := th.Run(".", th.MakeOptionsPluginsEnabled())
788-
th.AssertActualEqualsExpected(m, `
789-
apiVersion: apps/v1
745+
image: "gcr.io/kustomize-functions/e2econtainerconfig"
746+
`)))
747+
m, err := b.Run(fSys, tmpDir.String())
748+
assert.NoError(t, err)
749+
actual, err := m.AsYaml()
750+
assert.NoError(t, err)
751+
assert.Equal(t, `apiVersion: apps/v1
790752
kind: Deployment
791753
metadata:
792754
annotations:
793-
tshirt-size: small
794-
labels:
795-
app: nginx
796-
name: nginx
797-
spec:
798-
selector:
799-
matchLabels:
800-
app: nginx
801-
template:
802-
metadata:
803-
labels:
804-
app: nginx
805-
spec:
806-
containers:
807-
- image: nginx
808-
name: nginx
809-
resources:
810-
requests:
811-
cpu: 200m
812-
memory: 50M
813-
`)
755+
a-bool-value: "false"
756+
a-int-value: "0"
757+
a-string-value: ""
758+
name: foo
759+
`, string(actual))
814760
}
815761

816762
func TestFnContainerTransformerWithConfig(t *testing.T) {

0 commit comments

Comments
 (0)