@@ -69,3 +69,52 @@ data "kustomization" "test" {
69
69
}
70
70
` , path )
71
71
}
72
+
73
+ func TestAccDataSourceKustomization_helmChart (t * testing.T ) {
74
+
75
+ resource .Test (t , resource.TestCase {
76
+ //PreCheck: func() { testAccPreCheck(t) },
77
+ Providers : testAccProviders ,
78
+ Steps : []resource.TestStep {
79
+ {
80
+ Config : testAccDataSourceKustomizationConfig_helm ("test_kustomizations/helm/initial" , false ),
81
+ Check : resource .ComposeAggregateTestCheckFunc (
82
+ resource .TestCheckResourceAttrSet ("data.kustomization_build.test" , "id" ),
83
+ resource .TestCheckResourceAttrSet ("data.kustomization_build.test" , "path" ),
84
+ resource .TestCheckResourceAttr ("data.kustomization_build.test" , "path" , "test_kustomizations/helm/initial" ),
85
+ resource .TestCheckResourceAttr ("data.kustomization_build.test" , "ids.#" , "4" ),
86
+ resource .TestCheckResourceAttr ("data.kustomization_build.test" , "ids_prio.#" , "3" ),
87
+ resource .TestCheckResourceAttr ("data.kustomization_build.test" , "manifests.%" , "4" ),
88
+ resource .TestCheckOutput ("service" , "{\" apiVersion\" :\" v1\" ,\" kind\" :\" Service\" ,\" metadata\" :{\" creationTimestamp\" :null,\" labels\" :{\" app\" :\" nginx\" },\" name\" :\" nginx\" ,\" namespace\" :\" test-basic\" },\" spec\" :{\" ports\" :[{\" name\" :\" http\" ,\" port\" :80,\" protocol\" :\" TCP\" ,\" targetPort\" :80}],\" selector\" :{\" app\" :\" nginx\" },\" type\" :\" ClusterIP\" },\" status\" :{\" loadBalancer\" :{}}}" ),
89
+ resource .TestCheckOutput ("deployment" , "{\" apiVersion\" :\" apps/v1\" ,\" kind\" :\" Deployment\" ,\" metadata\" :{\" creationTimestamp\" :null,\" labels\" :{\" app\" :\" nginx\" },\" name\" :\" nginx\" ,\" namespace\" :\" test-basic\" },\" spec\" :{\" replicas\" :1,\" selector\" :{\" matchLabels\" :{\" app\" :\" nginx\" }},\" strategy\" :{},\" template\" :{\" metadata\" :{\" creationTimestamp\" :null,\" labels\" :{\" app\" :\" nginx\" }},\" spec\" :{\" containers\" :[{\" image\" :\" nginx:6.0.10\" ,\" name\" :\" test-basic\" ,\" resources\" :{}}]}}},\" status\" :{}}" ),
90
+ ),
91
+ },
92
+ },
93
+ })
94
+ }
95
+
96
+ func testAccDataSourceKustomizationConfig_helm (path string , legacy bool ) string {
97
+ return fmt .Sprintf (`
98
+
99
+ provider "kustomization" {
100
+ legacy_id_format = %v
101
+ }
102
+
103
+ data "kustomization_build" "test" {
104
+ path = "%s"
105
+
106
+ kustomize_options = {
107
+ enable_helm = true
108
+ helm_path = "helm"
109
+ }
110
+ }
111
+
112
+ output "service" {
113
+ value = data.kustomization_build.test.manifests["_/Service/test-basic/nginx"]
114
+ }
115
+
116
+ output "deployment" {
117
+ value = data.kustomization_build.test.manifests["apps/Deployment/test-basic/nginx"]
118
+ }
119
+ ` , legacy , path )
120
+ }
0 commit comments