@@ -714,103 +714,49 @@ spec:
714
714
}
715
715
716
716
func TestFnContainerTransformer (t * testing.T ) {
717
- t .Skip ("wait for #3881" )
718
717
skipIfNoDocker (t )
719
-
720
- // Function plugins should not need the env setup done by MakeEnhancedHarness
721
718
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 (`
724
725
resources:
725
- - data .yaml
726
+ - deployment .yaml
726
727
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 (`
732
731
apiVersion: apps/v1
733
732
kind: Deployment
734
733
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
770
740
metadata:
771
- name: validate
741
+ name: foo
772
742
annotations:
773
743
config.kubernetes.io/function: |
774
744
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
790
752
kind: Deployment
791
753
metadata:
792
754
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 ))
814
760
}
815
761
816
762
func TestFnContainerTransformerWithConfig (t * testing.T ) {
0 commit comments