88 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
99)
1010
11+ // TestAccKubernetesDataSourceConfigMap_basic tests that the data source is able to read
12+ // plaintext data, binary data, annotation, label, and name of the config map resource.
1113func TestAccKubernetesDataSourceConfigMap_basic (t * testing.T ) {
1214 name := fmt .Sprintf ("tf-acc-test-%s" , acctest .RandStringFromCharSet (10 , acctest .CharSetAlphaNum ))
1315
@@ -19,31 +21,45 @@ func TestAccKubernetesDataSourceConfigMap_basic(t *testing.T) {
1921 Config : testAccKubernetesDataSourceConfigMapConfig_basic (name ),
2022 Check : resource .ComposeAggregateTestCheckFunc (
2123 resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "metadata.0.name" , name ),
22- resource .TestCheckResourceAttrSet ("data.kubernetes_config_map.test" , "metadata.0.generation" ),
23- resource .TestCheckResourceAttrSet ("data.kubernetes_config_map.test" , "metadata.0.resource_version" ),
24- resource .TestCheckResourceAttrSet ("data.kubernetes_config_map.test" , "metadata.0.self_link" ),
25- resource .TestCheckResourceAttrSet ("data.kubernetes_config_map.test" , "metadata.0.uid" ),
26- resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "metadata.0.annotations.%" , "2" ),
2724 resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "metadata.0.annotations.TestAnnotationOne" , "one" ),
28- resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "metadata.0.annotations.TestAnnotationTwo" , "two" ),
2925 resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "metadata.0.labels.TestLabelOne" , "one" ),
30- resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "metadata.0.labels.TestLabelTwo" , "two" ),
31- resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "metadata.0.labels.TestLabelThree" , "three" ),
32- resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "data.%" , "2" ),
3326 resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "data.one" , "first" ),
34- resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "data.two " , "second " ),
27+ resource .TestCheckResourceAttr ("data.kubernetes_config_map.test" , "binary_data.raw " , "UmF3IGRhdGEgc2hvdWxkIGNvbWUgYmFjayBhcyBpcyBpbiB0aGUgcG9k " ),
3528 ),
3629 },
3730 },
3831 })
3932}
4033
34+ // testAccKubernetesDataSourceConfigMapConfig_basic provides the terraform config
35+ // used to test basic functionality of the config_map data source.
4136func testAccKubernetesDataSourceConfigMapConfig_basic (name string ) string {
42- return testAccKubernetesConfigMapConfig_basic (name ) + `
37+ return fmt .Sprintf (`
38+ resource "kubernetes_config_map" "test" {
39+ metadata {
40+ annotations = {
41+ TestAnnotationOne = "one"
42+ }
43+
44+ labels = {
45+ TestLabelOne = "one"
46+ }
47+
48+ name = "%s"
49+ }
50+
51+ data = {
52+ one = "first"
53+ }
54+
55+ binary_data = {
56+ raw = "${base64encode("Raw data should come back as is in the pod")}"
57+ }
58+ }
59+
4360data "kubernetes_config_map" "test" {
4461 metadata {
4562 name = "${kubernetes_config_map.test.metadata.0.name}"
4663 }
47- }
48- `
64+ }` , name )
4965}
0 commit comments