diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 0a61c6af..d9568224 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -1227,6 +1227,7 @@ The following attributes are exported: * `creation` - (Optional/Computed) Creation option for etcd service (string) * `external_urls` - (Optional) External urls for etcd service (list) * `extra_args` - (Optional/Computed) Extra arguments for etcd service (map) +* `extra_args_array` - (Optional/Computed) Extra arguments array for etcd service (list) * `extra_binds` - (Optional) Extra binds for etcd service (list) * `extra_env` - (Optional) Extra environment for etcd service (list) * `gid` - (Optional) Etcd service GID. Default: `0`. For Rancher v2.3.x and above (int) @@ -1269,6 +1270,7 @@ The following attributes are exported: * `audit_log` - (Optional) K8s audit log configuration. (list maxitems: 1) * `event_rate_limit` - (Optional) K8s event rate limit configuration. (list maxitems: 1) * `extra_args` - (Optional/Computed) Extra arguments for kube API service (map) +* `extra_args_array` - (Optional/Computed) Extra arguments array for kube API service (list) * `extra_binds` - (Optional) Extra binds for kube API service (list) * `extra_env` - (Optional) Extra environment for kube API service (list) * `image` - (Optional/Computed) Docker image for kube API service (string) @@ -1391,6 +1393,7 @@ EOF * `cluster_cidr` - (Optional/Computed) Cluster CIDR option for kube controller service (string) * `extra_args` - (Optional/Computed) Extra arguments for kube controller service (map) +* `extra_args_array` - (Optional/Computed) Extra arguments array for kube controller service (list) * `extra_binds` - (Optional) Extra binds for kube controller service (list) * `extra_env` - (Optional) Extra environment for kube controller service (list) * `image` - (Optional/Computed) Docker image for kube controller service (string) @@ -1403,6 +1406,7 @@ EOF * `cluster_dns_server` - (Optional/Computed) Cluster DNS Server option for kubelet service (string) * `cluster_domain` - (Optional/Computed) Cluster Domain option for kubelet service (string) * `extra_args` - (Optional/Computed) Extra arguments for kubelet service (map) +* `extra_args_array` - (Optional/Computed) Extra arguments array for kubelet service (list) * `extra_binds` - (Optional) Extra binds for kubelet service (list) * `extra_env` - (Optional) Extra environment for kubelet service (list) * `fail_swap_on` - (Optional/Computed) Enable or disable failing when swap on is not supported (bool) @@ -1415,6 +1419,7 @@ EOF ###### Arguments * `extra_args` - (Optional/Computed) Extra arguments for kubeproxy service (map) +* `extra_args_array` - (Optional/Computed) Extra arguments array for kubeproxy service (list) * `extra_binds` - (Optional) Extra binds for kubeproxy service (list) * `extra_env` - (Optional) Extra environment for kubeproxy service (list) * `image` - (Optional/Computed) Docker image for kubeproxy service (string) @@ -1424,6 +1429,7 @@ EOF ###### Arguments * `extra_args` - (Optional/Computed) Extra arguments for scheduler service (map) +* `extra_args_array` - (Optional/Computed) Extra arguments array for scheduler service (list) * `extra_binds` - (Optional) Extra binds for scheduler service (list) * `extra_env` - (Optional) Extra environment for scheduler service (list) * `image` - (Optional/Computed) Docker image for scheduler service (string) diff --git a/rancher2/schema_cluster_rke_config_services_etcd.go b/rancher2/schema_cluster_rke_config_services_etcd.go index f65c3ac1..02578a3a 100644 --- a/rancher2/schema_cluster_rke_config_services_etcd.go +++ b/rancher2/schema_cluster_rke_config_services_etcd.go @@ -81,6 +81,30 @@ func clusterRKEConfigServicesEtcdBackupConfigFields() map[string]*schema.Schema return s } +func clusterRKEConfigServicesEtcdExtraArgsArrayFields() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "extra_arg": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "argument": { + Required: true, + Type: schema.TypeString, + }, + "values": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + } +} + func clusterRKEConfigServicesEtcdFields() map[string]*schema.Schema { s := map[string]*schema.Schema{ "backup_config": { @@ -120,6 +144,15 @@ func clusterRKEConfigServicesEtcdFields() map[string]*schema.Schema { Optional: true, Computed: true, }, + "extra_args_array": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Extra Arguments that can be specified multiple times which are added to etcd services", + Elem: &schema.Resource{ + Schema: clusterRKEConfigServicesEtcdExtraArgsArrayFields(), + }, + }, "extra_binds": { Type: schema.TypeList, Optional: true, diff --git a/rancher2/schema_cluster_rke_config_services_kube_api.go b/rancher2/schema_cluster_rke_config_services_kube_api.go index 9153716a..a6c0ea4e 100644 --- a/rancher2/schema_cluster_rke_config_services_kube_api.go +++ b/rancher2/schema_cluster_rke_config_services_kube_api.go @@ -402,6 +402,30 @@ func clusterRKEConfigServicesKubeAPIEventRateLimitFieldsData() map[string]*schem return s } +func clusterRKEConfigServicesKubeAPIExtraArgsArrayFields() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "extra_arg": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "argument": { + Required: true, + Type: schema.TypeString, + }, + "values": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + } +} + func clusterRKEConfigServicesKubeAPISecretsEncryptionConfigFieldsV0() map[string]*schema.Schema { s := map[string]*schema.Schema{ "custom_config": { @@ -517,6 +541,15 @@ func clusterRKEConfigServicesKubeAPIFieldsV0() map[string]*schema.Schema { Optional: true, Computed: true, }, + "extra_args_array": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Extra Arguments that can be specified multiple times which are added to kube-api services", + Elem: &schema.Resource{ + Schema: clusterRKEConfigServicesKubeAPIExtraArgsArrayFields(), + }, + }, "extra_binds": { Type: schema.TypeList, Optional: true, @@ -600,6 +633,15 @@ func clusterRKEConfigServicesKubeAPIFields() map[string]*schema.Schema { Optional: true, Computed: true, }, + "extra_args_array": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Extra Arguments that can be specified multiple times which are added to kube-api services", + Elem: &schema.Resource{ + Schema: clusterRKEConfigServicesKubeAPIExtraArgsArrayFields(), + }, + }, "extra_binds": { Type: schema.TypeList, Optional: true, @@ -684,6 +726,15 @@ func clusterRKEConfigServicesKubeAPIFieldsData() map[string]*schema.Schema { Optional: true, Computed: true, }, + "extra_args_array": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Extra Arguments that can be specified multiple times which are added to kube-api services", + Elem: &schema.Resource{ + Schema: clusterRKEConfigServicesKubeAPIExtraArgsArrayFields(), + }, + }, "extra_binds": { Type: schema.TypeList, Optional: true, diff --git a/rancher2/schema_cluster_rke_config_services_kube_controller.go b/rancher2/schema_cluster_rke_config_services_kube_controller.go index 0df3541b..dc7a5241 100644 --- a/rancher2/schema_cluster_rke_config_services_kube_controller.go +++ b/rancher2/schema_cluster_rke_config_services_kube_controller.go @@ -6,6 +6,30 @@ import ( //Schemas +func clusterRKEConfigServicesKubeControllerExtraArgsArrayFields() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "extra_arg": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "argument": { + Required: true, + Type: schema.TypeString, + }, + "values": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + } +} + func clusterRKEConfigServicesKubeControllerFields() map[string]*schema.Schema { s := map[string]*schema.Schema{ "cluster_cidr": { @@ -18,6 +42,15 @@ func clusterRKEConfigServicesKubeControllerFields() map[string]*schema.Schema { Optional: true, Computed: true, }, + "extra_args_array": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Extra Arguments that can be specified multiple times which are added to kube-controller services", + Elem: &schema.Resource{ + Schema: clusterRKEConfigServicesKubeControllerExtraArgsArrayFields(), + }, + }, "extra_binds": { Type: schema.TypeList, Optional: true, diff --git a/rancher2/schema_cluster_rke_config_services_kubelet.go b/rancher2/schema_cluster_rke_config_services_kubelet.go index e91536c3..444557e0 100644 --- a/rancher2/schema_cluster_rke_config_services_kubelet.go +++ b/rancher2/schema_cluster_rke_config_services_kubelet.go @@ -6,6 +6,30 @@ import ( //Schemas +func clusterRKEConfigServicesKubeletExtraArgsArrayFields() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "extra_arg": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "argument": { + Required: true, + Type: schema.TypeString, + }, + "values": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + } +} + func clusterRKEConfigServicesKubeletFields() map[string]*schema.Schema { s := map[string]*schema.Schema{ "cluster_dns_server": { @@ -23,6 +47,15 @@ func clusterRKEConfigServicesKubeletFields() map[string]*schema.Schema { Optional: true, Computed: true, }, + "extra_args_array": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Extra Arguments that can be specified multiple times which are added to kubelet services", + Elem: &schema.Resource{ + Schema: clusterRKEConfigServicesKubeletExtraArgsArrayFields(), + }, + }, "extra_binds": { Type: schema.TypeList, Optional: true, diff --git a/rancher2/schema_cluster_rke_config_services_kubeproxy.go b/rancher2/schema_cluster_rke_config_services_kubeproxy.go index 0f306997..18e16296 100644 --- a/rancher2/schema_cluster_rke_config_services_kubeproxy.go +++ b/rancher2/schema_cluster_rke_config_services_kubeproxy.go @@ -6,6 +6,30 @@ import ( //Schemas +func clusterRKEConfigServicesKubeproxyExtraArgsArrayFields() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "extra_arg": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "argument": { + Required: true, + Type: schema.TypeString, + }, + "values": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + } +} + func clusterRKEConfigServicesKubeproxyFields() map[string]*schema.Schema { s := map[string]*schema.Schema{ "extra_args": { @@ -13,6 +37,15 @@ func clusterRKEConfigServicesKubeproxyFields() map[string]*schema.Schema { Optional: true, Computed: true, }, + "extra_args_array": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Extra Arguments that can be specified multiple times which are added to kubeproxy services", + Elem: &schema.Resource{ + Schema: clusterRKEConfigServicesKubeproxyExtraArgsArrayFields(), + }, + }, "extra_binds": { Type: schema.TypeList, Optional: true, diff --git a/rancher2/schema_cluster_rke_config_services_scheduler.go b/rancher2/schema_cluster_rke_config_services_scheduler.go index 73677f4d..15fabb6f 100644 --- a/rancher2/schema_cluster_rke_config_services_scheduler.go +++ b/rancher2/schema_cluster_rke_config_services_scheduler.go @@ -6,6 +6,30 @@ import ( //Schemas +func clusterRKEConfigServicesSchedulerExtraArgsArrayFields() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "extra_arg": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "argument": { + Required: true, + Type: schema.TypeString, + }, + "values": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + } +} + func clusterRKEConfigServicesSchedulerFields() map[string]*schema.Schema { s := map[string]*schema.Schema{ "extra_args": { @@ -13,6 +37,15 @@ func clusterRKEConfigServicesSchedulerFields() map[string]*schema.Schema { Optional: true, Computed: true, }, + "extra_args_array": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Extra Arguments that can be specified multiple times which are added to scheduler services", + Elem: &schema.Resource{ + Schema: clusterRKEConfigServicesSchedulerExtraArgsArrayFields(), + }, + }, "extra_binds": { Type: schema.TypeList, Optional: true, diff --git a/rancher2/structure_cluster_rke_config_services_etcd.go b/rancher2/structure_cluster_rke_config_services_etcd.go index 0e13d85d..4c49ce25 100644 --- a/rancher2/structure_cluster_rke_config_services_etcd.go +++ b/rancher2/structure_cluster_rke_config_services_etcd.go @@ -123,6 +123,10 @@ func flattenClusterRKEConfigServicesEtcd(in *managementClient.ETCDService, p []i obj["extra_args"] = toMapInterface(in.ExtraArgs) } + if len(in.ExtraArgsArray) > 0 { + obj["extra_args_array"] = flattenExtraArgsArray(in.ExtraArgsArray) + } + if len(in.ExtraBinds) > 0 { obj["extra_binds"] = toArrayInterface(in.ExtraBinds) } @@ -277,6 +281,10 @@ func expandClusterRKEConfigServicesEtcd(p []interface{}) (*managementClient.ETCD obj.ExtraArgs = toMapString(v) } + if v, ok := in["extra_args_array"].([]interface{}); ok && len(v) > 0 { + obj.ExtraArgsArray = expandExtraArgsArray(v) + } + if v, ok := in["extra_binds"].([]interface{}); ok && len(v) > 0 { obj.ExtraBinds = toArrayString(v) } diff --git a/rancher2/structure_cluster_rke_config_services_etcd_test.go b/rancher2/structure_cluster_rke_config_services_etcd_test.go index f9c557e6..43504f6b 100644 --- a/rancher2/structure_cluster_rke_config_services_etcd_test.go +++ b/rancher2/structure_cluster_rke_config_services_etcd_test.go @@ -63,6 +63,10 @@ func init() { "arg_one": "one", "arg_two": "two", }, + ExtraArgsArray: map[string][]string{ + "arg1": {"v1"}, + "arg2": {"v2"}, + }, ExtraBinds: []string{"bind_one", "bind_two"}, ExtraEnv: []string{"env_one", "env_two"}, GID: int64(1001), @@ -84,6 +88,20 @@ func init() { "arg_one": "one", "arg_two": "two", }, + "extra_args_array": []interface{}{ + map[string]interface{}{ + "extra_arg": []interface{}{ + map[string]interface{}{ + "argument": "arg1", + "values": []interface{}{"v1"}, + }, + map[string]interface{}{ + "argument": "arg2", + "values": []interface{}{"v2"}, + }, + }, + }, + }, "extra_binds": []interface{}{"bind_one", "bind_two"}, "extra_env": []interface{}{"env_one", "env_two"}, "gid": 1001, diff --git a/rancher2/structure_cluster_rke_config_services_kube_api.go b/rancher2/structure_cluster_rke_config_services_kube_api.go index 8614b257..7bfdc2a6 100644 --- a/rancher2/structure_cluster_rke_config_services_kube_api.go +++ b/rancher2/structure_cluster_rke_config_services_kube_api.go @@ -167,6 +167,10 @@ func flattenClusterRKEConfigServicesKubeAPI(in *managementClient.KubeAPIService) obj["extra_args"] = toMapInterface(in.ExtraArgs) } + if len(in.ExtraArgsArray) > 0 { + obj["extra_args_array"] = flattenExtraArgsArray(in.ExtraArgsArray) + } + if len(in.ExtraBinds) > 0 { obj["extra_binds"] = toArrayInterface(in.ExtraBinds) } @@ -392,6 +396,10 @@ func expandClusterRKEConfigServicesKubeAPI(p []interface{}) (*managementClient.K obj.ExtraArgs = toMapString(v) } + if v, ok := in["extra_args_array"].([]interface{}); ok && len(v) > 0 { + obj.ExtraArgsArray = expandExtraArgsArray(v) + } + if v, ok := in["extra_binds"].([]interface{}); ok && len(v) > 0 { obj.ExtraBinds = toArrayString(v) } diff --git a/rancher2/structure_cluster_rke_config_services_kube_api_test.go b/rancher2/structure_cluster_rke_config_services_kube_api_test.go index 8a3b808c..1389df47 100644 --- a/rancher2/structure_cluster_rke_config_services_kube_api_test.go +++ b/rancher2/structure_cluster_rke_config_services_kube_api_test.go @@ -126,6 +126,10 @@ func init() { "arg_one": "one", "arg_two": "two", }, + ExtraArgsArray: map[string][]string{ + "arg1": {"v1"}, + "arg2": {"v2"}, + }, ExtraBinds: []string{"bind_one", "bind_two"}, ExtraEnv: []string{"env_one", "env_two"}, Image: "image", @@ -144,6 +148,20 @@ func init() { "arg_one": "one", "arg_two": "two", }, + "extra_args_array": []interface{}{ + map[string]interface{}{ + "extra_arg": []interface{}{ + map[string]interface{}{ + "argument": "arg1", + "values": []interface{}{"v1"}, + }, + map[string]interface{}{ + "argument": "arg2", + "values": []interface{}{"v2"}, + }, + }, + }, + }, "extra_binds": []interface{}{"bind_one", "bind_two"}, "extra_env": []interface{}{"env_one", "env_two"}, "image": "image", diff --git a/rancher2/structure_cluster_rke_config_services_kube_controller.go b/rancher2/structure_cluster_rke_config_services_kube_controller.go index ae66be70..9749a560 100644 --- a/rancher2/structure_cluster_rke_config_services_kube_controller.go +++ b/rancher2/structure_cluster_rke_config_services_kube_controller.go @@ -20,6 +20,10 @@ func flattenClusterRKEConfigServicesKubeController(in *managementClient.KubeCont obj["extra_args"] = toMapInterface(in.ExtraArgs) } + if len(in.ExtraArgsArray) > 0 { + obj["extra_args_array"] = flattenExtraArgsArray(in.ExtraArgsArray) + } + if len(in.ExtraBinds) > 0 { obj["extra_binds"] = toArrayInterface(in.ExtraBinds) } @@ -56,6 +60,10 @@ func expandClusterRKEConfigServicesKubeController(p []interface{}) (*managementC obj.ExtraArgs = toMapString(v) } + if v, ok := in["extra_args_array"].([]interface{}); ok && len(v) > 0 { + obj.ExtraArgsArray = expandExtraArgsArray(v) + } + if v, ok := in["extra_binds"].([]interface{}); ok && len(v) > 0 { obj.ExtraBinds = toArrayString(v) } diff --git a/rancher2/structure_cluster_rke_config_services_kube_controller_test.go b/rancher2/structure_cluster_rke_config_services_kube_controller_test.go index 3f65a301..351637f1 100644 --- a/rancher2/structure_cluster_rke_config_services_kube_controller_test.go +++ b/rancher2/structure_cluster_rke_config_services_kube_controller_test.go @@ -19,6 +19,10 @@ func init() { "arg_one": "one", "arg_two": "two", }, + ExtraArgsArray: map[string][]string{ + "arg1": {"v1"}, + "arg2": {"v2"}, + }, ExtraBinds: []string{"bind_one", "bind_two"}, ExtraEnv: []string{"env_one", "env_two"}, Image: "image", @@ -31,6 +35,20 @@ func init() { "arg_one": "one", "arg_two": "two", }, + "extra_args_array": []interface{}{ + map[string]interface{}{ + "extra_arg": []interface{}{ + map[string]interface{}{ + "argument": "arg1", + "values": []interface{}{"v1"}, + }, + map[string]interface{}{ + "argument": "arg2", + "values": []interface{}{"v2"}, + }, + }, + }, + }, "extra_binds": []interface{}{"bind_one", "bind_two"}, "extra_env": []interface{}{"env_one", "env_two"}, "image": "image", diff --git a/rancher2/structure_cluster_rke_config_services_kubelet.go b/rancher2/structure_cluster_rke_config_services_kubelet.go index b2067446..3fab7fe5 100644 --- a/rancher2/structure_cluster_rke_config_services_kubelet.go +++ b/rancher2/structure_cluster_rke_config_services_kubelet.go @@ -24,6 +24,10 @@ func flattenClusterRKEConfigServicesKubelet(in *managementClient.KubeletService) obj["extra_args"] = toMapInterface(in.ExtraArgs) } + if len(in.ExtraArgsArray) > 0 { + obj["extra_args_array"] = flattenExtraArgsArray(in.ExtraArgsArray) + } + if len(in.ExtraBinds) > 0 { obj["extra_binds"] = toArrayInterface(in.ExtraBinds) } @@ -67,6 +71,10 @@ func expandClusterRKEConfigServicesKubelet(p []interface{}) (*managementClient.K obj.ExtraArgs = toMapString(v) } + if v, ok := in["extra_args_array"].([]interface{}); ok && len(v) > 0 { + obj.ExtraArgsArray = expandExtraArgsArray(v) + } + if v, ok := in["extra_binds"].([]interface{}); ok && len(v) > 0 { obj.ExtraBinds = toArrayString(v) } diff --git a/rancher2/structure_cluster_rke_config_services_kubelet_test.go b/rancher2/structure_cluster_rke_config_services_kubelet_test.go index 76404aab..4fdb6de3 100644 --- a/rancher2/structure_cluster_rke_config_services_kubelet_test.go +++ b/rancher2/structure_cluster_rke_config_services_kubelet_test.go @@ -20,6 +20,10 @@ func init() { "arg_one": "one", "arg_two": "two", }, + ExtraArgsArray: map[string][]string{ + "arg1": {"v1"}, + "arg2": {"v2"}, + }, ExtraBinds: []string{"bind_one", "bind_two"}, ExtraEnv: []string{"env_one", "env_two"}, FailSwapOn: true, @@ -35,6 +39,20 @@ func init() { "arg_one": "one", "arg_two": "two", }, + "extra_args_array": []interface{}{ + map[string]interface{}{ + "extra_arg": []interface{}{ + map[string]interface{}{ + "argument": "arg1", + "values": []interface{}{"v1"}, + }, + map[string]interface{}{ + "argument": "arg2", + "values": []interface{}{"v2"}, + }, + }, + }, + }, "extra_binds": []interface{}{"bind_one", "bind_two"}, "extra_env": []interface{}{"env_one", "env_two"}, "fail_swap_on": true, diff --git a/rancher2/structure_cluster_rke_config_services_kubeproxy.go b/rancher2/structure_cluster_rke_config_services_kubeproxy.go index 42b22129..06b06584 100644 --- a/rancher2/structure_cluster_rke_config_services_kubeproxy.go +++ b/rancher2/structure_cluster_rke_config_services_kubeproxy.go @@ -16,6 +16,10 @@ func flattenClusterRKEConfigServicesKubeproxy(in *managementClient.KubeproxyServ obj["extra_args"] = toMapInterface(in.ExtraArgs) } + if len(in.ExtraArgsArray) > 0 { + obj["extra_args_array"] = flattenExtraArgsArray(in.ExtraArgsArray) + } + if len(in.ExtraBinds) > 0 { obj["extra_binds"] = toArrayInterface(in.ExtraBinds) } @@ -44,6 +48,10 @@ func expandClusterRKEConfigServicesKubeproxy(p []interface{}) (*managementClient obj.ExtraArgs = toMapString(v) } + if v, ok := in["extra_args_array"].([]interface{}); ok && len(v) > 0 { + obj.ExtraArgsArray = expandExtraArgsArray(v) + } + if v, ok := in["extra_binds"].([]interface{}); ok && len(v) > 0 { obj.ExtraBinds = toArrayString(v) } diff --git a/rancher2/structure_cluster_rke_config_services_kubeproxy_test.go b/rancher2/structure_cluster_rke_config_services_kubeproxy_test.go index 598cd800..4deebe28 100644 --- a/rancher2/structure_cluster_rke_config_services_kubeproxy_test.go +++ b/rancher2/structure_cluster_rke_config_services_kubeproxy_test.go @@ -18,6 +18,10 @@ func init() { "arg_one": "one", "arg_two": "two", }, + ExtraArgsArray: map[string][]string{ + "arg1": {"v1"}, + "arg2": {"v2"}, + }, ExtraBinds: []string{"bind_one", "bind_two"}, ExtraEnv: []string{"env_one", "env_two"}, Image: "image", @@ -28,6 +32,20 @@ func init() { "arg_one": "one", "arg_two": "two", }, + "extra_args_array": []interface{}{ + map[string]interface{}{ + "extra_arg": []interface{}{ + map[string]interface{}{ + "argument": "arg1", + "values": []interface{}{"v1"}, + }, + map[string]interface{}{ + "argument": "arg2", + "values": []interface{}{"v2"}, + }, + }, + }, + }, "extra_binds": []interface{}{"bind_one", "bind_two"}, "extra_env": []interface{}{"env_one", "env_two"}, "image": "image", diff --git a/rancher2/structure_cluster_rke_config_services_scheduler.go b/rancher2/structure_cluster_rke_config_services_scheduler.go index dddd15d2..62fd466b 100644 --- a/rancher2/structure_cluster_rke_config_services_scheduler.go +++ b/rancher2/structure_cluster_rke_config_services_scheduler.go @@ -16,6 +16,10 @@ func flattenClusterRKEConfigServicesScheduler(in *managementClient.SchedulerServ obj["extra_args"] = toMapInterface(in.ExtraArgs) } + if len(in.ExtraArgsArray) > 0 { + obj["extra_args_array"] = flattenExtraArgsArray(in.ExtraArgsArray) + } + if len(in.ExtraBinds) > 0 { obj["extra_binds"] = toArrayInterface(in.ExtraBinds) } @@ -44,6 +48,10 @@ func expandClusterRKEConfigServicesScheduler(p []interface{}) (*managementClient obj.ExtraArgs = toMapString(v) } + if v, ok := in["extra_args_array"].([]interface{}); ok && len(v) > 0 { + obj.ExtraArgsArray = expandExtraArgsArray(v) + } + if v, ok := in["extra_binds"].([]interface{}); ok && len(v) > 0 { obj.ExtraBinds = toArrayString(v) } diff --git a/rancher2/structure_cluster_rke_config_services_scheduler_test.go b/rancher2/structure_cluster_rke_config_services_scheduler_test.go index 775c4550..80ac15f6 100644 --- a/rancher2/structure_cluster_rke_config_services_scheduler_test.go +++ b/rancher2/structure_cluster_rke_config_services_scheduler_test.go @@ -18,6 +18,10 @@ func init() { "arg_one": "one", "arg_two": "two", }, + ExtraArgsArray: map[string][]string{ + "arg1": {"v1"}, + "arg2": {"v2"}, + }, ExtraBinds: []string{"bind_one", "bind_two"}, ExtraEnv: []string{"env_one", "env_two"}, Image: "image", @@ -28,6 +32,20 @@ func init() { "arg_one": "one", "arg_two": "two", }, + "extra_args_array": []interface{}{ + map[string]interface{}{ + "extra_arg": []interface{}{ + map[string]interface{}{ + "argument": "arg1", + "values": []interface{}{"v1"}, + }, + map[string]interface{}{ + "argument": "arg2", + "values": []interface{}{"v2"}, + }, + }, + }, + }, "extra_binds": []interface{}{"bind_one", "bind_two"}, "extra_env": []interface{}{"env_one", "env_two"}, "image": "image", diff --git a/rancher2/util.go b/rancher2/util.go index faefefc3..e5ed515f 100644 --- a/rancher2/util.go +++ b/rancher2/util.go @@ -530,6 +530,27 @@ func toMapString(in map[string]interface{}) map[string]string { return out } +func expandExtraArgsArray(v []interface{}) map[string][]string { + extraArgMap := make(map[string][]string) + if v == nil || len(v) == 0 || v[0] == nil { + return extraArgMap + } + + // there should only be 1 extra_args_array block per service + extraArgs := v[0].(map[string]interface{})["extra_arg"] + for _, extraArg := range extraArgs.([]interface{}) { + arg := extraArg.(map[string]interface{}) + interfaceValues := arg["values"].([]interface{}) + stringValues := make([]string, 0, len(interfaceValues)) + for _, e := range interfaceValues { + stringValues = append(stringValues, e.(string)) + } + extraArgMap[arg["argument"].(string)] = stringValues + } + + return extraArgMap +} + func toMapInterface(in map[string]string) map[string]interface{} { out := make(map[string]interface{}) for i, v := range in { @@ -538,6 +559,41 @@ func toMapInterface(in map[string]string) map[string]interface{} { return out } +func flattenExtraArgsArray(in map[string][]string) []interface{} { + // ensure deterministic ordering of map + // to prevent flaky unit-tests. Alphabetical + // ordering must be honored in .tf files to ensure + // the planner does not detect changes when there are none. + // This is required as ExtraArgsArray is of type map[string][]string + // and there is no way to guarantee element order when flattening the map. + var keys []string + for k := range in { + keys = append(keys, k) + } + sort.Slice(keys, func(i, j int) bool { + return keys[i] < keys[j] + }) + + var extraArgs []interface{} + for _, k := range keys { + var arr []interface{} + for _, e := range in[k] { + arr = append(arr, e) + } + sort.Slice(arr, func(i, j int) bool { return arr[i].(string) < arr[j].(string) }) + extraArgs = append(extraArgs, map[string]interface{}{ + "argument": k, + "values": arr, + }) + } + + return []interface{}{ + map[string]interface{}{ + "extra_arg": extraArgs, + }, + } +} + func jsonToMapInterface(in string) (map[string]interface{}, error) { out := make(map[string]interface{}) err := jsonToInterface(in, &out)