diff --git a/rancher2/data_source_rancher2_cluster.go b/rancher2/data_source_rancher2_cluster.go index 2976ddb0..3078d064 100644 --- a/rancher2/data_source_rancher2_cluster.go +++ b/rancher2/data_source_rancher2_cluster.go @@ -60,14 +60,6 @@ func dataSourceRancher2Cluster() *schema.Resource { Schema: clusterK3SConfigFields(), }, }, - "eks_config": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: clusterEKSConfigFields(), - }, - }, "eks_config_v2": { Type: schema.TypeList, MaxItems: 1, @@ -76,14 +68,6 @@ func dataSourceRancher2Cluster() *schema.Resource { Schema: clusterEKSConfigV2Fields(), }, }, - "aks_config": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: clusterAKSConfigFields(), - }, - }, "aks_config_v2": { Type: schema.TypeList, MaxItems: 1, @@ -92,14 +76,6 @@ func dataSourceRancher2Cluster() *schema.Resource { Schema: clusterAKSConfigV2Fields(), }, }, - "gke_config": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: clusterGKEConfigFields(), - }, - }, "gke_config_v2": { Type: schema.TypeList, MaxItems: 1, @@ -108,14 +84,6 @@ func dataSourceRancher2Cluster() *schema.Resource { Schema: clusterGKEConfigV2Fields(), }, }, - "oke_config": { - Type: schema.TypeList, - MaxItems: 1, - Computed: true, - Elem: &schema.Resource{ - Schema: clusterOKEConfigFields(), - }, - }, "default_project_id": { Type: schema.TypeString, Computed: true, diff --git a/rancher2/resource_rancher2_cluster.go b/rancher2/resource_rancher2_cluster.go index f2deaa34..b94f97ec 100644 --- a/rancher2/resource_rancher2_cluster.go +++ b/rancher2/resource_rancher2_cluster.go @@ -290,39 +290,15 @@ func resourceRancher2ClusterUpdate(d *schema.ResourceData, meta interface{}) err replace := false switch driver := ToLower(d.Get("driver").(string)); driver { - case clusterDriverAKS: - aksConfig, err := expandClusterAKSConfig(d.Get("aks_config").([]interface{}), d.Get("name").(string)) - if err != nil { - return err - } - update["azureKubernetesServiceConfig"] = aksConfig case ToLower(clusterDriverAKSV2): aksConfigV2 := expandClusterAKSConfigV2(d.Get("aks_config_v2").([]interface{})) update["aksConfig"] = aksConfigV2 - case clusterDriverEKS: - eksConfig, err := expandClusterEKSConfig(d.Get("eks_config").([]interface{}), d.Get("name").(string)) - if err != nil { - return err - } - update["amazonElasticContainerServiceConfig"] = eksConfig case ToLower(clusterDriverEKSV2): eksConfigV2 := expandClusterEKSConfigV2(d.Get("eks_config_v2").([]interface{})) update["eksConfig"] = fixClusterEKSConfigV2(d.Get("eks_config_v2").([]interface{}), structToMap(eksConfigV2)) - case clusterDriverGKE: - gkeConfig, err := expandClusterGKEConfig(d.Get("gke_config").([]interface{}), d.Get("name").(string)) - if err != nil { - return err - } - update["googleKubernetesEngineConfig"] = gkeConfig case ToLower(clusterDriverGKEV2): gkeConfig := expandClusterGKEConfigV2(d.Get("gke_config_v2").([]interface{})) update["gkeConfig"] = fixClusterGKEConfigV2(structToMap(gkeConfig)) - case clusterOKEKind: - okeConfig, err := expandClusterOKEConfig(d.Get("oke_config").([]interface{}), d.Get("name").(string)) - if err != nil { - return err - } - update["okeEngineConfig"] = okeConfig case ToLower(clusterDriverRKE): rkeConfig, err := expandClusterRKEConfig(d.Get("rke_config").([]interface{}), d.Get("name").(string)) if err != nil { diff --git a/rancher2/schema_cluster.go b/rancher2/schema_cluster.go index 383fbb73..2f7fbdb8 100644 --- a/rancher2/schema_cluster.go +++ b/rancher2/schema_cluster.go @@ -14,7 +14,7 @@ const ( ) var ( - clusterDrivers = []string{clusterDriverImported, clusterDriverAKS, clusterDriverEKS, clusterDriverGKE, clusterDriverGKEV2, clusterDriverK3S, clusterDriverOKE, clusterDriverRKE, clusterDriverRKE2} + clusterDrivers = []string{clusterDriverImported, clusterDriverGKEV2, clusterDriverK3S, clusterDriverRKE, clusterDriverRKE2} clusterRegistrationTokenNames = []string{clusterRegistrationTokenName, "system"} ) @@ -25,7 +25,6 @@ type Cluster struct { AmazonElasticContainerServiceConfig *AmazonElasticContainerServiceConfig `json:"amazonElasticContainerServiceConfig,omitempty" yaml:"amazonElasticContainerServiceConfig,omitempty"` AzureKubernetesServiceConfig *AzureKubernetesServiceConfig `json:"azureKubernetesServiceConfig,omitempty" yaml:"azureKubernetesServiceConfig,omitempty"` GoogleKubernetesEngineConfig *GoogleKubernetesEngineConfig `json:"googleKubernetesEngineConfig,omitempty" yaml:"googleKubernetesEngineConfig,omitempty"` - OracleKubernetesEngineConfig *OracleKubernetesEngineConfig `json:"okeEngineConfig,omitempty" yaml:"okeEngineConfig,omitempty"` } // Schemas @@ -143,33 +142,6 @@ func clusterFieldsV0() map[string]*schema.Schema { Schema: clusterK3SConfigFields(), }, }, - "eks_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"aks_config", "gke_config", "k3s_config", "rke_config"}, - Elem: &schema.Resource{ - Schema: clusterEKSConfigFields(), - }, - }, - "aks_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"eks_config", "gke_config", "k3s_config", "rke_config"}, - Elem: &schema.Resource{ - Schema: clusterAKSConfigFields(), - }, - }, - "gke_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"aks_config", "eks_config", "k3s_config", "rke_config"}, - Elem: &schema.Resource{ - Schema: clusterGKEConfigFields(), - }, - }, "default_project_id": { Type: schema.TypeString, Computed: true, @@ -357,15 +329,6 @@ func clusterFields() map[string]*schema.Schema { Schema: clusterK3SConfigFields(), }, }, - "eks_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"aks_config", "aks_config_v2", "eks_config_v2", "gke_config", "gke_config_v2", "k3s_config", "oke_config", "rke_config", "rke2_config"}, - Elem: &schema.Resource{ - Schema: clusterEKSConfigFields(), - }, - }, "eks_config_v2": { Type: schema.TypeList, MaxItems: 1, @@ -376,15 +339,6 @@ func clusterFields() map[string]*schema.Schema { Schema: clusterEKSConfigV2Fields(), }, }, - "aks_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"eks_config", "aks_config_v2", "eks_config_v2", "gke_config", "gke_config_v2", "k3s_config", "oke_config", "rke_config", "rke2_config"}, - Elem: &schema.Resource{ - Schema: clusterAKSConfigFields(), - }, - }, "aks_config_v2": { Type: schema.TypeList, MaxItems: 1, @@ -394,15 +348,6 @@ func clusterFields() map[string]*schema.Schema { Schema: clusterAKSConfigV2Fields(), }, }, - "gke_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"aks_config", "aks_config_v2", "eks_config", "eks_config_v2", "gke_config_v2", "k3s_config", "oke_config", "rke_config", "rke2_config"}, - Elem: &schema.Resource{ - Schema: clusterGKEConfigFields(), - }, - }, "gke_config_v2": { Type: schema.TypeList, MaxItems: 1, @@ -412,15 +357,6 @@ func clusterFields() map[string]*schema.Schema { Schema: clusterGKEConfigV2Fields(), }, }, - "oke_config": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{"aks_config", "aks_config_v2", "eks_config", "eks_config_v2", "gke_config", "gke_config_v2", "k3s_config", "rke_config", "rke2_config"}, - Elem: &schema.Resource{ - Schema: clusterOKEConfigFields(), - }, - }, "default_project_id": { Type: schema.TypeString, Computed: true, diff --git a/rancher2/schema_cluster_aks_config.go b/rancher2/schema_cluster_aks_config.go deleted file mode 100644 index bc2de82b..00000000 --- a/rancher2/schema_cluster_aks_config.go +++ /dev/null @@ -1,306 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" -) - -const ( - clusterAKSKind = "aks" - clusterDriverAKS = "azurekubernetesservice" - clusterAKSLoadBalancerSkuBasic = "basic" - clusterAKSLoadBalancerSkuStandard = "standard" -) - -var ( - clusterAKSAgentStorageProfile = []string{"ManagedDisks", "StorageAccount"} - clusterAKSNetworkPlugin = []string{"azure", "kubenet"} - clusterAKSNetworkPolicy = []string{"calico"} - clusterAKSLoadBalancerSkuList = []string{ - clusterAKSLoadBalancerSkuBasic, - clusterAKSLoadBalancerSkuStandard, - } -) - -//Types - -type AzureKubernetesServiceConfig struct { - AADClientAppID string `json:"addClientAppId,omitempty" yaml:"addClientAppId,omitempty"` - AADServerAppID string `json:"addServerAppId,omitempty" yaml:"addServerAppId,omitempty"` - AADServerAppSecret string `json:"addServerAppSecret,omitempty" yaml:"addServerAppSecret,omitempty"` - AADTenantID string `json:"addTenantId,omitempty" yaml:"addTenantId,omitempty"` - AdminUsername string `json:"adminUsername,omitempty" yaml:"adminUsername,omitempty"` - AgentDNSPrefix string `json:"agentDnsPrefix,omitempty" yaml:"agentDnsPrefix,omitempty"` - AgentOsdiskSizeGB int64 `json:"agentOsdiskSize,omitempty" yaml:"agentOsdiskSize,omitempty"` - AgentPoolName string `json:"agentPoolName,omitempty" yaml:"agentPoolName,omitempty"` - AgentStorageProfile string `json:"agentStorageProfile,omitempty" yaml:"agentStorageProfile,omitempty"` - AgentVMSize string `json:"agentVmSize,omitempty" yaml:"agentVmSize,omitempty"` - AuthBaseURL string `json:"authBaseUrl" yaml:"authBaseUrl"` - BaseURL string `json:"baseUrl,omitempty" yaml:"baseUrl,omitempty"` - ClientID string `json:"clientId,omitempty" yaml:"clientId,omitempty"` - ClientSecret string `json:"clientSecret,omitempty" yaml:"clientSecret,omitempty"` - Count int64 `json:"count,omitempty" yaml:"count,omitempty"` - DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` - DriverName string `json:"driverName,omitempty" yaml:"driverName,omitempty"` - DNSServiceIP string `json:"dnsServiceIp,omitempty" yaml:"dnsServiceIp,omitempty"` - DockerBridgeCIDR string `json:"dockerBridgeCidr,omitempty" yaml:"dockerBridgeCidr,omitempty"` - EnableHTTPApplicationRouting bool `json:"enableHttpApplicationRouting,omitempty" yaml:"enableHttpApplicationRouting,omitempty"` - EnableMonitoring *bool `json:"enableMonitoring,omitempty" yaml:"enableMonitoring,omitempty"` - KubernetesVersion string `json:"kubernetesVersion,omitempty" yaml:"kubernetesVersion,omitempty"` - LoadBalancerSku string `json:"loadBalancerSku,omitempty" yaml:"loadBalancerSku,omitempty"` - Location string `json:"location,omitempty" yaml:"location,omitempty"` - LogAnalyticsWorkspace string `json:"logAnalyticsWorkspace,omitempty" yaml:"logAnalyticsWorkspace,omitempty"` - LogAnalyticsWorkspaceResourceGroup string `json:"logAnalyticsWorkspaceResourceGroup,omitempty" yaml:"logAnalyticsWorkspaceResourceGroup,omitempty"` - MasterDNSPrefix string `json:"masterDnsPrefix,omitempty" yaml:"masterDnsPrefix,omitempty"` - MaxPods int64 `json:"maxPods,omitempty" yaml:"maxPods,omitempty"` - Name string `json:"name,omitempty" yaml:"name,omitempty"` - NetworkPlugin string `json:"networkPlugin,omitempty" yaml:"networkPlugin,omitempty"` - NetworkPolicy string `json:"networkPolicy,omitempty" yaml:"networkPolicy,omitempty"` - PodCIDR string `json:"podCidr,omitempty" yaml:"podCidr,omitempty"` - ResourceGroup string `json:"resourceGroup,omitempty" yaml:"resourceGroup,omitempty"` - SSHPublicKeyContents string `json:"sshPublicKeyContents,omitempty" yaml:"sshPublicKeyContents,omitempty"` - ServiceCIDR string `json:"serviceCidr,omitempty" yaml:"serviceCidr,omitempty"` - Subnet string `json:"subnet,omitempty" yaml:"subnet,omitempty"` - SubscriptionID string `json:"subscriptionId,omitempty" yaml:"subscriptionId,omitempty"` - Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` - TenantID string `json:"tenantId,omitempty" yaml:"tenantId,omitempty"` - VirtualNetwork string `json:"virtualNetwork,omitempty" yaml:"virtualNetwork,omitempty"` - VirtualNetworkResourceGroup string `json:"virtualNetworkResourceGroup,omitempty" yaml:"virtualNetworkResourceGroup,omitempty"` -} - -//Schemas - -func clusterAKSConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "agent_dns_prefix": { - Type: schema.TypeString, - Required: true, - Description: "DNS prefix to be used to create the FQDN for the agent pool", - }, - "client_id": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - Description: "Azure client ID to use", - }, - "client_secret": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - Description: "Azure client secret associated with the \"client id\"", - }, - "kubernetes_version": { - Type: schema.TypeString, - Required: true, - Description: "Specify the version of Kubernetes", - }, - "master_dns_prefix": { - Type: schema.TypeString, - Required: true, - Description: "DNS prefix to use the Kubernetes cluster control pane", - }, - "resource_group": { - Type: schema.TypeString, - Required: true, - Description: "The name of the Cluster resource group", - }, - "ssh_public_key_contents": { - Type: schema.TypeString, - Required: true, - Description: "Contents of the SSH public key used to authenticate with Linux hosts", - }, - "subnet": { - Type: schema.TypeString, - Required: true, - Description: "The name of an existing Azure Virtual Subnet. Composite of agent virtual network subnet ID", - }, - "subscription_id": { - Type: schema.TypeString, - Required: true, - Description: "Subscription credentials which uniquely identify Microsoft Azure subscription", - }, - "tenant_id": { - Type: schema.TypeString, - Required: true, - Description: "Azure tenant ID to use", - }, - "virtual_network": { - Type: schema.TypeString, - Required: true, - Description: "The name of an existing Azure Virtual Network. Composite of agent virtual network subnet ID", - }, - "virtual_network_resource_group": { - Type: schema.TypeString, - Required: true, - Description: "The resource group of an existing Azure Virtual Network. Composite of agent virtual network subnet ID", - }, - "add_client_app_id": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "The ID of an Azure Active Directory client application of type \"Native\". This application is for user login via kubectl", - }, - "add_server_app_id": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "The ID of an Azure Active Directory server application of type \"Web app/API\". This application represents the managed cluster's apiserver (Server application)", - }, - "aad_server_app_secret": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "The secret of an Azure Active Directory server application", - }, - "aad_tenant_id": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "The ID of an Azure Active Directory tenant", - }, - "admin_username": { - Type: schema.TypeString, - Optional: true, - Default: "azureuser", - Description: "The administrator username to use for Linux hosts", - }, - "agent_os_disk_size": { - Type: schema.TypeInt, - Optional: true, - Default: 0, - Description: "GB size to be used to specify the disk for every machine in the agent pool. If you specify 0, it will apply the default according to the \"agent vm size\" specified", - }, - "agent_pool_name": { - Type: schema.TypeString, - Optional: true, - Default: "agentpool0", - Description: "Name for the agent pool, upto 12 alphanumeric characters", - }, - "agent_storage_profile": { - Type: schema.TypeString, - Optional: true, - Default: "ManagedDisks", - Description: "Storage profile specifies what kind of storage used on machine in the agent pool. Chooses from [ManagedDisks StorageAccount]", - }, - "agent_vm_size": { - Type: schema.TypeString, - Optional: true, - Default: "Standard_D1_v2", - Description: "Size of machine in the agent pool", - }, - "auth_base_url": { - Type: schema.TypeString, - Optional: true, - Default: "https://login.microsoftonline.com/", - Description: "Different authentication API url to use", - }, - "base_url": { - Type: schema.TypeString, - Optional: true, - Default: "https://management.azure.com/", - Description: "Different resource management API url to use", - }, - "count": { - Type: schema.TypeInt, - Optional: true, - Default: 1, - Description: "Number of machines (VMs) in the agent pool. Allowed values must be in the range of 1 to 100 (inclusive)", - }, - "dns_service_ip": { - Type: schema.TypeString, - Optional: true, - Default: "10.0.0.10", - Description: "An IP address assigned to the Kubernetes DNS service. It must be within the Kubernetes Service address range specified in \"service cidr\"", - }, - "docker_bridge_cidr": { - Type: schema.TypeString, - Optional: true, - Default: "172.17.0.1/16", - Description: "A CIDR notation IP range assigned to the Docker bridge network. It must not overlap with any Subnet IP ranges or the Kubernetes Service address range specified in \"service cidr\"", - }, - "enable_http_application_routing": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable the Kubernetes ingress with automatic public DNS name creation", - }, - "enable_monitoring": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Turn on Azure Log Analytics monitoring. Uses the Log Analytics \"Default\" workspace if it exists, else creates one. if using an existing workspace, specifies \"log analytics workspace resource id\"", - }, - "load_balancer_sku": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Load balancer type (basic | standard). Must be standard for auto-scaling", - ValidateFunc: validation.StringInSlice(clusterAKSLoadBalancerSkuList, true), - }, - "location": { - Type: schema.TypeString, - Optional: true, - Default: "eastus", - Description: "Azure Kubernetes cluster location", - }, - "log_analytics_workspace": { - Type: schema.TypeString, - Optional: true, - Description: "The name of an existing Azure Log Analytics Workspace to use for storing monitoring data. If not specified, uses '{resource group}-{subscription id}-{location code}'", - }, - "log_analytics_workspace_resource_group": { - Type: schema.TypeString, - Optional: true, - Description: "The resource group of an existing Azure Log Analytics Workspace to use for storing monitoring data. If not specified, uses the 'Cluster' resource group", - }, - "max_pods": { - Type: schema.TypeInt, - Optional: true, - Default: 110, - Description: "Maximum number of pods that can run on a node", - }, - "network_plugin": { - Type: schema.TypeString, - Optional: true, - Default: "azure", - Description: "Network plugin used for building Kubernetes network. Chooses from [azure kubenet]", - ValidateFunc: validation.StringInSlice(clusterAKSNetworkPlugin, true), - }, - "network_policy": { - Type: schema.TypeString, - Optional: true, - Description: "Network policy used for building Kubernetes network. Chooses from [calico]", - ValidateFunc: validation.StringInSlice(clusterAKSNetworkPolicy, true), - }, - "pod_cidr": { - Type: schema.TypeString, - Optional: true, - Default: "172.244.0.0/16", - Description: "A CIDR notation IP range from which to assign Kubernetes Pod IPs when \"network plugin\" is specified in \"kubenet\".", - }, - "service_cidr": { - Type: schema.TypeString, - Optional: true, - Default: "10.0.0.0/16", - Description: "A CIDR notation IP range from which to assign Kubernetes Service cluster IPs. It must not overlap with any Subnet IP ranges", - }, - "tag": { - Type: schema.TypeMap, - Optional: true, - Computed: true, - Description: "Tags for Kubernetes cluster. For example, foo=bar", - Deprecated: "Use tags argument instead as []string", - }, - "tags": { - Type: schema.TypeList, - Optional: true, - Computed: true, - Description: "Tags for Kubernetes cluster. For example, `[\"foo=bar\",\"bar=foo\"]`", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - } - - return s -} diff --git a/rancher2/schema_cluster_aks_config_v2.go b/rancher2/schema_cluster_aks_config_v2.go index 6620b827..9b154091 100644 --- a/rancher2/schema_cluster_aks_config_v2.go +++ b/rancher2/schema_cluster_aks_config_v2.go @@ -14,6 +14,52 @@ var ( clusterAKSOutboundType = []string{"loadbalancer", "managednatgateway", "userassignednatgateway", "userdefinedrouting"} ) +//Types + +type AzureKubernetesServiceConfig struct { + AADClientAppID string `json:"addClientAppId,omitempty" yaml:"addClientAppId,omitempty"` + AADServerAppID string `json:"addServerAppId,omitempty" yaml:"addServerAppId,omitempty"` + AADServerAppSecret string `json:"addServerAppSecret,omitempty" yaml:"addServerAppSecret,omitempty"` + AADTenantID string `json:"addTenantId,omitempty" yaml:"addTenantId,omitempty"` + AdminUsername string `json:"adminUsername,omitempty" yaml:"adminUsername,omitempty"` + AgentDNSPrefix string `json:"agentDnsPrefix,omitempty" yaml:"agentDnsPrefix,omitempty"` + AgentOsdiskSizeGB int64 `json:"agentOsdiskSize,omitempty" yaml:"agentOsdiskSize,omitempty"` + AgentPoolName string `json:"agentPoolName,omitempty" yaml:"agentPoolName,omitempty"` + AgentStorageProfile string `json:"agentStorageProfile,omitempty" yaml:"agentStorageProfile,omitempty"` + AgentVMSize string `json:"agentVmSize,omitempty" yaml:"agentVmSize,omitempty"` + AuthBaseURL string `json:"authBaseUrl" yaml:"authBaseUrl"` + BaseURL string `json:"baseUrl,omitempty" yaml:"baseUrl,omitempty"` + ClientID string `json:"clientId,omitempty" yaml:"clientId,omitempty"` + ClientSecret string `json:"clientSecret,omitempty" yaml:"clientSecret,omitempty"` + Count int64 `json:"count,omitempty" yaml:"count,omitempty"` + DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` + DriverName string `json:"driverName,omitempty" yaml:"driverName,omitempty"` + DNSServiceIP string `json:"dnsServiceIp,omitempty" yaml:"dnsServiceIp,omitempty"` + DockerBridgeCIDR string `json:"dockerBridgeCidr,omitempty" yaml:"dockerBridgeCidr,omitempty"` + EnableHTTPApplicationRouting bool `json:"enableHttpApplicationRouting,omitempty" yaml:"enableHttpApplicationRouting,omitempty"` + EnableMonitoring *bool `json:"enableMonitoring,omitempty" yaml:"enableMonitoring,omitempty"` + KubernetesVersion string `json:"kubernetesVersion,omitempty" yaml:"kubernetesVersion,omitempty"` + LoadBalancerSku string `json:"loadBalancerSku,omitempty" yaml:"loadBalancerSku,omitempty"` + Location string `json:"location,omitempty" yaml:"location,omitempty"` + LogAnalyticsWorkspace string `json:"logAnalyticsWorkspace,omitempty" yaml:"logAnalyticsWorkspace,omitempty"` + LogAnalyticsWorkspaceResourceGroup string `json:"logAnalyticsWorkspaceResourceGroup,omitempty" yaml:"logAnalyticsWorkspaceResourceGroup,omitempty"` + MasterDNSPrefix string `json:"masterDnsPrefix,omitempty" yaml:"masterDnsPrefix,omitempty"` + MaxPods int64 `json:"maxPods,omitempty" yaml:"maxPods,omitempty"` + Name string `json:"name,omitempty" yaml:"name,omitempty"` + NetworkPlugin string `json:"networkPlugin,omitempty" yaml:"networkPlugin,omitempty"` + NetworkPolicy string `json:"networkPolicy,omitempty" yaml:"networkPolicy,omitempty"` + PodCIDR string `json:"podCidr,omitempty" yaml:"podCidr,omitempty"` + ResourceGroup string `json:"resourceGroup,omitempty" yaml:"resourceGroup,omitempty"` + SSHPublicKeyContents string `json:"sshPublicKeyContents,omitempty" yaml:"sshPublicKeyContents,omitempty"` + ServiceCIDR string `json:"serviceCidr,omitempty" yaml:"serviceCidr,omitempty"` + Subnet string `json:"subnet,omitempty" yaml:"subnet,omitempty"` + SubscriptionID string `json:"subscriptionId,omitempty" yaml:"subscriptionId,omitempty"` + Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` + TenantID string `json:"tenantId,omitempty" yaml:"tenantId,omitempty"` + VirtualNetwork string `json:"virtualNetwork,omitempty" yaml:"virtualNetwork,omitempty"` + VirtualNetworkResourceGroup string `json:"virtualNetworkResourceGroup,omitempty" yaml:"virtualNetworkResourceGroup,omitempty"` +} + // Schemas func clusterAKSConfigV2NodePoolsFields() map[string]*schema.Schema { diff --git a/rancher2/schema_cluster_eks_config.go b/rancher2/schema_cluster_eks_config.go deleted file mode 100644 index ac553790..00000000 --- a/rancher2/schema_cluster_eks_config.go +++ /dev/null @@ -1,158 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -const ( - clusterEKSKind = "eks" - clusterDriverEKS = "amazonelasticcontainerservice" -) - -//Types - -type AmazonElasticContainerServiceConfig struct { - AMI string `json:"ami,omitempty" yaml:"ami,omitempty"` - AccessKey string `json:"accessKey,omitempty" yaml:"accessKey,omitempty"` - AssociateWorkerNodePublicIP *bool `json:"associateWorkerNodePublicIp,omitempty" yaml:"associateWorkerNodePublicIp,omitempty"` - DesiredNodes int64 `json:"desiredNodes,omitempty" yaml:"desiredNodes,omitempty"` - DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` - DriverName string `json:"driverName,omitempty" yaml:"driverName,omitempty"` - EBSEncryption bool `json:"ebsEncryption,omitempty" yaml:"ebsEncryption,omitempty"` - InstanceType string `json:"instanceType,omitempty" yaml:"instanceType,omitempty"` - KeyPairName string `json:"keyPairName,omitempty" yaml:"keyPairName,omitempty"` - KubernetesVersion string `json:"kubernetesVersion,omitempty" yaml:"kubernetesVersion,omitempty"` - MaximumNodes int64 `json:"maximumNodes,omitempty" yaml:"maximumNodes,omitempty"` - MinimumNodes int64 `json:"minimumNodes,omitempty" yaml:"minimumNodes,omitempty"` - NodeVolumeSize int64 `json:"nodeVolumeSize,omitempty" yaml:"nodeVolumeSize,omitempty"` - Region string `json:"region,omitempty" yaml:"region,omitempty"` - SecretKey string `json:"secretKey,omitempty" yaml:"secretKey,omitempty"` - SecurityGroups []string `json:"securityGroups,omitempty" yaml:"securityGroups,omitempty"` - ServiceRole string `json:"serviceRole,omitempty" yaml:"serviceRole,omitempty"` - SessionToken string `json:"sessionToken,omitempty" yaml:"sessionToken,omitempty"` - Subnets []string `json:"subnets,omitempty" yaml:"subnets,omitempty"` - UserData string `json:"userData,omitempty" yaml:"userData,omitempty"` - VirtualNetwork string `json:"virtualNetwork,omitempty" yaml:"virtualNetwork,omitempty"` -} - -//Schemas - -func clusterEKSConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "access_key": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - Description: "The AWS Client ID to use", - }, - "kubernetes_version": { - Type: schema.TypeString, - Required: true, - Description: "The kubernetes master version", - }, - "secret_key": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - Description: "The AWS Client Secret associated with the Client ID", - }, - "ami": { - Type: schema.TypeString, - Optional: true, - Description: "A custom AMI ID to use for the worker nodes instead of the default", - }, - "associate_worker_node_public_ip": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Associate public ip EKS worker nodes", - }, - "desired_nodes": { - Type: schema.TypeInt, - Optional: true, - Default: 3, - Description: "The desired number of worker nodes", - }, - "ebs_encryption": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enables EBS encryption of worker nodes", - }, - "instance_type": { - Type: schema.TypeString, - Optional: true, - Default: "t2.medium", - Description: "The type of machine to use for worker nodes", - }, - "key_pair_name": { - Type: schema.TypeString, - Optional: true, - Description: "Allow user to specify key name to use", - }, - "maximum_nodes": { - Type: schema.TypeInt, - Optional: true, - Default: 3, - Description: "The maximum number of worker nodes", - }, - "minimum_nodes": { - Type: schema.TypeInt, - Optional: true, - Default: 1, - Description: "The minimum number of worker nodes", - }, - "node_volume_size": { - Type: schema.TypeInt, - Optional: true, - Default: 20, - Description: "The volume size for each node", - }, - "region": { - Type: schema.TypeString, - Optional: true, - Default: "us-west-2", - Description: "The AWS Region to create the EKS cluster in", - }, - "security_groups": { - Type: schema.TypeList, - Optional: true, - Description: "List of security groups to use for the cluster", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "service_role": { - Type: schema.TypeString, - Optional: true, - Description: "The service role to use to perform the cluster operations in AWS", - }, - "session_token": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "A session token to use with the client key and secret if applicable", - }, - "subnets": { - Type: schema.TypeList, - Optional: true, - Description: "List of subnets in the virtual network to use", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "user_data": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Pass user-data to the nodes to perform automated configuration tasks", - }, - "virtual_network": { - Type: schema.TypeString, - Optional: true, - Description: "The name of the virtual network to use", - }, - } - - return s -} diff --git a/rancher2/schema_cluster_eks_config_v2.go b/rancher2/schema_cluster_eks_config_v2.go index ae351a0e..8f8626a2 100644 --- a/rancher2/schema_cluster_eks_config_v2.go +++ b/rancher2/schema_cluster_eks_config_v2.go @@ -14,6 +14,32 @@ const ( clusterEKSV2LoggingAuthenticator = "authenticator" ) +//Types + +type AmazonElasticContainerServiceConfig struct { + AMI string `json:"ami,omitempty" yaml:"ami,omitempty"` + AccessKey string `json:"accessKey,omitempty" yaml:"accessKey,omitempty"` + AssociateWorkerNodePublicIP *bool `json:"associateWorkerNodePublicIp,omitempty" yaml:"associateWorkerNodePublicIp,omitempty"` + DesiredNodes int64 `json:"desiredNodes,omitempty" yaml:"desiredNodes,omitempty"` + DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` + DriverName string `json:"driverName,omitempty" yaml:"driverName,omitempty"` + EBSEncryption bool `json:"ebsEncryption,omitempty" yaml:"ebsEncryption,omitempty"` + InstanceType string `json:"instanceType,omitempty" yaml:"instanceType,omitempty"` + KeyPairName string `json:"keyPairName,omitempty" yaml:"keyPairName,omitempty"` + KubernetesVersion string `json:"kubernetesVersion,omitempty" yaml:"kubernetesVersion,omitempty"` + MaximumNodes int64 `json:"maximumNodes,omitempty" yaml:"maximumNodes,omitempty"` + MinimumNodes int64 `json:"minimumNodes,omitempty" yaml:"minimumNodes,omitempty"` + NodeVolumeSize int64 `json:"nodeVolumeSize,omitempty" yaml:"nodeVolumeSize,omitempty"` + Region string `json:"region,omitempty" yaml:"region,omitempty"` + SecretKey string `json:"secretKey,omitempty" yaml:"secretKey,omitempty"` + SecurityGroups []string `json:"securityGroups,omitempty" yaml:"securityGroups,omitempty"` + ServiceRole string `json:"serviceRole,omitempty" yaml:"serviceRole,omitempty"` + SessionToken string `json:"sessionToken,omitempty" yaml:"sessionToken,omitempty"` + Subnets []string `json:"subnets,omitempty" yaml:"subnets,omitempty"` + UserData string `json:"userData,omitempty" yaml:"userData,omitempty"` + VirtualNetwork string `json:"virtualNetwork,omitempty" yaml:"virtualNetwork,omitempty"` +} + //Schemas func clusterEKSConfigV2NodeGroupsLaunchTemplateFields() map[string]*schema.Schema { diff --git a/rancher2/schema_cluster_gke_config.go b/rancher2/schema_cluster_gke_config.go deleted file mode 100644 index 57349d85..00000000 --- a/rancher2/schema_cluster_gke_config.go +++ /dev/null @@ -1,384 +0,0 @@ -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -const ( - clusterGKEKind = "gke" - clusterDriverGKE = "googlekubernetesengine" -) - -//Types - -type GoogleKubernetesEngineConfig struct { - ClusterIpv4Cidr string `json:"clusterIpv4Cidr,omitempty" yaml:"clusterIpv4Cidr,omitempty"` - Credential string `json:"credential,omitempty" yaml:"credential,omitempty"` - Description string `json:"description,omitempty" yaml:"description,omitempty"` - DiskSizeGb int64 `json:"diskSizeGb,omitempty" yaml:"diskSizeGb,omitempty"` - DiskType string `json:"diskType,omitempty" yaml:"diskType,omitempty"` - DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` - DriverName string `json:"driverName,omitempty" yaml:"driverName,omitempty"` - EnableAlphaFeature bool `json:"enableAlphaFeature,omitempty" yaml:"enableAlphaFeature,omitempty"` - EnableAutoRepair bool `json:"enableAutoRepair,omitempty" yaml:"enableAutoRepair,omitempty"` - EnableAutoUpgrade bool `json:"enableAutoUpgrade,omitempty" yaml:"enableAutoUpgrade,omitempty"` - EnableHorizontalPodAutoscaling *bool `json:"enableHorizontalPodAutoscaling,omitempty" yaml:"enableHorizontalPodAutoscaling,omitempty"` - EnableHTTPLoadBalancing *bool `json:"enableHttpLoadBalancing,omitempty" yaml:"enableHttpLoadBalancing,omitempty"` - EnableKubernetesDashboard bool `json:"enableKubernetesDashboard,omitempty" yaml:"enableKubernetesDashboard,omitempty"` - EnableLegacyAbac bool `json:"enableLegacyAbac,omitempty" yaml:"enableLegacyAbac,omitempty"` - EnableMasterAuthorizedNetwork bool `json:"enableMasterAuthorizedNetwork,omitempty" yaml:"enableMasterAuthorizedNetwork,omitempty"` - EnableNetworkPolicyConfig *bool `json:"enableNetworkPolicyConfig,omitempty" yaml:"enableNetworkPolicyConfig,omitempty"` - EnableNodepoolAutoscaling bool `json:"enableNodepoolAutoscaling,omitempty" yaml:"enableNodepoolAutoscaling,omitempty"` - EnablePrivateEndpoint bool `json:"enablePrivateEndpoint,omitempty" yaml:"enablePrivateEndpoint,omitempty"` - EnablePrivateNodes bool `json:"enablePrivateNodes,omitempty" yaml:"enablePrivateNodes,omitempty"` - EnableStackdriverLogging *bool `json:"enableStackdriverLogging,omitempty" yaml:"enableStackdriverLogging,omitempty"` - EnableStackdriverMonitoring *bool `json:"enableStackdriverMonitoring,omitempty" yaml:"enableStackdriverMonitoring,omitempty"` - ImageType string `json:"imageType,omitempty" yaml:"imageType,omitempty"` - IPPolicyClusterIpv4CidrBlock string `json:"ipPolicyClusterIpv4CidrBlock,omitempty" yaml:"ipPolicyClusterIpv4CidrBlock,omitempty"` - IPPolicyClusterSecondaryRangeName string `json:"ipPolicyClusterSecondaryRangeName,omitempty" yaml:"ipPolicyClusterSecondaryRangeName,omitempty"` - IPPolicyCreateSubnetwork bool `json:"ipPolicyCreateSubnetwork,omitempty" yaml:"ipPolicyCreateSubnetwork,omitempty"` - IPPolicyNodeIpv4CidrBlock string `json:"ipPolicyNodeIpv4CidrBlock,omitempty" yaml:"ipPolicyNodeIpv4CidrBlock,omitempty"` - IPPolicyServicesIpv4CidrBlock string `json:"ipPolicyServicesIpv4CidrBlock,omitempty" yaml:"ipPolicyServicesIpv4CidrBlock,omitempty"` - IPPolicyServicesSecondaryRangeName string `json:"ipPolicyServicesSecondaryRangeName,omitempty" yaml:"ipPolicyServicesSecondaryRangeName,omitempty"` - IPPolicySubnetworkName string `json:"ipPolicySubnetworkName,omitempty" yaml:"ipPolicySubnetworkName,omitempty"` - IssueClientCertificate bool `json:"issueClientCertificate,omitempty" yaml:"issueClientCertificate,omitempty"` - KubernetesDashboard bool `json:"kubernetesDashboard,omitempty" yaml:"kubernetesDashboard,omitempty"` - Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` - LocalSsdCount int64 `json:"localSsdCount,omitempty" yaml:"localSsdCount,omitempty"` - Locations []string `json:"locations,omitempty" yaml:"locations,omitempty"` - MachineType string `json:"machineType,omitempty" yaml:"machineType,omitempty"` - MaintenanceWindow string `json:"maintenanceWindow,omitempty" yaml:"maintenanceWindow,omitempty"` - MasterAuthorizedNetworkCidrBlocks []string `json:"masterAuthorizedNetworkCidrBlocks,omitempty" yaml:"masterAuthorizedNetworkCidrBlocks,omitempty"` - MasterIpv4CidrBlock string `json:"masterIpv4CidrBlock,omitempty" yaml:"masterIpv4CidrBlock,omitempty"` - MasterVersion string `json:"masterVersion,omitempty" yaml:"masterVersion,omitempty"` - MaxNodeCount int64 `json:"maxNodeCount,omitempty" yaml:"maxNodeCount,omitempty"` - MinNodeCount int64 `json:"minNodeCount,omitempty" yaml:"minNodeCount,omitempty"` - Name string `json:"name,omitempty" yaml:"name,omitempty"` - Network string `json:"network,omitempty" yaml:"network,omitempty"` - NodeCount int64 `json:"nodeCount,omitempty" yaml:"nodeCount,omitempty"` - NodePool string `json:"nodePool,omitempty" yaml:"nodePool,omitempty"` - NodeVersion string `json:"nodeVersion,omitempty" yaml:"nodeVersion,omitempty"` - OauthScopes []string `json:"oauthScopes,omitempty" yaml:"oauthScopes,omitempty"` - Preemptible bool `json:"preemptible,omitempty" yaml:"preemptible,omitempty"` - ProjectID string `json:"projectId,omitempty" yaml:"projectId,omitempty"` - Region string `json:"region,omitempty" yaml:"region,omitempty"` - ResourceLabels map[string]string `json:"resourceLabels,omitempty" yaml:"resourceLabels,omitempty"` - ServiceAccount string `json:"serviceAccount,omitempty" yaml:"serviceAccount,omitempty"` - SubNetwork string `json:"subNetwork,omitempty" yaml:"subNetwork,omitempty"` - UseIPAliases bool `json:"useIpAliases,omitempty" yaml:"useIpAliases,omitempty"` - Taints []string `json:"taints,omitempty" yaml:"taints,omitempty"` - Zone string `json:"zone,omitempty" yaml:"zone,omitempty"` -} - -//Schemas - -func clusterGKEConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - "cluster_ipv4_cidr": { - Type: schema.TypeString, - Required: true, - Description: "The IP address range of the container pods", - }, - "credential": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - Description: "The contents of the GC credential file", - }, - "disk_type": { - Type: schema.TypeString, - Required: true, - Description: "Type of the disk attached to each node", - }, - "image_type": { - Type: schema.TypeString, - Required: true, - Description: "The image to use for the worker nodes", - }, - "ip_policy_cluster_ipv4_cidr_block": { - Type: schema.TypeString, - Required: true, - Description: "The IP address range for the cluster pod IPs", - }, - "ip_policy_cluster_secondary_range_name": { - Type: schema.TypeString, - Required: true, - Description: "The name of the secondary range to be used for the cluster CIDR block", - }, - "ip_policy_node_ipv4_cidr_block": { - Type: schema.TypeString, - Required: true, - Description: "The IP address range of the instance IPs in this cluster", - }, - "ip_policy_services_ipv4_cidr_block": { - Type: schema.TypeString, - Required: true, - Description: "The IP address range of the services IPs in this cluster", - }, - "ip_policy_services_secondary_range_name": { - Type: schema.TypeString, - Required: true, - Description: "The name of the secondary range to be used for the services CIDR block", - }, - "ip_policy_subnetwork_name": { - Type: schema.TypeString, - Required: true, - Description: "A custom subnetwork name to be used if createSubnetwork is true", - }, - "locations": { - Type: schema.TypeList, - Required: true, - Description: "Locations to use for the cluster", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "machine_type": { - Type: schema.TypeString, - Required: true, - Description: "The machine type to use for the worker nodes", - }, - "maintenance_window": { - Type: schema.TypeString, - Required: true, - Description: "When to performance updates on the nodes, in 24-hour time", - }, - "master_ipv4_cidr_block": { - Type: schema.TypeString, - Required: true, - Description: "The IP range in CIDR notation to use for the hosted master network", - }, - "master_version": { - Type: schema.TypeString, - Required: true, - Description: "The kubernetes master version", - }, - "network": { - Type: schema.TypeString, - Required: true, - Description: "The network to use for the cluster", - }, - "node_pool": { - Type: schema.TypeString, - Required: true, - Description: "The ID of the cluster node pool", - }, - "node_version": { - Type: schema.TypeString, - Required: true, - Description: "The version of kubernetes to use on the nodes", - }, - "oauth_scopes": { - Type: schema.TypeList, - Required: true, - Description: "The set of Google API scopes to be made available on all of the node VMs under the default service account", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "project_id": { - Type: schema.TypeString, - Required: true, - Description: "The ID of your project to use when creating a cluster", - }, - "service_account": { - Type: schema.TypeString, - Required: true, - Description: "The Google Cloud Platform Service Account to be used by the node VMs", - }, - "sub_network": { - Type: schema.TypeString, - Required: true, - Description: "The sub-network to use for the cluster", - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: "An optional description of this cluster", - }, - "disk_size_gb": { - Type: schema.TypeInt, - Optional: true, - Default: 100, - Description: "Size of the disk attached to each node", - }, - "enable_alpha_feature": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "To enable kubernetes alpha feature", - }, - "enable_auto_repair": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Specifies whether the node auto-repair is enabled for the node pool", - }, - "enable_auto_upgrade": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Specifies whether node auto-upgrade is enabled for the node pool", - }, - "enable_horizontal_pod_autoscaling": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Enable horizontal pod autoscaling for the cluster", - }, - "enable_http_load_balancing": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Enable http load balancing for the cluster", - }, - "enable_kubernetes_dashboard": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether to enable the kubernetes dashboard", - }, - "enable_legacy_abac": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether to enable legacy abac on the cluster", - }, - "enable_master_authorized_network": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether or not master authorized network is enabled", - }, - "enable_network_policy_config": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Enable network policy config for the cluster", - }, - "enable_nodepool_autoscaling": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable nodepool autoscaling", - }, - "enable_private_endpoint": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether the master's internal IP address is used as the cluster endpoint", - }, - "enable_private_nodes": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether nodes have internal IP address only", - }, - "enable_stackdriver_logging": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Enable stackdriver logging", - }, - "enable_stackdriver_monitoring": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Enable stackdriver monitoring", - }, - "ip_policy_create_subnetwork": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether a new subnetwork will be created automatically for the cluster", - }, - "issue_client_certificate": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Issue a client certificate", - }, - "kubernetes_dashboard": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable the kubernetes dashboard", - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Computed: true, - Description: "The map of Kubernetes labels (key/value pairs) to be applied to each node", - }, - "local_ssd_count": { - Type: schema.TypeInt, - Optional: true, - Default: 0, - Description: "The number of local SSD disks to be attached to the node", - }, - "master_authorized_network_cidr_blocks": { - Type: schema.TypeList, - Optional: true, - Description: "Define up to 10 external networks that could access Kubernetes master through HTTPS", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "max_node_count": { - Type: schema.TypeInt, - Optional: true, - Default: 0, - Description: "Maximum number of nodes in the NodePool. Must be >= minNodeCount. There has to enough quota to scale up the cluster", - }, - "min_node_count": { - Type: schema.TypeInt, - Optional: true, - Default: 0, - Description: "Minimmum number of nodes in the NodePool. Must be >= 1 and <= maxNodeCount", - }, - "node_count": { - Type: schema.TypeInt, - Optional: true, - Default: 3, - Description: "The number of nodes to create in this cluster", - }, - "preemptible": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether the nodes are created as preemptible VM instances", - }, - "region": { - Type: schema.TypeString, - Optional: true, - Description: "The region to launch the cluster. Region or zone should be used", - }, - "resource_labels": { - Type: schema.TypeMap, - Optional: true, - Computed: true, - Description: "The map of Kubernetes labels (key/value pairs) to be applied to each cluster", - }, - "use_ip_aliases": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether alias IPs will be used for pod IPs in the cluster", - }, - "taints": { - Type: schema.TypeList, - Optional: true, - Description: "List of kubernetes taints to be applied to each node", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "zone": { - Type: schema.TypeString, - Optional: true, - Description: "The zone to launch the cluster. Zone or region should be used", - }, - } - - return s -} diff --git a/rancher2/schema_cluster_gke_config_v2.go b/rancher2/schema_cluster_gke_config_v2.go index 868c23e7..26cb3e9d 100644 --- a/rancher2/schema_cluster_gke_config_v2.go +++ b/rancher2/schema_cluster_gke_config_v2.go @@ -14,6 +14,67 @@ const ( clusterGKEV2LoggingAuthenticator = "authenticator" ) +//Types + +type GoogleKubernetesEngineConfig struct { + ClusterIpv4Cidr string `json:"clusterIpv4Cidr,omitempty" yaml:"clusterIpv4Cidr,omitempty"` + Credential string `json:"credential,omitempty" yaml:"credential,omitempty"` + Description string `json:"description,omitempty" yaml:"description,omitempty"` + DiskSizeGb int64 `json:"diskSizeGb,omitempty" yaml:"diskSizeGb,omitempty"` + DiskType string `json:"diskType,omitempty" yaml:"diskType,omitempty"` + DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` + DriverName string `json:"driverName,omitempty" yaml:"driverName,omitempty"` + EnableAlphaFeature bool `json:"enableAlphaFeature,omitempty" yaml:"enableAlphaFeature,omitempty"` + EnableAutoRepair bool `json:"enableAutoRepair,omitempty" yaml:"enableAutoRepair,omitempty"` + EnableAutoUpgrade bool `json:"enableAutoUpgrade,omitempty" yaml:"enableAutoUpgrade,omitempty"` + EnableHorizontalPodAutoscaling *bool `json:"enableHorizontalPodAutoscaling,omitempty" yaml:"enableHorizontalPodAutoscaling,omitempty"` + EnableHTTPLoadBalancing *bool `json:"enableHttpLoadBalancing,omitempty" yaml:"enableHttpLoadBalancing,omitempty"` + EnableKubernetesDashboard bool `json:"enableKubernetesDashboard,omitempty" yaml:"enableKubernetesDashboard,omitempty"` + EnableLegacyAbac bool `json:"enableLegacyAbac,omitempty" yaml:"enableLegacyAbac,omitempty"` + EnableMasterAuthorizedNetwork bool `json:"enableMasterAuthorizedNetwork,omitempty" yaml:"enableMasterAuthorizedNetwork,omitempty"` + EnableNetworkPolicyConfig *bool `json:"enableNetworkPolicyConfig,omitempty" yaml:"enableNetworkPolicyConfig,omitempty"` + EnableNodepoolAutoscaling bool `json:"enableNodepoolAutoscaling,omitempty" yaml:"enableNodepoolAutoscaling,omitempty"` + EnablePrivateEndpoint bool `json:"enablePrivateEndpoint,omitempty" yaml:"enablePrivateEndpoint,omitempty"` + EnablePrivateNodes bool `json:"enablePrivateNodes,omitempty" yaml:"enablePrivateNodes,omitempty"` + EnableStackdriverLogging *bool `json:"enableStackdriverLogging,omitempty" yaml:"enableStackdriverLogging,omitempty"` + EnableStackdriverMonitoring *bool `json:"enableStackdriverMonitoring,omitempty" yaml:"enableStackdriverMonitoring,omitempty"` + ImageType string `json:"imageType,omitempty" yaml:"imageType,omitempty"` + IPPolicyClusterIpv4CidrBlock string `json:"ipPolicyClusterIpv4CidrBlock,omitempty" yaml:"ipPolicyClusterIpv4CidrBlock,omitempty"` + IPPolicyClusterSecondaryRangeName string `json:"ipPolicyClusterSecondaryRangeName,omitempty" yaml:"ipPolicyClusterSecondaryRangeName,omitempty"` + IPPolicyCreateSubnetwork bool `json:"ipPolicyCreateSubnetwork,omitempty" yaml:"ipPolicyCreateSubnetwork,omitempty"` + IPPolicyNodeIpv4CidrBlock string `json:"ipPolicyNodeIpv4CidrBlock,omitempty" yaml:"ipPolicyNodeIpv4CidrBlock,omitempty"` + IPPolicyServicesIpv4CidrBlock string `json:"ipPolicyServicesIpv4CidrBlock,omitempty" yaml:"ipPolicyServicesIpv4CidrBlock,omitempty"` + IPPolicyServicesSecondaryRangeName string `json:"ipPolicyServicesSecondaryRangeName,omitempty" yaml:"ipPolicyServicesSecondaryRangeName,omitempty"` + IPPolicySubnetworkName string `json:"ipPolicySubnetworkName,omitempty" yaml:"ipPolicySubnetworkName,omitempty"` + IssueClientCertificate bool `json:"issueClientCertificate,omitempty" yaml:"issueClientCertificate,omitempty"` + KubernetesDashboard bool `json:"kubernetesDashboard,omitempty" yaml:"kubernetesDashboard,omitempty"` + Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` + LocalSsdCount int64 `json:"localSsdCount,omitempty" yaml:"localSsdCount,omitempty"` + Locations []string `json:"locations,omitempty" yaml:"locations,omitempty"` + MachineType string `json:"machineType,omitempty" yaml:"machineType,omitempty"` + MaintenanceWindow string `json:"maintenanceWindow,omitempty" yaml:"maintenanceWindow,omitempty"` + MasterAuthorizedNetworkCidrBlocks []string `json:"masterAuthorizedNetworkCidrBlocks,omitempty" yaml:"masterAuthorizedNetworkCidrBlocks,omitempty"` + MasterIpv4CidrBlock string `json:"masterIpv4CidrBlock,omitempty" yaml:"masterIpv4CidrBlock,omitempty"` + MasterVersion string `json:"masterVersion,omitempty" yaml:"masterVersion,omitempty"` + MaxNodeCount int64 `json:"maxNodeCount,omitempty" yaml:"maxNodeCount,omitempty"` + MinNodeCount int64 `json:"minNodeCount,omitempty" yaml:"minNodeCount,omitempty"` + Name string `json:"name,omitempty" yaml:"name,omitempty"` + Network string `json:"network,omitempty" yaml:"network,omitempty"` + NodeCount int64 `json:"nodeCount,omitempty" yaml:"nodeCount,omitempty"` + NodePool string `json:"nodePool,omitempty" yaml:"nodePool,omitempty"` + NodeVersion string `json:"nodeVersion,omitempty" yaml:"nodeVersion,omitempty"` + OauthScopes []string `json:"oauthScopes,omitempty" yaml:"oauthScopes,omitempty"` + Preemptible bool `json:"preemptible,omitempty" yaml:"preemptible,omitempty"` + ProjectID string `json:"projectId,omitempty" yaml:"projectId,omitempty"` + Region string `json:"region,omitempty" yaml:"region,omitempty"` + ResourceLabels map[string]string `json:"resourceLabels,omitempty" yaml:"resourceLabels,omitempty"` + ServiceAccount string `json:"serviceAccount,omitempty" yaml:"serviceAccount,omitempty"` + SubNetwork string `json:"subNetwork,omitempty" yaml:"subNetwork,omitempty"` + UseIPAliases bool `json:"useIpAliases,omitempty" yaml:"useIpAliases,omitempty"` + Taints []string `json:"taints,omitempty" yaml:"taints,omitempty"` + Zone string `json:"zone,omitempty" yaml:"zone,omitempty"` +} + //Schemas func clusterGKEConfigV2NodeTaintFields() map[string]*schema.Schema { diff --git a/rancher2/schema_cluster_oke_config.go b/rancher2/schema_cluster_oke_config.go deleted file mode 100644 index 77e1f961..00000000 --- a/rancher2/schema_cluster_oke_config.go +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright 2020 Oracle and/or its affiliates. - -package rancher2 - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -const ( - clusterOKEKind = "oke" - clusterDriverOKE = "oraclecontainerengine" -) - -//Types - -type OracleKubernetesEngineConfig struct { - CompartmentID string `json:"compartmentId,omitempty" yaml:"compartmentId,omitempty"` - CustomBootVolumeSize int64 `json:"customBootVolumeSize,omitempty" yaml:"customBootVolumeSize,omitempty"` - Description string `json:"description,omitempty" yaml:"description,omitempty"` - DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` - EnableKubernetesDashboard bool `json:"enableKubernetesDashboard,omitempty" yaml:"enableKubernetesDashboard,omitempty"` - Fingerprint string `json:"fingerprint,omitempty" yaml:"fingerprint,omitempty"` - FlexOCPUs int64 `json:"flexOcpus,omitempty" yaml:"flexOcpus,omitempty"` - KubernetesVersion string `json:"kubernetesVersion,omitempty" yaml:"kubernetesVersion,omitempty"` - DriverName string `json:"driverName,omitempty" yaml:"driverName,omitempty"` - KMSKeyID string `json:"kmsKeyId" yaml:"kmsKeyId"` - LimitNodeCount int64 `json:"limitNodeCount,omitempty" yaml:"limitNodeCount,omitempty"` - Name string `json:"name,omitempty" yaml:"name,omitempty"` - NodeImage string `json:"nodeImage,omitempty" yaml:"nodeImage,omitempty"` - NodePoolSubnetDNSDomainName string `json:"nodePoolDnsDomainName,omitempty" yaml:"nodePoolDnsDomainName,omitempty"` - NodePoolSubnetName string `json:"nodePoolSubnetName,omitempty" yaml:"nodePoolSubnetName,omitempty"` - NodePublicSSHKeyContents string `json:"nodePublicKeyContents,omitempty" yaml:"nodePublicKeyContents,omitempty"` - NodeShape string `json:"nodeShape,omitempty" yaml:"nodeShape,omitempty"` - PrivateControlPlane bool `json:"enablePrivateControlPlane,omitempty" yaml:"enablePrivateControlPlane,omitempty"` - PrivateKeyContents string `json:"privateKeyContents,omitempty" yaml:"privateKeyContents,omitempty"` - PrivateKeyPassphrase string `json:"privateKeyPassphrase,omitempty" yaml:"privateKeyPassphrase,omitempty"` - PrivateNodes bool `json:"enablePrivateNodes,omitempty" yaml:"enablePrivateNodes,omitempty"` - PodCidr string `json:"podCidr,omitempty" yaml:"podCidr,omitempty"` - QuantityOfSubnets int64 `json:"quantityOfNodeSubnets,omitempty" yaml:"quantityOfNodeSubnets,omitempty"` - QuantityPerSubnet int64 `json:"quantityPerSubnet,omitempty" yaml:"quantityPerSubnet,omitempty"` - Region string `json:"region,omitempty" yaml:"region,omitempty"` - ServiceCidr string `json:"serviceCidr,omitempty" yaml:"serviceCidr,omitempty"` - ServiceLBSubnet1Name string `json:"loadBalancerSubnetName1,omitempty" yaml:"loadBalancerSubnetName1,omitempty"` - ServiceLBSubnet2Name string `json:"loadBalancerSubnetName2,omitempty" yaml:"loadBalancerSubnetName2,omitempty"` - ServiceSubnetDNSDomainName string `json:"serviceDnsDomainName,omitempty" yaml:"serviceDnsDomainName,omitempty"` - SkipVCNDelete bool `json:"skipVcnDelete,omitempty" yaml:"skipVcnDelete,omitempty"` - TenancyID string `json:"tenancyId,omitempty" yaml:"tenancyId,omitempty"` - UserOCID string `json:"userOcid,omitempty" yaml:"userOcid,omitempty"` - VCNName string `json:"vcnName,omitempty" yaml:"vcnName,omitempty"` - VcnCompartmentID string `json:"vcnCompartmentId,omitempty" yaml:"vcnCompartmentId,omitempty"` - WorkerNodeIngressCidr string `json:"workerNodeIngressCidr,omitempty" yaml:"workerNodeIngressCidr,omitempty"` -} - -//Schemas - -func clusterOKEConfigFields() map[string]*schema.Schema { - s := map[string]*schema.Schema{ - - "compartment_id": { - Type: schema.TypeString, - Required: true, - Description: "The OCID of the compartment in which to create resources (VCN, worker nodes, etc.)", - }, - "custom_boot_volume_size": { - Type: schema.TypeInt, - Optional: true, - Description: "An optional custom boot volume size (in GB) for the nodes", - }, - "fingerprint": { - Type: schema.TypeString, - Required: true, - Description: "The fingerprint corresponding to the specified user's private API Key", - }, - "flex_ocpus": { - Type: schema.TypeInt, - Optional: true, - Description: "Optional number of OCPUs for nodes (requires flexible node_shape)", - }, - "kms_key_id": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "Optional specify the OCID of the KMS Vault master key", - }, - "kubernetes_version": { - Type: schema.TypeString, - Required: true, - Description: "The Kubernetes version that will be used for your master *and* worker nodes e.g. v1.19.7", - }, - "limit_node_count": { - Type: schema.TypeInt, - Optional: true, - Description: "Optional limit on the total number of nodes in the pool", - }, - "node_image": { - Type: schema.TypeString, - Required: true, - Description: "The OS for the node image", - }, - "node_shape": { - Type: schema.TypeString, - Required: true, - Description: "The shape of the node (determines number of CPUs and amount of memory on each node)", - }, - "private_key_contents": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - Description: "The private API key file contents for the specified user, in PEM format", - }, - "region": { - Type: schema.TypeString, - Required: true, - Description: "The availability domain within the region to host the OKE cluster", - }, - "tenancy_id": { - Type: schema.TypeString, - Required: true, - Description: "The OCID of the tenancy in which to create resources", - }, - "user_ocid": { - Type: schema.TypeString, - Required: true, - Description: "The OCID of a user who has access to the tenancy/compartment", - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: "An optional description of this cluster", - }, - "enable_private_control_plane": { - Type: schema.TypeBool, - Optional: true, - Description: "Whether Kubernetes API endpoint is a private IP only accessible from within the VCN", - }, - "enable_kubernetes_dashboard": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enable the kubernetes dashboard", - }, - "enable_private_nodes": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether worker nodes are deployed into a new private subnet", - }, - "load_balancer_subnet_name_1": { - Type: schema.TypeString, - Optional: true, - Description: "The name of the first existing subnet to use for Kubernetes services / LB", - }, - "load_balancer_subnet_name_2": { - Type: schema.TypeString, - Optional: true, - Description: "The (optional) name of a second existing subnet to use for Kubernetes services / LB", - }, - "node_pool_dns_domain_name": { - Type: schema.TypeString, - Optional: true, - Default: "nodedns", - Description: "Optional name for DNS domain of node pool subnet", - }, - "node_pool_subnet_name": { - Type: schema.TypeString, - Optional: true, - Default: "nodedns", - Description: "Optional name for node pool subnet", - }, - "node_public_key_contents": { - Type: schema.TypeString, - Optional: true, - Description: "The contents of the SSH public key file to use for the nodes", - }, - "private_key_passphrase": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "The passphrase of the private key for the OKE cluster", - }, - "quantity_of_node_subnets": { - Type: schema.TypeInt, - Optional: true, - Description: "Number of node subnets (defaults to creating 1 regional subnet)", - }, - "quantity_per_subnet": { - Type: schema.TypeInt, - Optional: true, - Default: 1, - Description: "Number of worker nodes in each subnet / availability domain", - }, - "service_dns_domain_name": { - Type: schema.TypeString, - Optional: true, - Default: "svcdns", - Description: "Optional name for DNS domain of service subnet", - }, - "skip_vcn_delete": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Whether to skip deleting VCN", - }, - "vcn_compartment_id": { - Type: schema.TypeString, - Optional: true, - Description: "The OCID of the compartment (if different from compartment_id) in which to find the pre-existing virtual network set with vcn_name.", - }, - "vcn_name": { - Type: schema.TypeString, - Optional: true, - Description: "The optional name of an existing virtual network to use for the cluster creation. A new VCN will be created if not specified.", - }, - "worker_node_ingress_cidr": { - Type: schema.TypeString, - Optional: true, - Description: "Additional CIDR from which to allow ingress to worker nodes", - }, - "pod_cidr": { - Type: schema.TypeString, - Optional: true, - Description: "Optional specify the pod CIDR, defaults to 10.244.0.0/16", - }, - "service_cidr": { - Type: schema.TypeString, - Optional: true, - Description: "Optional specify the service CIDR, defaults to 10.96.0.0/16", - }, - } - - return s -} diff --git a/rancher2/structure_cluster.go b/rancher2/structure_cluster.go index 45a3c46d..77d5b1ea 100644 --- a/rancher2/structure_cluster.go +++ b/rancher2/structure_cluster.go @@ -153,19 +153,6 @@ func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *manage d.Set("driver", in.Driver) switch driver := ToLower(in.Driver); driver { - case clusterDriverAKS: - v, ok := d.Get("aks_config").([]interface{}) - if !ok { - v = []interface{}{} - } - aksConfig, err := flattenClusterAKSConfig(in.AzureKubernetesServiceConfig, v) - if err != nil { - return err - } - err = d.Set("aks_config", aksConfig) - if err != nil { - return err - } case ToLower(clusterDriverAKSV2): v, ok := d.Get("aks_config_v2").([]interface{}) if !ok { @@ -175,19 +162,6 @@ func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *manage if err != nil { return err } - case clusterDriverEKS: - v, ok := d.Get("eks_config").([]interface{}) - if !ok { - v = []interface{}{} - } - eksConfig, err := flattenClusterEKSConfig(in.AmazonElasticContainerServiceConfig, v) - if err != nil { - return err - } - err = d.Set("eks_config", eksConfig) - if err != nil { - return err - } case ToLower(clusterDriverEKSV2): v, ok := d.Get("eks_config_v2").([]interface{}) if !ok { @@ -197,19 +171,6 @@ func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *manage if err != nil { return err } - case clusterDriverGKE: - v, ok := d.Get("gke_config").([]interface{}) - if !ok { - v = []interface{}{} - } - gkeConfig, err := flattenClusterGKEConfig(in.GoogleKubernetesEngineConfig, v) - if err != nil { - return err - } - err = d.Set("gke_config", gkeConfig) - if err != nil { - return err - } case ToLower(clusterDriverGKEV2): v, ok := d.Get("gke_config_v2").([]interface{}) if !ok { @@ -220,20 +181,6 @@ func flattenCluster(d *schema.ResourceData, in *Cluster, clusterRegToken *manage if err != nil { return err } - case clusterOKEKind, clusterDriverOKE: - v, ok := d.Get("oke_config").([]interface{}) - if !ok { - v = []interface{}{} - } - - okeConfig, err := flattenClusterOKEConfig(in.OracleKubernetesEngineConfig, v) - if err != nil { - return err - } - err = d.Set("oke_config", okeConfig) - if err != nil { - return err - } } // Setting k3s_config, rke2_config and rke_config always as computed @@ -475,15 +422,6 @@ func expandCluster(in *schema.ResourceData) (*Cluster, error) { obj.FleetWorkspaceName = v } - if v, ok := in.Get("aks_config").([]interface{}); ok && len(v) > 0 { - aksConfig, err := expandClusterAKSConfig(v, obj.Name) - if err != nil { - return nil, err - } - obj.AzureKubernetesServiceConfig = aksConfig - obj.Driver = clusterDriverAKS - } - if v, ok := in.Get("aks_config_v2").([]interface{}); ok && len(v) > 0 { // Setting aks cluster name if empty if aksData, ok := v[0].(map[string]interface{}); ok { @@ -496,15 +434,6 @@ func expandCluster(in *schema.ResourceData) (*Cluster, error) { obj.Driver = clusterDriverAKSV2 } - if v, ok := in.Get("eks_config").([]interface{}); ok && len(v) > 0 { - eksConfig, err := expandClusterEKSConfig(v, obj.Name) - if err != nil { - return nil, err - } - obj.AmazonElasticContainerServiceConfig = eksConfig - obj.Driver = clusterDriverEKS - } - if v, ok := in.Get("eks_config_v2").([]interface{}); ok && len(v) > 0 { // Setting eks cluster name if empty if eksData, ok := v[0].(map[string]interface{}); ok { @@ -517,30 +446,12 @@ func expandCluster(in *schema.ResourceData) (*Cluster, error) { obj.Driver = clusterDriverEKSV2 } - if v, ok := in.Get("gke_config").([]interface{}); ok && len(v) > 0 { - gkeConfig, err := expandClusterGKEConfig(v, obj.Name) - if err != nil { - return nil, err - } - obj.GoogleKubernetesEngineConfig = gkeConfig - obj.Driver = clusterDriverGKE - } - if v, ok := in.Get("gke_config_v2").([]interface{}); ok && len(v) > 0 { gkeConfig := expandClusterGKEConfigV2(v) obj.GKEConfig = gkeConfig obj.Driver = clusterDriverGKEV2 } - if v, ok := in.Get("oke_config").([]interface{}); ok && len(v) > 0 { - okeConfig, err := expandClusterOKEConfig(v, obj.Name) - if err != nil { - return nil, err - } - obj.OracleKubernetesEngineConfig = okeConfig - obj.Driver = clusterOKEKind - } - if v, ok := in.Get("k3s_config").([]interface{}); ok && len(v) > 0 { obj.K3sConfig = expandClusterK3SConfig(v) obj.Driver = clusterDriverK3S diff --git a/rancher2/structure_cluster_aks_config.go b/rancher2/structure_cluster_aks_config.go deleted file mode 100644 index 5d7f838c..00000000 --- a/rancher2/structure_cluster_aks_config.go +++ /dev/null @@ -1,340 +0,0 @@ -package rancher2 - -// Flatteners - -func flattenClusterAKSConfig(in *AzureKubernetesServiceConfig, p []interface{}) ([]interface{}, error) { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{}, nil - } - - if len(in.AADClientAppID) > 0 { - obj["add_client_app_id"] = in.AADClientAppID - } - - if len(in.AADServerAppID) > 0 { - obj["add_server_app_id"] = in.AADServerAppID - } - - if len(in.AADServerAppSecret) > 0 { - obj["aad_server_app_secret"] = in.AADServerAppSecret - } - - if len(in.AADTenantID) > 0 { - obj["aad_tenant_id"] = in.AADTenantID - } - - if len(in.AdminUsername) > 0 { - obj["admin_username"] = in.AdminUsername - } - - if len(in.AgentDNSPrefix) > 0 { - obj["agent_dns_prefix"] = in.AgentDNSPrefix - } - - if in.AgentOsdiskSizeGB > 0 { - obj["agent_os_disk_size"] = int(in.AgentOsdiskSizeGB) - } - - if len(in.AgentPoolName) > 0 { - obj["agent_pool_name"] = in.AgentPoolName - } - - if len(in.AgentStorageProfile) > 0 { - obj["agent_storage_profile"] = in.AgentStorageProfile - } - - if len(in.AgentVMSize) > 0 { - obj["agent_vm_size"] = in.AgentVMSize - } - - if len(in.AuthBaseURL) > 0 { - obj["auth_base_url"] = in.AuthBaseURL - } - - if len(in.BaseURL) > 0 { - obj["base_url"] = in.BaseURL - } - - if len(in.ClientID) > 0 { - obj["client_id"] = in.ClientID - } - - if len(in.ClientSecret) > 0 { - obj["client_secret"] = in.ClientSecret - } - - if in.Count > 0 { - obj["count"] = int(in.Count) - } - - if len(in.DNSServiceIP) > 0 { - obj["dns_service_ip"] = in.DNSServiceIP - } - - if len(in.DockerBridgeCIDR) > 0 { - obj["docker_bridge_cidr"] = in.DockerBridgeCIDR - } - - obj["enable_http_application_routing"] = in.EnableHTTPApplicationRouting - obj["enable_monitoring"] = *in.EnableMonitoring - - if len(in.KubernetesVersion) > 0 { - obj["kubernetes_version"] = in.KubernetesVersion - } - - if len(in.LoadBalancerSku) > 0 { - obj["load_balancer_sku"] = in.LoadBalancerSku - } - - if len(in.Location) > 0 { - obj["location"] = in.Location - } - - if len(in.LogAnalyticsWorkspace) > 0 { - obj["log_analytics_workspace"] = in.LogAnalyticsWorkspace - } - - if len(in.LogAnalyticsWorkspaceResourceGroup) > 0 { - obj["log_analytics_workspace_resource_group"] = in.LogAnalyticsWorkspaceResourceGroup - } - - if len(in.MasterDNSPrefix) > 0 { - obj["master_dns_prefix"] = in.MasterDNSPrefix - } - - if in.MaxPods > 0 { - obj["max_pods"] = int(in.MaxPods) - } - - if len(in.NetworkPlugin) > 0 { - obj["network_plugin"] = in.NetworkPlugin - } - - if len(in.NetworkPolicy) > 0 { - obj["network_policy"] = in.NetworkPolicy - } - - if len(in.PodCIDR) > 0 { - obj["pod_cidr"] = in.PodCIDR - } - - if len(in.ResourceGroup) > 0 { - obj["resource_group"] = in.ResourceGroup - } - - if len(in.SSHPublicKeyContents) > 0 { - obj["ssh_public_key_contents"] = in.SSHPublicKeyContents - } - - if len(in.ServiceCIDR) > 0 { - obj["service_cidr"] = in.ServiceCIDR - } - - if len(in.Subnet) > 0 { - obj["subnet"] = in.Subnet - } - - if len(in.SubscriptionID) > 0 { - obj["subscription_id"] = in.SubscriptionID - } - - if len(in.Tags) > 0 { - obj["tags"] = toArrayInterface(in.Tags) - } - - if len(in.TenantID) > 0 { - obj["tenant_id"] = in.TenantID - } - - if len(in.VirtualNetwork) > 0 { - obj["virtual_network"] = in.VirtualNetwork - } - - if len(in.VirtualNetworkResourceGroup) > 0 { - obj["virtual_network_resource_group"] = in.VirtualNetworkResourceGroup - } - - return []interface{}{obj}, nil -} - -// Expanders - -func expandClusterAKSConfig(p []interface{}, name string) (*AzureKubernetesServiceConfig, error) { - obj := &AzureKubernetesServiceConfig{} - if len(p) == 0 || p[0] == nil { - return obj, nil - } - in := p[0].(map[string]interface{}) - - obj.Name = name - obj.DisplayName = name - obj.DriverName = clusterDriverAKS - - if v, ok := in["add_client_app_id"].(string); ok && len(v) > 0 { - obj.AADClientAppID = v - } - - if v, ok := in["add_server_app_id"].(string); ok && len(v) > 0 { - obj.AADServerAppID = v - } - - if v, ok := in["aad_server_app_secret"].(string); ok && len(v) > 0 { - obj.AADServerAppSecret = v - } - - if v, ok := in["aad_tenant_id"].(string); ok && len(v) > 0 { - obj.AADTenantID = v - } - - if v, ok := in["admin_username"].(string); ok && len(v) > 0 { - obj.AdminUsername = v - } - - if v, ok := in["agent_dns_prefix"].(string); ok && len(v) > 0 { - obj.AgentDNSPrefix = v - } - - if v, ok := in["agent_os_disk_size"].(int); ok && v > 0 { - obj.AgentOsdiskSizeGB = int64(v) - } - - if v, ok := in["agent_pool_name"].(string); ok && len(v) > 0 { - obj.AgentPoolName = v - } - - if v, ok := in["agent_storage_profile"].(string); ok && len(v) > 0 { - obj.AgentStorageProfile = v - } - - if v, ok := in["agent_vm_size"].(string); ok && len(v) > 0 { - obj.AgentVMSize = v - } - - if v, ok := in["auth_base_url"].(string); ok && len(v) > 0 { - obj.AuthBaseURL = v - } - - if v, ok := in["base_url"].(string); ok && len(v) > 0 { - obj.BaseURL = v - } - - if v, ok := in["client_id"].(string); ok && len(v) > 0 { - obj.ClientID = v - } - - if v, ok := in["client_secret"].(string); ok && len(v) > 0 { - obj.ClientSecret = v - } - - if v, ok := in["count"].(int); ok && v > 0 { - obj.Count = int64(v) - } - - if v, ok := in["dns_service_ip"].(string); ok && len(v) > 0 { - obj.DNSServiceIP = v - } - - if v, ok := in["docker_bridge_cidr"].(string); ok && len(v) > 0 { - obj.DockerBridgeCIDR = v - } - - if v, ok := in["enable_http_application_routing"].(bool); ok { - obj.EnableHTTPApplicationRouting = v - } - - if v, ok := in["enable_monitoring"].(bool); ok { - obj.EnableMonitoring = &v - } - - if v, ok := in["kubernetes_version"].(string); ok && len(v) > 0 { - obj.KubernetesVersion = v - } - - if v, ok := in["load_balancer_sku"].(string); ok && len(v) > 0 { - obj.LoadBalancerSku = v - } - - if v, ok := in["location"].(string); ok && len(v) > 0 { - obj.Location = v - } - - if v, ok := in["log_analytics_workspace"].(string); ok && len(v) > 0 { - obj.LogAnalyticsWorkspace = v - } - - if v, ok := in["log_analytics_workspace_resource_group"].(string); ok && len(v) > 0 { - obj.LogAnalyticsWorkspaceResourceGroup = v - } - - if v, ok := in["master_dns_prefix"].(string); ok && len(v) > 0 { - obj.MasterDNSPrefix = v - } - - if v, ok := in["max_pods"].(int); ok && v > 0 { - obj.MaxPods = int64(v) - } - - if v, ok := in["network_plugin"].(string); ok && len(v) > 0 { - obj.NetworkPlugin = v - } - - if v, ok := in["network_policy"].(string); ok && len(v) > 0 { - obj.NetworkPolicy = v - } - - if v, ok := in["pod_cidr"].(string); ok && len(v) > 0 { - obj.PodCIDR = v - } - - if v, ok := in["resource_group"].(string); ok && len(v) > 0 { - obj.ResourceGroup = v - } - - if v, ok := in["ssh_public_key_contents"].(string); ok && len(v) > 0 { - obj.SSHPublicKeyContents = v - } - - if v, ok := in["service_cidr"].(string); ok && len(v) > 0 { - obj.ServiceCIDR = v - } - - if v, ok := in["subnet"].(string); ok && len(v) > 0 { - obj.Subnet = v - } - - if v, ok := in["subscription_id"].(string); ok && len(v) > 0 { - obj.SubscriptionID = v - } - - if v, ok := in["tag"].(map[string]interface{}); ok && len(v) > 0 { - tagMap := toMapString(v) - for k, value := range tagMap { - obj.Tags = append(obj.Tags, k+"="+value) - } - } - - if v, ok := in["tags"].([]interface{}); ok && len(v) > 0 { - obj.Tags = toArrayString(v) - } - - if v, ok := in["tenant_id"].(string); ok && len(v) > 0 { - obj.TenantID = v - } - - if v, ok := in["virtual_network"].(string); ok && len(v) > 0 { - obj.VirtualNetwork = v - } - - if v, ok := in["virtual_network_resource_group"].(string); ok && len(v) > 0 { - obj.VirtualNetworkResourceGroup = v - } - - return obj, nil -} diff --git a/rancher2/structure_cluster_aks_config_test.go b/rancher2/structure_cluster_aks_config_test.go deleted file mode 100644 index 3cd16d22..00000000 --- a/rancher2/structure_cluster_aks_config_test.go +++ /dev/null @@ -1,148 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -var ( - testClusterAKSConfigConf *AzureKubernetesServiceConfig - testClusterAKSConfigInterface []interface{} -) - -func init() { - testClusterAKSConfigConf = &AzureKubernetesServiceConfig{ - AADClientAppID: "add_client_app_id", - AADServerAppID: "add_server_app_id", - AADServerAppSecret: "aad_server_app_secret", - AADTenantID: "aad_tenant_id", - AdminUsername: "admin", - AgentDNSPrefix: "dns", - AgentPoolName: "agent", - AgentStorageProfile: "agent_storage_profile", - AgentVMSize: "size", - AuthBaseURL: "auth_base_url", - BaseURL: "url", - ClientID: "client_id", - ClientSecret: "client_secret", - Count: 3, - DisplayName: "test", - DriverName: clusterDriverAKS, - DNSServiceIP: "dns_ip", - DockerBridgeCIDR: "192.168.1.0/16", - EnableHTTPApplicationRouting: true, - EnableMonitoring: newTrue(), - KubernetesVersion: "version", - LoadBalancerSku: clusterAKSLoadBalancerSkuStandard, - Location: "location", - LogAnalyticsWorkspace: "log_analytics_workspace", - LogAnalyticsWorkspaceResourceGroup: "log_analytics_workspace_resource_group", - MasterDNSPrefix: "dns_prefix", - Name: "test", - MaxPods: 100, - NetworkPlugin: "network_plugin", - NetworkPolicy: "network_policy", - AgentOsdiskSizeGB: 16, - PodCIDR: "pod_cidr", - ResourceGroup: "resource_group", - SSHPublicKeyContents: "key", - ServiceCIDR: "service_cidr", - Subnet: "subnet", - SubscriptionID: "subscription_id", - Tags: []string{ - "tag1=value1", - "tag2=value2", - }, - TenantID: "tenant_id", - VirtualNetwork: "virtual_network", - VirtualNetworkResourceGroup: "network_resource_group", - } - testClusterAKSConfigInterface = []interface{}{ - map[string]interface{}{ - "add_client_app_id": "add_client_app_id", - "add_server_app_id": "add_server_app_id", - "aad_server_app_secret": "aad_server_app_secret", - "aad_tenant_id": "aad_tenant_id", - "admin_username": "admin", - "agent_dns_prefix": "dns", - "agent_os_disk_size": 16, - "agent_pool_name": "agent", - "agent_storage_profile": "agent_storage_profile", - "agent_vm_size": "size", - "auth_base_url": "auth_base_url", - "base_url": "url", - "client_id": "client_id", - "client_secret": "client_secret", - "count": 3, - "dns_service_ip": "dns_ip", - "docker_bridge_cidr": "192.168.1.0/16", - "enable_http_application_routing": true, - "enable_monitoring": true, - "kubernetes_version": "version", - "load_balancer_sku": clusterAKSLoadBalancerSkuStandard, - "location": "location", - "log_analytics_workspace": "log_analytics_workspace", - "log_analytics_workspace_resource_group": "log_analytics_workspace_resource_group", - "master_dns_prefix": "dns_prefix", - "max_pods": 100, - "network_plugin": "network_plugin", - "network_policy": "network_policy", - "pod_cidr": "pod_cidr", - "resource_group": "resource_group", - "ssh_public_key_contents": "key", - "service_cidr": "service_cidr", - "subnet": "subnet", - "subscription_id": "subscription_id", - "tags": []interface{}{ - "tag1=value1", - "tag2=value2", - }, - "tenant_id": "tenant_id", - "virtual_network": "virtual_network", - "virtual_network_resource_group": "network_resource_group", - }, - } -} - -func TestFlattenClusterAKSConfig(t *testing.T) { - - cases := []struct { - Input *AzureKubernetesServiceConfig - ExpectedOutput []interface{} - }{ - { - testClusterAKSConfigConf, - testClusterAKSConfigInterface, - }, - } - - for _, tc := range cases { - output, err := flattenClusterAKSConfig(tc.Input, testClusterAKSConfigInterface) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandClusterAKSConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *AzureKubernetesServiceConfig - }{ - { - testClusterAKSConfigInterface, - testClusterAKSConfigConf, - }, - } - - for _, tc := range cases { - output, err := expandClusterAKSConfig(tc.Input, "test") - if err != nil { - assert.FailNow(t, "[ERROR] on expander: %#v", err) - } - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_cluster_eks_config.go b/rancher2/structure_cluster_eks_config.go deleted file mode 100644 index 0c1aa758..00000000 --- a/rancher2/structure_cluster_eks_config.go +++ /dev/null @@ -1,181 +0,0 @@ -package rancher2 - -// Flatteners - -func flattenClusterEKSConfig(in *AmazonElasticContainerServiceConfig, p []interface{}) ([]interface{}, error) { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{}, nil - } - - if len(in.AccessKey) > 0 { - obj["access_key"] = in.AccessKey - } - - if len(in.SecretKey) > 0 { - obj["secret_key"] = in.SecretKey - } - - if len(in.AMI) > 0 { - obj["ami"] = in.AMI - } - - obj["associate_worker_node_public_ip"] = *in.AssociateWorkerNodePublicIP - - if in.DesiredNodes > 0 { - obj["desired_nodes"] = int(in.DesiredNodes) - } - - if len(in.InstanceType) > 0 { - obj["instance_type"] = in.InstanceType - } - - obj["ebs_encryption"] = in.EBSEncryption - - if len(in.KeyPairName) > 0 { - obj["key_pair_name"] = in.KeyPairName - } - - if len(in.KubernetesVersion) > 0 { - obj["kubernetes_version"] = in.KubernetesVersion - } - - if in.MaximumNodes > 0 { - obj["maximum_nodes"] = int(in.MaximumNodes) - } - - if in.MinimumNodes > 0 { - obj["minimum_nodes"] = int(in.MinimumNodes) - } - - if in.NodeVolumeSize > 0 { - obj["node_volume_size"] = int(in.NodeVolumeSize) - } - - if len(in.Region) > 0 { - obj["region"] = in.Region - } - - if len(in.SecurityGroups) > 0 { - obj["security_groups"] = toArrayInterface(in.SecurityGroups) - } - - if len(in.ServiceRole) > 0 { - obj["service_role"] = in.ServiceRole - } - - if len(in.SessionToken) > 0 { - obj["session_token"] = in.SessionToken - } - - if len(in.Subnets) > 0 { - obj["subnets"] = toArrayInterface(in.Subnets) - } - - if len(in.UserData) > 0 { - obj["user_data"] = in.UserData - } - - if len(in.VirtualNetwork) > 0 { - obj["virtual_network"] = in.VirtualNetwork - } - - return []interface{}{obj}, nil -} - -// Expanders - -func expandClusterEKSConfig(p []interface{}, name string) (*AmazonElasticContainerServiceConfig, error) { - obj := &AmazonElasticContainerServiceConfig{} - if len(p) == 0 || p[0] == nil { - return obj, nil - } - in := p[0].(map[string]interface{}) - - obj.DisplayName = name - obj.DriverName = clusterDriverEKS - - if v, ok := in["access_key"].(string); ok && len(v) > 0 { - obj.AccessKey = v - } - - if v, ok := in["secret_key"].(string); ok && len(v) > 0 { - obj.SecretKey = v - } - - if v, ok := in["ami"].(string); ok && len(v) > 0 { - obj.AMI = v - } - - if v, ok := in["associate_worker_node_public_ip"].(bool); ok { - obj.AssociateWorkerNodePublicIP = &v - } - - if v, ok := in["desired_nodes"].(int); ok && v > 0 { - obj.DesiredNodes = int64(v) - } - - if v, ok := in["ebs_encryption"].(bool); ok { - obj.EBSEncryption = v - } - - if v, ok := in["instance_type"].(string); ok && len(v) > 0 { - obj.InstanceType = v - } - - if v, ok := in["key_pair_name"].(string); ok && len(v) > 0 { - obj.KeyPairName = v - } - - if v, ok := in["kubernetes_version"].(string); ok && len(v) > 0 { - obj.KubernetesVersion = v - } - - if v, ok := in["maximum_nodes"].(int); ok && v > 0 { - obj.MaximumNodes = int64(v) - } - - if v, ok := in["minimum_nodes"].(int); ok && v > 0 { - obj.MinimumNodes = int64(v) - } - - if v, ok := in["node_volume_size"].(int); ok && v > 0 { - obj.NodeVolumeSize = int64(v) - } - - if v, ok := in["region"].(string); ok && len(v) > 0 { - obj.Region = v - } - - if v, ok := in["security_groups"].([]interface{}); ok && len(v) > 0 { - obj.SecurityGroups = toArrayString(v) - } - - if v, ok := in["service_role"].(string); ok && len(v) > 0 { - obj.ServiceRole = v - } - - if v, ok := in["session_token"].(string); ok && len(v) > 0 { - obj.SessionToken = v - } - - if v, ok := in["subnets"].([]interface{}); ok && len(v) > 0 { - obj.Subnets = toArrayString(v) - } - - if v, ok := in["user_data"].(string); ok && len(v) > 0 { - obj.UserData = v - } - - if v, ok := in["virtual_network"].(string); ok && len(v) > 0 { - obj.VirtualNetwork = v - } - - return obj, nil -} diff --git a/rancher2/structure_cluster_eks_config_test.go b/rancher2/structure_cluster_eks_config_test.go deleted file mode 100644 index e640048c..00000000 --- a/rancher2/structure_cluster_eks_config_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -var ( - testClusterEKSConfigConf *AmazonElasticContainerServiceConfig - testClusterEKSConfigInterface []interface{} -) - -func init() { - testClusterEKSConfigConf = &AmazonElasticContainerServiceConfig{ - AccessKey: "XXXXXXXX", - SecretKey: "YYYYYYYY", - AMI: "ami", - AssociateWorkerNodePublicIP: newTrue(), - DesiredNodes: 4, - DisplayName: "test", - DriverName: clusterDriverEKS, - EBSEncryption: true, - InstanceType: "instance", - KeyPairName: "key_pair_name", - KubernetesVersion: "1.11", - MaximumNodes: 5, - MinimumNodes: 3, - NodeVolumeSize: 40, - Region: "region", - SecurityGroups: []string{"sg1", "sg2"}, - ServiceRole: "role", - SessionToken: "session_token", - Subnets: []string{"subnet1", "subnet2"}, - UserData: "user_data", - VirtualNetwork: "network", - } - testClusterEKSConfigInterface = []interface{}{ - map[string]interface{}{ - "access_key": "XXXXXXXX", - "secret_key": "YYYYYYYY", - "ami": "ami", - "associate_worker_node_public_ip": true, - "desired_nodes": 4, - "ebs_encryption": true, - "instance_type": "instance", - "key_pair_name": "key_pair_name", - "kubernetes_version": "1.11", - "maximum_nodes": 5, - "minimum_nodes": 3, - "node_volume_size": 40, - "region": "region", - "security_groups": []interface{}{"sg1", "sg2"}, - "service_role": "role", - "session_token": "session_token", - "subnets": []interface{}{"subnet1", "subnet2"}, - "user_data": "user_data", - "virtual_network": "network", - }, - } -} - -func TestFlattenClusterEKSConfig(t *testing.T) { - - cases := []struct { - Input *AmazonElasticContainerServiceConfig - ExpectedOutput []interface{} - }{ - { - testClusterEKSConfigConf, - testClusterEKSConfigInterface, - }, - } - - for _, tc := range cases { - output, err := flattenClusterEKSConfig(tc.Input, testClusterEKSConfigInterface) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandClusterEKSConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *AmazonElasticContainerServiceConfig - }{ - { - testClusterEKSConfigInterface, - testClusterEKSConfigConf, - }, - } - - for _, tc := range cases { - output, err := expandClusterEKSConfig(tc.Input, "test") - if err != nil { - assert.FailNow(t, "[ERROR] on expander: %#v", err) - } - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_cluster_gke_config.go b/rancher2/structure_cluster_gke_config.go deleted file mode 100644 index 0aae0b2b..00000000 --- a/rancher2/structure_cluster_gke_config.go +++ /dev/null @@ -1,423 +0,0 @@ -package rancher2 - -// Flatteners - -func flattenClusterGKEConfig(in *GoogleKubernetesEngineConfig, p []interface{}) ([]interface{}, error) { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{}, nil - } - - if len(in.ClusterIpv4Cidr) > 0 { - obj["cluster_ipv4_cidr"] = in.ClusterIpv4Cidr - } - - if len(in.Credential) > 0 { - obj["credential"] = in.Credential - } - - if len(in.Description) > 0 { - obj["description"] = in.Description - } - - if in.DiskSizeGb > 0 { - obj["disk_size_gb"] = int(in.DiskSizeGb) - } - - if len(in.DiskType) > 0 { - obj["disk_type"] = in.DiskType - } - - obj["enable_alpha_feature"] = in.EnableAlphaFeature - obj["enable_auto_repair"] = in.EnableAutoRepair - obj["enable_auto_upgrade"] = in.EnableAutoUpgrade - - if in.EnableHTTPLoadBalancing != nil { - obj["enable_http_load_balancing"] = *in.EnableHTTPLoadBalancing - } - - if in.EnableHorizontalPodAutoscaling != nil { - obj["enable_horizontal_pod_autoscaling"] = *in.EnableHorizontalPodAutoscaling - } - - obj["enable_kubernetes_dashboard"] = in.EnableKubernetesDashboard - obj["enable_legacy_abac"] = in.EnableLegacyAbac - obj["enable_master_authorized_network"] = in.EnableMasterAuthorizedNetwork - - if in.EnableNetworkPolicyConfig != nil { - obj["enable_network_policy_config"] = *in.EnableNetworkPolicyConfig - } - - obj["enable_nodepool_autoscaling"] = in.EnableNodepoolAutoscaling - obj["enable_private_endpoint"] = in.EnablePrivateEndpoint - obj["enable_private_nodes"] = in.EnablePrivateNodes - - if in.EnableStackdriverLogging != nil { - obj["enable_stackdriver_logging"] = *in.EnableStackdriverLogging - } - - if in.EnableHorizontalPodAutoscaling != nil { - obj["enable_stackdriver_monitoring"] = *in.EnableStackdriverMonitoring - } - - if len(in.ImageType) > 0 { - obj["image_type"] = in.ImageType - } - - if len(in.IPPolicyClusterIpv4CidrBlock) > 0 { - obj["ip_policy_cluster_ipv4_cidr_block"] = in.IPPolicyClusterIpv4CidrBlock - } - - if len(in.IPPolicyClusterSecondaryRangeName) > 0 { - obj["ip_policy_cluster_secondary_range_name"] = in.IPPolicyClusterSecondaryRangeName - } - - obj["ip_policy_create_subnetwork"] = in.IPPolicyCreateSubnetwork - - if len(in.IPPolicyNodeIpv4CidrBlock) > 0 { - obj["ip_policy_node_ipv4_cidr_block"] = in.IPPolicyNodeIpv4CidrBlock - } - - if len(in.IPPolicyServicesIpv4CidrBlock) > 0 { - obj["ip_policy_services_ipv4_cidr_block"] = in.IPPolicyServicesIpv4CidrBlock - } - - if len(in.IPPolicyServicesSecondaryRangeName) > 0 { - obj["ip_policy_services_secondary_range_name"] = in.IPPolicyServicesSecondaryRangeName - } - - if len(in.IPPolicySubnetworkName) > 0 { - obj["ip_policy_subnetwork_name"] = in.IPPolicySubnetworkName - } - - obj["issue_client_certificate"] = in.IssueClientCertificate - obj["kubernetes_dashboard"] = in.KubernetesDashboard - - if len(in.Labels) > 0 { - obj["labels"] = toMapInterface(in.Labels) - } - - if in.LocalSsdCount > 0 { - obj["local_ssd_count"] = int(in.LocalSsdCount) - } - - if len(in.Locations) > 0 { - obj["locations"] = toArrayInterface(in.Locations) - } - - if len(in.MachineType) > 0 { - obj["machine_type"] = in.MachineType - } - - if len(in.MaintenanceWindow) > 0 { - obj["maintenance_window"] = in.MaintenanceWindow - } - - if len(in.MasterAuthorizedNetworkCidrBlocks) > 0 { - obj["master_authorized_network_cidr_blocks"] = toArrayInterface(in.MasterAuthorizedNetworkCidrBlocks) - } - - if len(in.MasterIpv4CidrBlock) > 0 { - obj["master_ipv4_cidr_block"] = in.MasterIpv4CidrBlock - } - - if len(in.MasterVersion) > 0 { - obj["master_version"] = in.MasterVersion - } - - if in.MaxNodeCount > 0 { - obj["max_node_count"] = int(in.MaxNodeCount) - } - - if in.MinNodeCount > 0 { - obj["min_node_count"] = int(in.MinNodeCount) - } - - if len(in.Network) > 0 { - obj["network"] = in.Network - } - - if in.NodeCount > 0 { - obj["node_count"] = int(in.NodeCount) - } - - if len(in.NodePool) > 0 { - obj["node_pool"] = in.NodePool - } - - if len(in.NodeVersion) > 0 { - obj["node_version"] = in.NodeVersion - } - - if len(in.OauthScopes) > 0 { - obj["oauth_scopes"] = toArrayInterface(in.OauthScopes) - } - - obj["preemptible"] = in.Preemptible - - if len(in.ProjectID) > 0 { - obj["project_id"] = in.ProjectID - } - - if len(in.Region) > 0 { - obj["region"] = in.Region - } - - if len(in.ResourceLabels) > 0 { - obj["resource_labels"] = toMapInterface(in.ResourceLabels) - } - - if len(in.ServiceAccount) > 0 { - obj["service_account"] = in.ServiceAccount - } - - if len(in.SubNetwork) > 0 { - obj["sub_network"] = in.SubNetwork - } - - obj["use_ip_aliases"] = in.UseIPAliases - - if len(in.Taints) > 0 { - obj["taints"] = toArrayInterface(in.Taints) - } - - if len(in.Zone) > 0 { - obj["zone"] = in.Zone - } - - return []interface{}{obj}, nil -} - -// Expanders - -func expandClusterGKEConfig(p []interface{}, name string) (*GoogleKubernetesEngineConfig, error) { - obj := &GoogleKubernetesEngineConfig{} - if len(p) == 0 || p[0] == nil { - return obj, nil - } - in := p[0].(map[string]interface{}) - - obj.DisplayName = name - obj.Name = name - obj.DriverName = clusterDriverGKE - - if v, ok := in["cluster_ipv4_cidr"].(string); ok && len(v) > 0 { - obj.ClusterIpv4Cidr = v - } - - if v, ok := in["credential"].(string); ok && len(v) > 0 { - obj.Credential = v - } - - if v, ok := in["description"].(string); ok && len(v) > 0 { - obj.Description = v - } - - if v, ok := in["disk_size_gb"].(int); ok && v > 0 { - obj.DiskSizeGb = int64(v) - } - - if v, ok := in["disk_type"].(string); ok && len(v) > 0 { - obj.DiskType = v - } - - if v, ok := in["enable_alpha_feature"].(bool); ok { - obj.EnableAlphaFeature = v - } - - if v, ok := in["enable_auto_repair"].(bool); ok { - obj.EnableAutoRepair = v - } - - if v, ok := in["enable_auto_upgrade"].(bool); ok { - obj.EnableAutoUpgrade = v - } - - if v, ok := in["enable_http_load_balancing"].(bool); ok { - obj.EnableHTTPLoadBalancing = &v - } - - if v, ok := in["enable_horizontal_pod_autoscaling"].(bool); ok { - obj.EnableHorizontalPodAutoscaling = &v - } - - if v, ok := in["enable_kubernetes_dashboard"].(bool); ok { - obj.EnableKubernetesDashboard = v - } - - if v, ok := in["enable_legacy_abac"].(bool); ok { - obj.EnableLegacyAbac = v - } - - if v, ok := in["enable_master_authorized_network"].(bool); ok { - obj.EnableMasterAuthorizedNetwork = v - } - - if v, ok := in["enable_network_policy_config"].(bool); ok { - obj.EnableNetworkPolicyConfig = &v - } - - if v, ok := in["enable_nodepool_autoscaling"].(bool); ok { - obj.EnableNodepoolAutoscaling = v - } - - if v, ok := in["enable_private_endpoint"].(bool); ok { - obj.EnablePrivateEndpoint = v - } - - if v, ok := in["enable_private_nodes"].(bool); ok { - obj.EnablePrivateNodes = v - } - - if v, ok := in["enable_stackdriver_logging"].(bool); ok { - obj.EnableStackdriverLogging = &v - } - - if v, ok := in["enable_stackdriver_monitoring"].(bool); ok { - obj.EnableStackdriverMonitoring = &v - } - - if v, ok := in["image_type"].(string); ok && len(v) > 0 { - obj.ImageType = v - } - - if v, ok := in["ip_policy_cluster_ipv4_cidr_block"].(string); ok && len(v) > 0 { - obj.IPPolicyClusterIpv4CidrBlock = v - } - - if v, ok := in["ip_policy_cluster_secondary_range_name"].(string); ok && len(v) > 0 { - obj.IPPolicyClusterSecondaryRangeName = v - } - - if v, ok := in["ip_policy_create_subnetwork"].(bool); ok { - obj.IPPolicyCreateSubnetwork = v - } - - if v, ok := in["ip_policy_node_ipv4_cidr_block"].(string); ok && len(v) > 0 { - obj.IPPolicyNodeIpv4CidrBlock = v - } - - if v, ok := in["ip_policy_services_ipv4_cidr_block"].(string); ok && len(v) > 0 { - obj.IPPolicyServicesIpv4CidrBlock = v - } - - if v, ok := in["ip_policy_services_secondary_range_name"].(string); ok && len(v) > 0 { - obj.IPPolicyServicesSecondaryRangeName = v - } - - if v, ok := in["ip_policy_subnetwork_name"].(string); ok && len(v) > 0 { - obj.IPPolicySubnetworkName = v - } - - if v, ok := in["issue_client_certificate"].(bool); ok { - obj.IssueClientCertificate = v - } - - if v, ok := in["kubernetes_dashboard"].(bool); ok { - obj.KubernetesDashboard = v - } - - if v, ok := in["labels"].(map[string]interface{}); ok && len(v) > 0 { - obj.Labels = toMapString(v) - } - - if v, ok := in["local_ssd_count"].(int); ok && v > 0 { - obj.LocalSsdCount = int64(v) - } - - if v, ok := in["locations"].([]interface{}); ok && len(v) > 0 { - obj.Locations = toArrayString(v) - } - - if v, ok := in["machine_type"].(string); ok && len(v) > 0 { - obj.MachineType = v - } - - if v, ok := in["maintenance_window"].(string); ok && len(v) > 0 { - obj.MaintenanceWindow = v - } - - if v, ok := in["master_authorized_network_cidr_blocks"].([]interface{}); ok && len(v) > 0 { - obj.MasterAuthorizedNetworkCidrBlocks = toArrayString(v) - } - - if v, ok := in["master_ipv4_cidr_block"].(string); ok && len(v) > 0 { - obj.MasterIpv4CidrBlock = v - } - - if v, ok := in["master_version"].(string); ok && len(v) > 0 { - obj.MasterVersion = v - } - - if v, ok := in["max_node_count"].(int); ok && v > 0 { - obj.MaxNodeCount = int64(v) - } - - if v, ok := in["min_node_count"].(int); ok && v > 0 { - obj.MinNodeCount = int64(v) - } - - if v, ok := in["network"].(string); ok && len(v) > 0 { - obj.Network = v - } - - if v, ok := in["node_count"].(int); ok && v > 0 { - obj.NodeCount = int64(v) - } - - if v, ok := in["node_pool"].(string); ok && len(v) > 0 { - obj.NodePool = v - } - - if v, ok := in["node_version"].(string); ok && len(v) > 0 { - obj.NodeVersion = v - } - - if v, ok := in["oauth_scopes"].([]interface{}); ok && len(v) > 0 { - obj.OauthScopes = toArrayString(v) - } - - if v, ok := in["preemptible"].(bool); ok { - obj.Preemptible = v - } - - if v, ok := in["project_id"].(string); ok && len(v) > 0 { - obj.ProjectID = v - } - - if v, ok := in["region"].(string); ok && len(v) > 0 { - obj.Region = v - } - - if v, ok := in["resource_labels"].(map[string]interface{}); ok && len(v) > 0 { - obj.ResourceLabels = toMapString(v) - } - - if v, ok := in["service_account"].(string); ok && len(v) > 0 { - obj.ServiceAccount = v - } - - if v, ok := in["sub_network"].(string); ok && len(v) > 0 { - obj.SubNetwork = v - } - - if v, ok := in["use_ip_aliases"].(bool); ok { - obj.UseIPAliases = v - } - - if v, ok := in["taints"].([]interface{}); ok && len(v) > 0 { - obj.Taints = toArrayString(v) - } - - if v, ok := in["zone"].(string); ok && len(v) > 0 { - obj.Zone = v - } - - return obj, nil -} diff --git a/rancher2/structure_cluster_gke_config_test.go b/rancher2/structure_cluster_gke_config_test.go deleted file mode 100644 index 49713257..00000000 --- a/rancher2/structure_cluster_gke_config_test.go +++ /dev/null @@ -1,184 +0,0 @@ -package rancher2 - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -var ( - testClusterGKEConfigConf *GoogleKubernetesEngineConfig - testClusterGKEConfigInterface []interface{} -) - -func init() { - testClusterGKEConfigConf = &GoogleKubernetesEngineConfig{ - ClusterIpv4Cidr: "192.168.1.0/16", - Credential: "credential", - Description: "description", - DiskType: "disk_type", - DiskSizeGb: 16, - DisplayName: "test", - DriverName: clusterDriverGKE, - EnableAlphaFeature: true, - EnableAutoRepair: true, - EnableAutoUpgrade: true, - EnableHTTPLoadBalancing: newTrue(), - EnableHorizontalPodAutoscaling: newTrue(), - EnableKubernetesDashboard: true, - EnableLegacyAbac: true, - EnableMasterAuthorizedNetwork: true, - EnableNetworkPolicyConfig: newTrue(), - EnableNodepoolAutoscaling: true, - EnablePrivateEndpoint: true, - EnablePrivateNodes: true, - EnableStackdriverLogging: newTrue(), - EnableStackdriverMonitoring: newTrue(), - ImageType: "image", - IPPolicyClusterIpv4CidrBlock: "ip_policy_cluster_ipv4_cidr_block", - IPPolicyClusterSecondaryRangeName: "ip_policy_cluster_secondary_range_name", - IPPolicyCreateSubnetwork: true, - IPPolicyNodeIpv4CidrBlock: "ip_policy_node_ipv4_cidr_block", - IPPolicyServicesIpv4CidrBlock: "ip_policy_services_ipv4_cidr_block", - IPPolicyServicesSecondaryRangeName: "ip_policy_services_secondary_range_name", - IPPolicySubnetworkName: "ip_policy_subnetwork_name", - IssueClientCertificate: true, - KubernetesDashboard: true, - Labels: map[string]string{ - "label1": "value1", - "label2": "value2", - }, - LocalSsdCount: 1, - Locations: []string{"location1", "location2"}, - MachineType: "machine", - MaintenanceWindow: "maintenance", - MasterAuthorizedNetworkCidrBlocks: []string{"master1", "master2"}, - MasterIpv4CidrBlock: "master_ipv4_cidr_block", - MasterVersion: "version", - MaxNodeCount: 3, - MinNodeCount: 1, - Name: "test", - Network: "network", - NodeCount: 3, - NodePool: "node_pool", - NodeVersion: "node_version", - OauthScopes: []string{"scope1", "scope2"}, - Preemptible: true, - ProjectID: "project-test", - Region: "region", - ResourceLabels: map[string]string{ - "Rlabel1": "value1", - "Rlabel2": "value2", - }, - ServiceAccount: "service_account", - SubNetwork: "subnetwork", - UseIPAliases: true, - Taints: []string{"taint1", "taint2"}, - Zone: "zone", - } - testClusterGKEConfigInterface = []interface{}{ - map[string]interface{}{ - "cluster_ipv4_cidr": "192.168.1.0/16", - "credential": "credential", - "description": "description", - "disk_type": "disk_type", - "disk_size_gb": 16, - "enable_alpha_feature": true, - "enable_auto_repair": true, - "enable_auto_upgrade": true, - "enable_http_load_balancing": true, - "enable_horizontal_pod_autoscaling": true, - "enable_kubernetes_dashboard": true, - "enable_legacy_abac": true, - "enable_master_authorized_network": true, - "enable_network_policy_config": true, - "enable_nodepool_autoscaling": true, - "enable_private_endpoint": true, - "enable_private_nodes": true, - "enable_stackdriver_logging": true, - "enable_stackdriver_monitoring": true, - "image_type": "image", - "ip_policy_cluster_ipv4_cidr_block": "ip_policy_cluster_ipv4_cidr_block", - "ip_policy_cluster_secondary_range_name": "ip_policy_cluster_secondary_range_name", - "ip_policy_create_subnetwork": true, - "ip_policy_node_ipv4_cidr_block": "ip_policy_node_ipv4_cidr_block", - "ip_policy_services_ipv4_cidr_block": "ip_policy_services_ipv4_cidr_block", - "ip_policy_services_secondary_range_name": "ip_policy_services_secondary_range_name", - "ip_policy_subnetwork_name": "ip_policy_subnetwork_name", - "issue_client_certificate": true, - "kubernetes_dashboard": true, - "labels": map[string]interface{}{ - "label1": "value1", - "label2": "value2", - }, - "local_ssd_count": 1, - "locations": []interface{}{"location1", "location2"}, - "machine_type": "machine", - "maintenance_window": "maintenance", - "master_authorized_network_cidr_blocks": []interface{}{"master1", "master2"}, - "master_ipv4_cidr_block": "master_ipv4_cidr_block", - "master_version": "version", - "max_node_count": 3, - "min_node_count": 1, - "network": "network", - "node_count": 3, - "node_pool": "node_pool", - "node_version": "node_version", - "oauth_scopes": []interface{}{"scope1", "scope2"}, - "preemptible": true, - "project_id": "project-test", - "region": "region", - "resource_labels": map[string]interface{}{ - "Rlabel1": "value1", - "Rlabel2": "value2", - }, - "service_account": "service_account", - "sub_network": "subnetwork", - "use_ip_aliases": true, - "taints": []interface{}{"taint1", "taint2"}, - "zone": "zone", - }, - } -} - -func TestFlattenClusterGKEConfig(t *testing.T) { - - cases := []struct { - Input *GoogleKubernetesEngineConfig - ExpectedOutput []interface{} - }{ - { - testClusterGKEConfigConf, - testClusterGKEConfigInterface, - }, - } - - for _, tc := range cases { - output, err := flattenClusterGKEConfig(tc.Input, testClusterGKEConfigInterface) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandClusterGKEConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *GoogleKubernetesEngineConfig - }{ - { - testClusterGKEConfigInterface, - testClusterGKEConfigConf, - }, - } - - for _, tc := range cases { - output, err := expandClusterGKEConfig(tc.Input, "test") - if err != nil { - assert.FailNow(t, "[ERROR] on expander: %#v", err) - } - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_cluster_oke_config.go b/rancher2/structure_cluster_oke_config.go deleted file mode 100644 index 39abfabb..00000000 --- a/rancher2/structure_cluster_oke_config.go +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright 2020 Oracle and/or its affiliates. - -package rancher2 - -// Flatteners - -func flattenClusterOKEConfig(in *OracleKubernetesEngineConfig, p []interface{}) ([]interface{}, error) { - var obj map[string]interface{} - if len(p) == 0 || p[0] == nil { - obj = make(map[string]interface{}) - } else { - obj = p[0].(map[string]interface{}) - } - - if in == nil { - return []interface{}{}, nil - } - - if len(in.CompartmentID) > 0 { - obj["compartment_id"] = in.CompartmentID - } - - if in.CustomBootVolumeSize > 0 { - obj["custom_boot_volume_size"] = int(in.CustomBootVolumeSize) - } - - if len(in.Description) > 0 { - obj["description"] = in.Description - } - - obj["enable_private_control_plane"] = in.PrivateControlPlane - obj["enable_kubernetes_dashboard"] = in.EnableKubernetesDashboard - obj["enable_private_nodes"] = in.PrivateNodes - - if len(in.Fingerprint) > 0 { - obj["fingerprint"] = in.Fingerprint - } - - if in.FlexOCPUs > 0 { - obj["flex_ocpus"] = int(in.FlexOCPUs) - } - - if len(in.KMSKeyID) > 0 { - obj["kms_key_id"] = in.KMSKeyID - } - - if len(in.KubernetesVersion) > 0 { - obj["kubernetes_version"] = in.KubernetesVersion - } - - if in.LimitNodeCount > 0 { - obj["limit_node_count"] = int(in.LimitNodeCount) - } - - if len(in.ServiceLBSubnet1Name) > 0 { - obj["load_balancer_subnet_name_1"] = in.ServiceLBSubnet1Name - } - - if len(in.ServiceLBSubnet2Name) > 0 { - obj["load_balancer_subnet_name_2"] = in.ServiceLBSubnet2Name - } - - if len(in.NodeImage) > 0 { - obj["node_image"] = in.NodeImage - } - - if len(in.NodePoolSubnetDNSDomainName) > 0 { - obj["node_pool_dns_domain_name"] = in.NodePoolSubnetDNSDomainName - } - - if len(in.NodePoolSubnetName) > 0 { - obj["node_pool_subnet_name"] = in.NodePoolSubnetName - } - - if len(in.NodePublicSSHKeyContents) > 0 { - obj["node_public_key_contents"] = in.NodePublicSSHKeyContents - } - - if len(in.NodeShape) > 0 { - obj["node_shape"] = in.NodeShape - } - - if len(in.PodCidr) > 0 { - obj["pod_cidr"] = in.PodCidr - } - - if len(in.PrivateKeyContents) > 0 { - obj["private_key_contents"] = in.PrivateKeyContents - } - - if len(in.PrivateKeyPassphrase) > 0 { - obj["private_key_passphrase"] = in.PrivateKeyPassphrase - } - - if in.QuantityOfSubnets > 0 { - obj["quantity_of_node_subnets"] = int(in.QuantityOfSubnets) - } - - if in.QuantityPerSubnet > 0 { - obj["quantity_per_subnet"] = int(in.QuantityPerSubnet) - } - - if len(in.Region) > 0 { - obj["region"] = in.Region - } - - if len(in.ServiceCidr) > 0 { - obj["service_cidr"] = in.ServiceCidr - } - - if len(in.ServiceSubnetDNSDomainName) > 0 { - obj["service_dns_domain_name"] = in.ServiceSubnetDNSDomainName - } - - obj["skip_vcn_delete"] = in.SkipVCNDelete - - if len(in.TenancyID) > 0 { - obj["tenancy_id"] = in.TenancyID - } - - if len(in.UserOCID) > 0 { - obj["user_ocid"] = in.UserOCID - } - - if len(in.VcnCompartmentID) > 0 { - obj["vcn_compartment_id"] = in.VcnCompartmentID - } - - if len(in.VCNName) > 0 { - obj["vcn_name"] = in.VCNName - } - - if len(in.WorkerNodeIngressCidr) > 0 { - obj["worker_node_ingress_cidr"] = in.WorkerNodeIngressCidr - } - - return []interface{}{obj}, nil -} - -// Expanders - -func expandClusterOKEConfig(p []interface{}, name string) (*OracleKubernetesEngineConfig, error) { - obj := &OracleKubernetesEngineConfig{} - if len(p) == 0 || p[0] == nil { - return obj, nil - } - in := p[0].(map[string]interface{}) - - obj.DisplayName = name - obj.Name = name - obj.DriverName = clusterDriverOKE - - if v, ok := in["compartment_id"].(string); ok && len(v) > 0 { - obj.CompartmentID = v - } - - if v, ok := in["custom_boot_volume_size"].(int); ok && v > 0 { - obj.CustomBootVolumeSize = int64(v) - } - - if v, ok := in["description"].(string); ok && len(v) > 0 { - obj.Description = v - } - - if v, ok := in["enable_private_control_plane"].(bool); ok { - obj.PrivateControlPlane = v - } - - if v, ok := in["enable_kubernetes_dashboard"].(bool); ok { - obj.EnableKubernetesDashboard = v - } - - if v, ok := in["enable_private_nodes"].(bool); ok { - obj.PrivateNodes = v - } - - if v, ok := in["fingerprint"].(string); ok && len(v) > 0 { - obj.Fingerprint = v - } - - if v, ok := in["flex_ocpus"].(int); ok && v > 0 { - obj.FlexOCPUs = int64(v) - } - - if v, ok := in["kms_key_id"].(string); ok && len(v) > 0 { - obj.KMSKeyID = v - } - - if v, ok := in["kubernetes_version"].(string); ok && len(v) > 0 { - obj.KubernetesVersion = v - } - - if v, ok := in["limit_node_count"].(int); ok && v > 0 { - obj.LimitNodeCount = int64(v) - } - - if v, ok := in["load_balancer_subnet_name_1"].(string); ok && len(v) > 0 { - obj.ServiceLBSubnet1Name = v - } - - if v, ok := in["load_balancer_subnet_name_2"].(string); ok && len(v) > 0 { - obj.ServiceLBSubnet2Name = v - } - - if v, ok := in["name"].(string); ok && len(v) > 0 { - obj.Name = v - } - - if v, ok := in["node_image"].(string); ok && len(v) > 0 { - obj.NodeImage = v - } - - if v, ok := in["node_pool_dns_domain_name"].(string); ok && len(v) > 0 { - obj.NodePoolSubnetDNSDomainName = v - } - - if v, ok := in["node_pool_subnet_name"].(string); ok && len(v) > 0 { - obj.NodePoolSubnetName = v - } - - if v, ok := in["node_public_key_contents"].(string); ok && len(v) > 0 { - obj.NodePublicSSHKeyContents = v - } - - if v, ok := in["node_shape"].(string); ok && len(v) > 0 { - obj.NodeShape = v - } - - if v, ok := in["pod_cidr"].(string); ok && len(v) > 0 { - obj.PodCidr = v - } - - if v, ok := in["private_key_contents"].(string); ok && len(v) > 0 { - obj.PrivateKeyContents = v - } - - if v, ok := in["private_key_passphrase"].(string); ok && len(v) > 0 { - obj.PrivateKeyPassphrase = v - } - - if v, ok := in["quantity_of_node_subnets"].(int); ok && v > 0 { - obj.QuantityOfSubnets = int64(v) - } - - if v, ok := in["quantity_per_subnet"].(int); ok && v > 0 { - obj.QuantityPerSubnet = int64(v) - } - - if v, ok := in["region"].(string); ok && len(v) > 0 { - obj.Region = v - } - - if v, ok := in["service_dns_domain_name"].(string); ok && len(v) > 0 { - obj.ServiceSubnetDNSDomainName = v - } - - if v, ok := in["service_cidr"].(string); ok && len(v) > 0 { - obj.ServiceCidr = v - } - - if v, ok := in["skip_vcn_delete"].(bool); ok { - obj.SkipVCNDelete = v - } - - if v, ok := in["tenancy_id"].(string); ok && len(v) > 0 { - obj.TenancyID = v - } - - if v, ok := in["user_ocid"].(string); ok && len(v) > 0 { - obj.UserOCID = v - } - - if v, ok := in["vcn_compartment_id"].(string); ok && len(v) > 0 { - obj.VcnCompartmentID = v - } - - if v, ok := in["vcn_name"].(string); ok && len(v) > 0 { - obj.VCNName = v - } - - if v, ok := in["worker_node_ingress_cidr"].(string); ok && len(v) > 0 { - obj.WorkerNodeIngressCidr = v - } - - return obj, nil -} diff --git a/rancher2/structure_cluster_oke_config_test.go b/rancher2/structure_cluster_oke_config_test.go deleted file mode 100644 index 33c58185..00000000 --- a/rancher2/structure_cluster_oke_config_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2020 Oracle and/or its affiliates. - -package rancher2 - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -var ( - testClusterOKEConfigConf *OracleKubernetesEngineConfig - testClusterOKEConfigInterface []interface{} -) - -func init() { - testClusterOKEConfigConf = &OracleKubernetesEngineConfig{ - CompartmentID: "compartment", - CustomBootVolumeSize: 0, - Description: "description", - DisplayName: "test", - DriverName: clusterDriverOKE, - EnableKubernetesDashboard: true, - Fingerprint: "fingerprint", - FlexOCPUs: 0, - KubernetesVersion: "version", - KMSKeyID: "ocid1.key.oc1.reg.xxxxxxxxxxxxxxxxxx", - LimitNodeCount: 0, - Name: "test", - NodeImage: "image", - NodePoolSubnetDNSDomainName: "nodedns", - NodePoolSubnetName: "nodedns", - NodePublicSSHKeyContents: "public_key", - NodeShape: "shape", - PodCidr: "10.204.0.0/16", - PrivateKeyContents: "private_key_contents", - PrivateKeyPassphrase: "", - PrivateNodes: false, - QuantityOfSubnets: 2, - QuantityPerSubnet: 1, - Region: "region", - ServiceCidr: "10.98.0.0/16", - ServiceLBSubnet1Name: "", - ServiceLBSubnet2Name: "", - ServiceSubnetDNSDomainName: "svcdns", - SkipVCNDelete: false, - TenancyID: "tenancy", - UserOCID: "user", - VCNName: "", - VcnCompartmentID: "", - WorkerNodeIngressCidr: "", - } - testClusterOKEConfigInterface = []interface{}{ - map[string]interface{}{ - "compartment_id": "compartment", - "custom_boot_volume_size": 0, - "description": "description", - "enable_private_control_plane": false, - "enable_kubernetes_dashboard": true, - "enable_private_nodes": false, - "fingerprint": "fingerprint", - "flex_ocpus": 0, - "kms_key_id": "ocid1.key.oc1.reg.xxxxxxxxxxxxxxxxxx", - "kubernetes_version": "version", - "limit_node_count": 0, - "node_image": "image", - "node_pool_dns_domain_name": "nodedns", - "node_pool_subnet_name": "nodedns", - "node_public_key_contents": "public_key", - "node_shape": "shape", - "pod_cidr": "10.204.0.0/16", - "private_key_contents": "private_key_contents", - "private_key_passphrase": "", - "quantity_of_node_subnets": 2, - "quantity_per_subnet": 1, - "region": "region", - "load_balancer_subnet_name_1": "", - "load_balancer_subnet_name_2": "", - "service_cidr": "10.98.0.0/16", - "service_dns_domain_name": "svcdns", - "skip_vcn_delete": false, - "tenancy_id": "tenancy", - "user_ocid": "user", - "vcn_compartment_id": "", - "vcn_name": "", - "worker_node_ingress_cidr": "", - }, - } -} - -func TestFlattenClusterOKEConfig(t *testing.T) { - - cases := []struct { - Input *OracleKubernetesEngineConfig - ExpectedOutput []interface{} - }{ - { - testClusterOKEConfigConf, - testClusterOKEConfigInterface, - }, - } - - for _, tc := range cases { - output, err := flattenClusterOKEConfig(tc.Input, testClusterOKEConfigInterface) - if err != nil { - assert.FailNow(t, "[ERROR] on flattener: %#v", err) - } - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from flattener.") - } -} - -func TestExpandClusterOKEConfig(t *testing.T) { - - cases := []struct { - Input []interface{} - ExpectedOutput *OracleKubernetesEngineConfig - }{ - { - testClusterOKEConfigInterface, - testClusterOKEConfigConf, - }, - } - - for _, tc := range cases { - output, err := expandClusterOKEConfig(tc.Input, "test") - if err != nil { - assert.FailNow(t, "[ERROR] on expander: %#v", err) - } - assert.Equal(t, tc.ExpectedOutput, output, "Unexpected output from expander.") - } -} diff --git a/rancher2/structure_cluster_test.go b/rancher2/structure_cluster_test.go index 70080fef..1290bcc8 100644 --- a/rancher2/structure_cluster_test.go +++ b/rancher2/structure_cluster_test.go @@ -258,56 +258,6 @@ func testCluster() { testClusterGenerateKubeConfigOutput = &managementClient.GenerateKubeConfigOutput{ Config: "kube_config", } - testClusterConfAKS = &Cluster{ - AzureKubernetesServiceConfig: testClusterAKSConfigConf, - } - testClusterConfAKS.Name = "test" - testClusterConfAKS.Description = "description" - testClusterConfAKS.Driver = clusterDriverAKS - testClusterConfAKS.AgentEnvVars = testClusterEnvVarsConf - testClusterConfAKS.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfAKS.EnableNetworkPolicy = newTrue() - testClusterConfAKS.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf - testClusterInterfaceAKS = map[string]interface{}{ - "id": "id", - "name": "test", - "agent_env_vars": testClusterEnvVarsInterface, - "default_project_id": "default_project_id", - "description": "description", - "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, - "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverAKS, - "aks_config": testClusterAKSConfigInterface, - "system_project_id": "system_project_id", - } - testClusterConfEKS = &Cluster{ - AmazonElasticContainerServiceConfig: testClusterEKSConfigConf, - } - testClusterConfEKS.Name = "test" - testClusterConfEKS.Description = "description" - testClusterConfEKS.Driver = clusterDriverEKS - testClusterConfEKS.AgentEnvVars = testClusterEnvVarsConf - testClusterConfEKS.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfEKS.EnableNetworkPolicy = newTrue() - testClusterConfEKS.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf - testClusterInterfaceEKS = map[string]interface{}{ - "id": "id", - "name": "test", - "agent_env_vars": testClusterEnvVarsInterface, - "default_project_id": "default_project_id", - "description": "description", - "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, - "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverEKS, - "eks_config": testClusterEKSConfigInterface, - "system_project_id": "system_project_id", - } testClusterConfEKSV2 = &Cluster{} testClusterConfEKSV2.EKSConfig = testClusterEKSConfigV2Conf testClusterConfEKSV2.Name = "test" @@ -336,31 +286,6 @@ func testCluster() { "eks_config_v2": testClusterEKSConfigV2Interface, "system_project_id": "system_project_id", } - testClusterConfGKE = &Cluster{ - GoogleKubernetesEngineConfig: testClusterGKEConfigConf, - } - testClusterConfGKE.Name = "test" - testClusterConfGKE.Description = "description" - testClusterConfGKE.Driver = clusterDriverGKE - testClusterConfGKE.AgentEnvVars = testClusterEnvVarsConf - testClusterConfGKE.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfGKE.EnableNetworkPolicy = newTrue() - testClusterConfGKE.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf - testClusterInterfaceGKE = map[string]interface{}{ - "id": "id", - "name": "test", - "agent_env_vars": testClusterEnvVarsInterface, - "default_project_id": "default_project_id", - "description": "description", - "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, - "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterDriverGKE, - "gke_config": testClusterGKEConfigInterface, - "system_project_id": "system_project_id", - } testClusterConfK3S = &Cluster{} testClusterConfK3S.Name = "test" testClusterConfK3S.Description = "description" @@ -410,31 +335,6 @@ func testCluster() { "gke_config_v2": testClusterGKEConfigV2Interface, "system_project_id": "system_project_id", } - testClusterConfOKE = &Cluster{ - OracleKubernetesEngineConfig: testClusterOKEConfigConf, - } - testClusterConfOKE.Name = "test" - testClusterConfOKE.Description = "description" - testClusterConfOKE.Driver = clusterOKEKind - testClusterConfOKE.AgentEnvVars = testClusterEnvVarsConf - testClusterConfOKE.DefaultPodSecurityAdmissionConfigurationTemplateName = "default_pod_security_admission_configuration_template_name" - testClusterConfOKE.EnableNetworkPolicy = newTrue() - testClusterConfOKE.LocalClusterAuthEndpoint = testLocalClusterAuthEndpointConf - testClusterInterfaceOKE = map[string]interface{}{ - "id": "id", - "name": "test", - "agent_env_vars": testClusterEnvVarsInterface, - "default_project_id": "default_project_id", - "description": "description", - "cluster_auth_endpoint": testLocalClusterAuthEndpointInterface, - "cluster_registration_token": testClusterRegistrationTokenInterface, - "default_pod_security_admission_configuration_template_name": "default_pod_security_admission_configuration_template_name", - "enable_network_policy": true, - "kube_config": "kube_config", - "driver": clusterOKEKind, - "oke_config": testClusterOKEConfigInterface, - "system_project_id": "system_project_id", - } testClusterConfRKE = &Cluster{} testClusterConfRKE.Name = "test" testClusterConfRKE.Description = "description" @@ -629,9 +529,6 @@ func TestFlattenCluster(t *testing.T) { if tc.ExpectedOutput["driver"] == clusterDriverRKE { expectedOutput["rke_config"], _ = flattenClusterRKEConfig(tc.Input.RancherKubernetesEngineConfig, []interface{}{}) } - if tc.ExpectedOutput["driver"] == clusterDriverAKS { - expectedOutput["aks_config"], _ = flattenClusterAKSConfig(tc.Input.AzureKubernetesServiceConfig, []interface{}{}) - } if tc.ExpectedOutput["cluster_agent_deployment_customization"] != nil { expectedOutput["cluster_agent_deployment_customization"] = flattenAgentDeploymentCustomization(tc.Input.ClusterAgentDeploymentCustomization) }