Skip to content

Commit 86de757

Browse files
authored
Merge pull request #660 from rawmind0/akstag
Deprecated rancher2_cluster.aks_config.tag argument in favour of new rancher2_cluster.aks_config.tags
2 parents f6a0aee + 2fff047 commit 86de757

6 files changed

Lines changed: 74 additions & 52 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
FEATURES:
44

5+
* **Deprecated Argument:** `rancher2_cluster.aks_config.tag` - (Deprecated) Use `tags` argument instead as []string
6+
* **New Argument:** `rancher2_cluster.aks_config.tags` - (Optional/Computed) Tags for Kubernetes cluster. For example, `["foo=bar","bar=foo"]` (list)
57
* **New Argument:** `rancher2_cluster.agent_env_vars` - (Optional) Optional Agent Env Vars for Rancher agent. Just for Rancher v2.5.6 and above (list)
68

7-
89
ENHANCEMENTS:
910

1011

docs/resources/cluster.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,8 @@ The following arguments are supported:
12011201
* `network_policy` - (Optional) Network policy used for building Kubernetes network. Chooses from `calico` (string)
12021202
* `pod_cidr` - (Optional) A CIDR notation IP range from which to assign Kubernetes Pod IPs when \"network plugin\" is specified in \"kubenet\". Default `172.244.0.0/16` (string)
12031203
* `service_cidr` - (Optional) A CIDR notation IP range from which to assign Kubernetes Service cluster IPs. It must not overlap with any Subnet IP ranges. Default `10.0.0.0/16` (string)
1204-
* `tag` - (Optional/Computed) Tags for Kubernetes cluster. For example, foo=bar (map)
1204+
* `tag` - (Deprecated) Use `tags` argument instead as []string
1205+
* `tags` - (Optional/Computed) Tags for Kubernetes cluster. For example, `["foo=bar","bar=foo"]` (list)
12051206

12061207
### `eks_config`
12071208

rancher2/schema_cluster_aks_config.go

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,47 @@ var (
2525
//Types
2626

2727
type AzureKubernetesServiceConfig struct {
28-
AADClientAppID string `json:"addClientAppId,omitempty" yaml:"addClientAppId,omitempty"`
29-
AADServerAppID string `json:"addServerAppId,omitempty" yaml:"addServerAppId,omitempty"`
30-
AADServerAppSecret string `json:"addServerAppSecret,omitempty" yaml:"addServerAppSecret,omitempty"`
31-
AADTenantID string `json:"addTenantId,omitempty" yaml:"addTenantId,omitempty"`
32-
AdminUsername string `json:"adminUsername,omitempty" yaml:"adminUsername,omitempty"`
33-
AgentDNSPrefix string `json:"agentDnsPrefix,omitempty" yaml:"agentDnsPrefix,omitempty"`
34-
AgentOsdiskSizeGB int64 `json:"agentOsdiskSize,omitempty" yaml:"agentOsdiskSize,omitempty"`
35-
AgentPoolName string `json:"agentPoolName,omitempty" yaml:"agentPoolName,omitempty"`
36-
AgentStorageProfile string `json:"agentStorageProfile,omitempty" yaml:"agentStorageProfile,omitempty"`
37-
AgentVMSize string `json:"agentVmSize,omitempty" yaml:"agentVmSize,omitempty"`
38-
AuthBaseURL string `json:"authBaseUrl" yaml:"authBaseUrl"`
39-
BaseURL string `json:"baseUrl,omitempty" yaml:"baseUrl,omitempty"`
40-
ClientID string `json:"clientId,omitempty" yaml:"clientId,omitempty"`
41-
ClientSecret string `json:"clientSecret,omitempty" yaml:"clientSecret,omitempty"`
42-
Count int64 `json:"count,omitempty" yaml:"count,omitempty"`
43-
DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"`
44-
DriverName string `json:"driverName,omitempty" yaml:"driverName,omitempty"`
45-
DNSServiceIP string `json:"dnsServiceIp,omitempty" yaml:"dnsServiceIp,omitempty"`
46-
DockerBridgeCIDR string `json:"dockerBridgeCidr,omitempty" yaml:"dockerBridgeCidr,omitempty"`
47-
EnableHTTPApplicationRouting bool `json:"enableHttpApplicationRouting,omitempty" yaml:"enableHttpApplicationRouting,omitempty"`
48-
EnableMonitoring *bool `json:"enableMonitoring,omitempty" yaml:"enableMonitoring,omitempty"`
49-
KubernetesVersion string `json:"kubernetesVersion,omitempty" yaml:"kubernetesVersion,omitempty"`
50-
LoadBalancerSku string `json:"loadBalancerSku,omitempty" yaml:"loadBalancerSku,omitempty"`
51-
Location string `json:"location,omitempty" yaml:"location,omitempty"`
52-
LogAnalyticsWorkspace string `json:"logAnalyticsWorkspace,omitempty" yaml:"logAnalyticsWorkspace,omitempty"`
53-
LogAnalyticsWorkspaceResourceGroup string `json:"logAnalyticsWorkspaceResourceGroup,omitempty" yaml:"logAnalyticsWorkspaceResourceGroup,omitempty"`
54-
MasterDNSPrefix string `json:"masterDnsPrefix,omitempty" yaml:"masterDnsPrefix,omitempty"`
55-
MaxPods int64 `json:"maxPods,omitempty" yaml:"maxPods,omitempty"`
56-
Name string `json:"name,omitempty" yaml:"name,omitempty"`
57-
NetworkPlugin string `json:"networkPlugin,omitempty" yaml:"networkPlugin,omitempty"`
58-
NetworkPolicy string `json:"networkPolicy,omitempty" yaml:"networkPolicy,omitempty"`
59-
PodCIDR string `json:"podCidr,omitempty" yaml:"podCidr,omitempty"`
60-
ResourceGroup string `json:"resourceGroup,omitempty" yaml:"resourceGroup,omitempty"`
61-
SSHPublicKeyContents string `json:"sshPublicKeyContents,omitempty" yaml:"sshPublicKeyContents,omitempty"`
62-
ServiceCIDR string `json:"serviceCidr,omitempty" yaml:"serviceCidr,omitempty"`
63-
Subnet string `json:"subnet,omitempty" yaml:"subnet,omitempty"`
64-
SubscriptionID string `json:"subscriptionId,omitempty" yaml:"subscriptionId,omitempty"`
65-
Tag map[string]string `json:"tags,omitempty" yaml:"tags,omitempty"`
66-
TenantID string `json:"tenantId,omitempty" yaml:"tenantId,omitempty"`
67-
VirtualNetwork string `json:"virtualNetwork,omitempty" yaml:"virtualNetwork,omitempty"`
68-
VirtualNetworkResourceGroup string `json:"virtualNetworkResourceGroup,omitempty" yaml:"virtualNetworkResourceGroup,omitempty"`
28+
AADClientAppID string `json:"addClientAppId,omitempty" yaml:"addClientAppId,omitempty"`
29+
AADServerAppID string `json:"addServerAppId,omitempty" yaml:"addServerAppId,omitempty"`
30+
AADServerAppSecret string `json:"addServerAppSecret,omitempty" yaml:"addServerAppSecret,omitempty"`
31+
AADTenantID string `json:"addTenantId,omitempty" yaml:"addTenantId,omitempty"`
32+
AdminUsername string `json:"adminUsername,omitempty" yaml:"adminUsername,omitempty"`
33+
AgentDNSPrefix string `json:"agentDnsPrefix,omitempty" yaml:"agentDnsPrefix,omitempty"`
34+
AgentOsdiskSizeGB int64 `json:"agentOsdiskSize,omitempty" yaml:"agentOsdiskSize,omitempty"`
35+
AgentPoolName string `json:"agentPoolName,omitempty" yaml:"agentPoolName,omitempty"`
36+
AgentStorageProfile string `json:"agentStorageProfile,omitempty" yaml:"agentStorageProfile,omitempty"`
37+
AgentVMSize string `json:"agentVmSize,omitempty" yaml:"agentVmSize,omitempty"`
38+
AuthBaseURL string `json:"authBaseUrl" yaml:"authBaseUrl"`
39+
BaseURL string `json:"baseUrl,omitempty" yaml:"baseUrl,omitempty"`
40+
ClientID string `json:"clientId,omitempty" yaml:"clientId,omitempty"`
41+
ClientSecret string `json:"clientSecret,omitempty" yaml:"clientSecret,omitempty"`
42+
Count int64 `json:"count,omitempty" yaml:"count,omitempty"`
43+
DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"`
44+
DriverName string `json:"driverName,omitempty" yaml:"driverName,omitempty"`
45+
DNSServiceIP string `json:"dnsServiceIp,omitempty" yaml:"dnsServiceIp,omitempty"`
46+
DockerBridgeCIDR string `json:"dockerBridgeCidr,omitempty" yaml:"dockerBridgeCidr,omitempty"`
47+
EnableHTTPApplicationRouting bool `json:"enableHttpApplicationRouting,omitempty" yaml:"enableHttpApplicationRouting,omitempty"`
48+
EnableMonitoring *bool `json:"enableMonitoring,omitempty" yaml:"enableMonitoring,omitempty"`
49+
KubernetesVersion string `json:"kubernetesVersion,omitempty" yaml:"kubernetesVersion,omitempty"`
50+
LoadBalancerSku string `json:"loadBalancerSku,omitempty" yaml:"loadBalancerSku,omitempty"`
51+
Location string `json:"location,omitempty" yaml:"location,omitempty"`
52+
LogAnalyticsWorkspace string `json:"logAnalyticsWorkspace,omitempty" yaml:"logAnalyticsWorkspace,omitempty"`
53+
LogAnalyticsWorkspaceResourceGroup string `json:"logAnalyticsWorkspaceResourceGroup,omitempty" yaml:"logAnalyticsWorkspaceResourceGroup,omitempty"`
54+
MasterDNSPrefix string `json:"masterDnsPrefix,omitempty" yaml:"masterDnsPrefix,omitempty"`
55+
MaxPods int64 `json:"maxPods,omitempty" yaml:"maxPods,omitempty"`
56+
Name string `json:"name,omitempty" yaml:"name,omitempty"`
57+
NetworkPlugin string `json:"networkPlugin,omitempty" yaml:"networkPlugin,omitempty"`
58+
NetworkPolicy string `json:"networkPolicy,omitempty" yaml:"networkPolicy,omitempty"`
59+
PodCIDR string `json:"podCidr,omitempty" yaml:"podCidr,omitempty"`
60+
ResourceGroup string `json:"resourceGroup,omitempty" yaml:"resourceGroup,omitempty"`
61+
SSHPublicKeyContents string `json:"sshPublicKeyContents,omitempty" yaml:"sshPublicKeyContents,omitempty"`
62+
ServiceCIDR string `json:"serviceCidr,omitempty" yaml:"serviceCidr,omitempty"`
63+
Subnet string `json:"subnet,omitempty" yaml:"subnet,omitempty"`
64+
SubscriptionID string `json:"subscriptionId,omitempty" yaml:"subscriptionId,omitempty"`
65+
Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
66+
TenantID string `json:"tenantId,omitempty" yaml:"tenantId,omitempty"`
67+
VirtualNetwork string `json:"virtualNetwork,omitempty" yaml:"virtualNetwork,omitempty"`
68+
VirtualNetworkResourceGroup string `json:"virtualNetworkResourceGroup,omitempty" yaml:"virtualNetworkResourceGroup,omitempty"`
6969
}
7070

7171
//Schemas
@@ -289,6 +289,16 @@ func clusterAKSConfigFields() map[string]*schema.Schema {
289289
Optional: true,
290290
Computed: true,
291291
Description: "Tags for Kubernetes cluster. For example, foo=bar",
292+
Deprecated: "Use tags argument instead as []string",
293+
},
294+
"tags": {
295+
Type: schema.TypeList,
296+
Optional: true,
297+
Computed: true,
298+
Description: "Tags for Kubernetes cluster. For example, `[\"foo=bar\",\"bar=foo\"]`",
299+
Elem: &schema.Schema{
300+
Type: schema.TypeString,
301+
},
292302
},
293303
}
294304

rancher2/structure_cluster_aks_config.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ func flattenClusterAKSConfig(in *AzureKubernetesServiceConfig, p []interface{})
145145
obj["subscription_id"] = in.SubscriptionID
146146
}
147147

148-
if len(in.Tag) > 0 {
149-
obj["tag"] = toMapInterface(in.Tag)
148+
if len(in.Tags) > 0 {
149+
obj["tags"] = toArrayInterface(in.Tags)
150150
}
151151

152152
if len(in.TenantID) > 0 {
@@ -314,7 +314,14 @@ func expandClusterAKSConfig(p []interface{}, name string) (*AzureKubernetesServi
314314
}
315315

316316
if v, ok := in["tag"].(map[string]interface{}); ok && len(v) > 0 {
317-
obj.Tag = toMapString(v)
317+
tagMap := toMapString(v)
318+
for k, value := range tagMap {
319+
obj.Tags = append(obj.Tags, k+"="+value)
320+
}
321+
}
322+
323+
if v, ok := in["tags"].([]interface{}); ok && len(v) > 0 {
324+
obj.Tags = toArrayString(v)
318325
}
319326

320327
if v, ok := in["tenant_id"].(string); ok && len(v) > 0 {

rancher2/structure_cluster_aks_config_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ func init() {
4949
ServiceCIDR: "service_cidr",
5050
Subnet: "subnet",
5151
SubscriptionID: "subscription_id",
52-
Tag: map[string]string{
53-
"tag1": "value1",
54-
"tag2": "value2",
52+
Tags: []string{
53+
"tag1=value1",
54+
"tag2=value2",
5555
},
5656
TenantID: "tenant_id",
5757
VirtualNetwork: "virtual_network",
@@ -93,9 +93,9 @@ func init() {
9393
"service_cidr": "service_cidr",
9494
"subnet": "subnet",
9595
"subscription_id": "subscription_id",
96-
"tag": map[string]interface{}{
97-
"tag1": "value1",
98-
"tag2": "value2",
96+
"tags": []interface{}{
97+
"tag1=value1",
98+
"tag2=value2",
9999
},
100100
"tenant_id": "tenant_id",
101101
"virtual_network": "virtual_network",

rancher2/structure_cluster_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,9 @@ func TestFlattenCluster(t *testing.T) {
606606
if tc.ExpectedOutput["driver"] == clusterDriverRKE {
607607
expectedOutput["rke_config"], _ = flattenClusterRKEConfig(tc.Input.RancherKubernetesEngineConfig, []interface{}{})
608608
}
609+
if tc.ExpectedOutput["driver"] == clusterDriverAKS {
610+
expectedOutput["aks_config"], _ = flattenClusterAKSConfig(tc.Input.AzureKubernetesServiceConfig, []interface{}{})
611+
}
609612
expectedOutput["id"] = "id"
610613
if !reflect.DeepEqual(expectedOutput, tc.ExpectedOutput) {
611614
t.Fatalf("Unexpected output from flattener.\nExpected: %#v\nGiven: %#v",

0 commit comments

Comments
 (0)