From 419939faf6de988142771ca5e4bcd7a1cb848f3b Mon Sep 17 00:00:00 2001 From: rawmind0 Date: Fri, 21 Jun 2019 21:42:17 +0200 Subject: [PATCH 1/4] Added scheduler argument to services-rke_config argument on rancher2_cluster resource. go files --- .../schema_cluster_rke_config_services.go | 39 +++++++++++ .../structure_cluster_rke_config_services.go | 67 +++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/rancher2/schema_cluster_rke_config_services.go b/rancher2/schema_cluster_rke_config_services.go index e4dec1905..086a5a119 100644 --- a/rancher2/schema_cluster_rke_config_services.go +++ b/rancher2/schema_cluster_rke_config_services.go @@ -6,6 +6,36 @@ import ( //Schemas +func clusterRKEConfigServicesSchedulerFields() map[string]*schema.Schema { + s := map[string]*schema.Schema{ + "extra_args": { + Type: schema.TypeMap, + Optional: true, + Computed: true, + }, + "extra_binds": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "extra_env": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "image": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + } + return s +} + func clusterRKEConfigServicesKubeproxyFields() map[string]*schema.Schema { s := map[string]*schema.Schema{ "extra_args": { @@ -358,6 +388,15 @@ func clusterRKEConfigServicesFields() map[string]*schema.Schema { Schema: clusterRKEConfigServicesKubeproxyFields(), }, }, + "scheduler": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: clusterRKEConfigServicesSchedulerFields(), + }, + }, } return s } diff --git a/rancher2/structure_cluster_rke_config_services.go b/rancher2/structure_cluster_rke_config_services.go index 9bcbb7ea3..af85470b1 100644 --- a/rancher2/structure_cluster_rke_config_services.go +++ b/rancher2/structure_cluster_rke_config_services.go @@ -6,6 +6,31 @@ import ( // Flatteners +func flattenClusterRKEConfigServicesScheduler(in *managementClient.SchedulerService) ([]interface{}, error) { + obj := make(map[string]interface{}) + if in == nil { + return []interface{}{}, nil + } + + if len(in.ExtraArgs) > 0 { + obj["extra_args"] = toMapInterface(in.ExtraArgs) + } + + if len(in.ExtraBinds) > 0 { + obj["extra_binds"] = toArrayInterface(in.ExtraBinds) + } + + if len(in.ExtraEnv) > 0 { + obj["extra_env"] = toArrayInterface(in.ExtraEnv) + } + + if len(in.Image) > 0 { + obj["image"] = in.Image + } + + return []interface{}{obj}, nil +} + func flattenClusterRKEConfigServicesKubeproxy(in *managementClient.KubeproxyService) ([]interface{}, error) { obj := make(map[string]interface{}) if in == nil { @@ -320,11 +345,45 @@ func flattenClusterRKEConfigServices(in *managementClient.RKEConfigServices, p [ obj["kubeproxy"] = kubeproxy } + if in.Scheduler != nil { + scheduler, err := flattenClusterRKEConfigServicesScheduler(in.Scheduler) + if err != nil { + return []interface{}{obj}, err + } + obj["scheduler"] = scheduler + } + return []interface{}{obj}, nil } // Expanders +func expandClusterRKEConfigServicesScheduler(p []interface{}) (*managementClient.SchedulerService, error) { + obj := &managementClient.SchedulerService{} + if len(p) == 0 || p[0] == nil { + return obj, nil + } + in := p[0].(map[string]interface{}) + + if v, ok := in["extra_args"].(map[string]interface{}); ok && len(v) > 0 { + obj.ExtraArgs = toMapString(v) + } + + if v, ok := in["extra_binds"].([]interface{}); ok && len(v) > 0 { + obj.ExtraBinds = toArrayString(v) + } + + if v, ok := in["extra_env"].([]interface{}); ok && len(v) > 0 { + obj.ExtraEnv = toArrayString(v) + } + + if v, ok := in["image"].(string); ok && len(v) > 0 { + obj.Image = v + } + + return obj, nil +} + func expandClusterRKEConfigServicesKubeproxy(p []interface{}) (*managementClient.KubeproxyService, error) { obj := &managementClient.KubeproxyService{} if len(p) == 0 || p[0] == nil { @@ -630,5 +689,13 @@ func expandClusterRKEConfigServices(p []interface{}) (*managementClient.RKEConfi obj.Kubeproxy = kubeproxy } + if v, ok := in["scheduler"].([]interface{}); ok && len(v) > 0 { + scheduler, err := expandClusterRKEConfigServicesScheduler(v) + if err != nil { + return obj, err + } + obj.Scheduler = scheduler + } + return obj, nil } From f8becc972235223e3a6a3b78187804ef55357742 Mon Sep 17 00:00:00 2001 From: rawmind0 Date: Fri, 21 Jun 2019 21:42:56 +0200 Subject: [PATCH 2/4] Added scheduler argument to services-rke_config argument on rancher2_cluster resource. go test files --- ...ucture_cluster_rke_config_services_test.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rancher2/structure_cluster_rke_config_services_test.go b/rancher2/structure_cluster_rke_config_services_test.go index 7724455d5..f0fb0a94a 100644 --- a/rancher2/structure_cluster_rke_config_services_test.go +++ b/rancher2/structure_cluster_rke_config_services_test.go @@ -8,6 +8,8 @@ import ( ) var ( + testClusterRKEConfigServicesSchedulerConf *managementClient.SchedulerService + testClusterRKEConfigServicesSchedulerInterface []interface{} testClusterRKEConfigServicesKubeproxyConf *managementClient.KubeproxyService testClusterRKEConfigServicesKubeproxyInterface []interface{} testClusterRKEConfigServicesKubeletConf *managementClient.KubeletService @@ -27,6 +29,26 @@ var ( ) func init() { + testClusterRKEConfigServicesSchedulerConf = &managementClient.SchedulerService{ + ExtraArgs: map[string]string{ + "arg_one": "one", + "arg_two": "two", + }, + ExtraBinds: []string{"bind_one", "bind_two"}, + ExtraEnv: []string{"env_one", "env_two"}, + Image: "image", + } + testClusterRKEConfigServicesSchedulerInterface = []interface{}{ + map[string]interface{}{ + "extra_args": map[string]interface{}{ + "arg_one": "one", + "arg_two": "two", + }, + "extra_binds": []interface{}{"bind_one", "bind_two"}, + "extra_env": []interface{}{"env_one", "env_two"}, + "image": "image", + }, + } testClusterRKEConfigServicesKubeproxyConf = &managementClient.KubeproxyService{ ExtraArgs: map[string]string{ "arg_one": "one", @@ -197,6 +219,7 @@ func init() { KubeController: testClusterRKEConfigServicesKubeControllerConf, Kubelet: testClusterRKEConfigServicesKubeletConf, Kubeproxy: testClusterRKEConfigServicesKubeproxyConf, + Scheduler: testClusterRKEConfigServicesSchedulerConf, } testClusterRKEConfigServicesInterface = []interface{}{ map[string]interface{}{ @@ -205,6 +228,7 @@ func init() { "kube_controller": testClusterRKEConfigServicesKubeControllerInterface, "kubelet": testClusterRKEConfigServicesKubeletInterface, "kubeproxy": testClusterRKEConfigServicesKubeproxyInterface, + "scheduler": testClusterRKEConfigServicesSchedulerInterface, }, } } From f8f7a801a477c1382c5c9dd81e64ff47bc449219 Mon Sep 17 00:00:00 2001 From: rawmind0 Date: Fri, 21 Jun 2019 21:43:15 +0200 Subject: [PATCH 3/4] Added scheduler argument to services-rke_config argument on rancher2_cluster resource. doc files --- website/docs/r/cluster.html.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/website/docs/r/cluster.html.markdown b/website/docs/r/cluster.html.markdown index 0759aab1e..5696d95c9 100644 --- a/website/docs/r/cluster.html.markdown +++ b/website/docs/r/cluster.html.markdown @@ -445,6 +445,7 @@ The following attributes are exported: * `kube_controller` - (Optional/Computed) Kube Controller options for RKE services (list maxitems:1) * `kubelet` - (Optional/Computed) Kubelet options for RKE services (list maxitems:1) * `kubeproxy` - (Optional/Computed) Kubeproxy options for RKE services (list maxitems:1) +* `scheduler` - (Optional/Computed) Scheduler options for RKE services (list maxitems:1) ##### `etcd` @@ -528,6 +529,15 @@ The following attributes are exported: * `extra_env` - (Optional) Extra environment for kubeproxy service (list) * `image` - (Optional/Computed) Docker image for kubeproxy service (string) +##### `scheduler` + +###### Arguments + +* `extra_args` - (Optional/Computed) Extra arguments for scheduler service (map) +* `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) + ### `aks_config` #### Arguments From 4007a51dd4c67a99d5fb22b1218398949e26b21c Mon Sep 17 00:00:00 2001 From: rawmind0 Date: Fri, 21 Jun 2019 21:43:47 +0200 Subject: [PATCH 4/4] Updated CHANGELOG.md file --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ea02321..0a7f8a371 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ FEATURES: ENHANCEMENTS: +* Added `scheduler` argument to `services`-`rke_config` argument on `rancher2_cluster` resource + BUG FIXES: * Fix: index out of range issue on `vsphere_cloud_provider`-`cloud_provider`-`rke_config` argument on `rancher2_cluster` resource