Skip to content

Commit

Permalink
Also changed other fields to Set
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcturusZhang committed Apr 15, 2020
1 parent 4fda8cf commit 4324ffa
Showing 1 changed file with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func resourceArmApplicationGateway() *schema.Resource {
Required: true,
ForceNew: true,
},

"identity": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -102,7 +103,7 @@ func resourceArmApplicationGateway() *schema.Resource {

// Required
"backend_address_pool": {
Type: schema.TypeList,
Type: schema.TypeSet,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -139,7 +140,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"backend_http_settings": {
Type: schema.TypeList,
Type: schema.TypeSet,
Required: true,
MinItems: 1,
Elem: &schema.Resource{
Expand Down Expand Up @@ -204,7 +205,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"authentication_certificate": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -269,7 +270,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"frontend_ip_configuration": {
Type: schema.TypeList,
Type: schema.TypeSet,
Required: true,
MinItems: 1,
Elem: &schema.Resource{
Expand Down Expand Up @@ -366,7 +367,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"http_listener": {
Type: schema.TypeList,
Type: schema.TypeSet,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -430,7 +431,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"custom_error_configuration": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -460,7 +461,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"request_routing_rule": {
Type: schema.TypeList,
Type: schema.TypeSet,
Required: true,
MinItems: 1,
Elem: &schema.Resource{
Expand Down Expand Up @@ -551,7 +552,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"redirect_configuration": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -608,6 +609,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},
},
},

"autoscale_configuration": {
Type: schema.TypeList,
Optional: true,
Expand All @@ -627,6 +629,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},
},
},

"sku": {
Type: schema.TypeList,
Required: true,
Expand Down Expand Up @@ -670,7 +673,7 @@ func resourceArmApplicationGateway() *schema.Resource {

// Optional
"authentication_certificate": {
Type: schema.TypeList, // todo this should probably be a map
Type: schema.TypeSet, // todo this should probably be a map
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand All @@ -696,7 +699,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"trusted_root_certificate": {
Type: schema.TypeList, // todo this should probably be a map
Type: schema.TypeSet, // todo this should probably be a map
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -789,7 +792,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"probe": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -877,7 +880,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"rewrite_rule_set": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -977,8 +980,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"ssl_certificate": {
// TODO: should this become a Set?
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -1020,7 +1022,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"url_path_map": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -1052,7 +1054,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"path_rule": {
Type: schema.TypeList,
Type: schema.TypeSet,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -1283,7 +1285,7 @@ func resourceArmApplicationGateway() *schema.Resource {
},

"custom_error_configuration": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -1348,7 +1350,7 @@ func resourceArmApplicationGatewayCreateUpdate(d *schema.ResourceData, meta inte
gatewayIDFmt := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationGateways/%s"
gatewayID := fmt.Sprintf(gatewayIDFmt, armClient.Account.SubscriptionId, resGroup, name)

trustedRootCertificates := expandApplicationGatewayTrustedRootCertificates(d.Get("trusted_root_certificate").([]interface{}))
trustedRootCertificates := expandApplicationGatewayTrustedRootCertificates(d.Get("trusted_root_certificate").(*schema.Set).List())

requestRoutingRules, err := expandApplicationGatewayRequestRoutingRules(d, gatewayID)
if err != nil {
Expand Down Expand Up @@ -1379,9 +1381,9 @@ func resourceArmApplicationGatewayCreateUpdate(d *schema.ResourceData, meta inte
Tags: tags.Expand(t),
ApplicationGatewayPropertiesFormat: &network.ApplicationGatewayPropertiesFormat{
AutoscaleConfiguration: expandApplicationGatewayAutoscaleConfiguration(d),
AuthenticationCertificates: expandApplicationGatewayAuthenticationCertificates(d.Get("authentication_certificate").([]interface{})),
AuthenticationCertificates: expandApplicationGatewayAuthenticationCertificates(d.Get("authentication_certificate").(*schema.Set).List()),
TrustedRootCertificates: trustedRootCertificates,
CustomErrorConfigurations: expandApplicationGatewayCustomErrorConfigurations(d.Get("custom_error_configuration").([]interface{})),
CustomErrorConfigurations: expandApplicationGatewayCustomErrorConfigurations(d.Get("custom_error_configuration").(*schema.Set).List()),
BackendAddressPools: expandApplicationGatewayBackendAddressPools(d),
BackendHTTPSettingsCollection: expandApplicationGatewayBackendHTTPSettings(d, gatewayID),
EnableHTTP2: utils.Bool(enablehttp2),
Expand Down Expand Up @@ -1747,7 +1749,7 @@ func flattenApplicationGatewayAuthenticationCertificates(certs *[]network.Applic
// since the certificate data isn't returned lets load any existing data
nameToDataMap := map[string]string{}
if existing, ok := d.GetOk("authentication_certificate"); ok && existing != nil {
for _, c := range existing.([]interface{}) {
for _, c := range existing.(*schema.Set).List() {
b := c.(map[string]interface{})
nameToDataMap[b["name"].(string)] = b["data"].(string)
}
Expand Down Expand Up @@ -1784,7 +1786,7 @@ func flattenApplicationGatewayTrustedRootCertificates(certs *[]network.Applicati
// since the certificate data isn't returned lets load any existing data
nameToDataMap := map[string]string{}
if existing, ok := d.GetOk("trusted_root_certificate"); ok && existing != nil {
for _, c := range existing.([]interface{}) {
for _, c := range existing.(*schema.Set).List() {
b := c.(map[string]interface{})
nameToDataMap[b["name"].(string)] = b["data"].(string)
}
Expand Down Expand Up @@ -1821,7 +1823,7 @@ func flattenApplicationGatewayTrustedRootCertificates(certs *[]network.Applicati
}

func expandApplicationGatewayBackendAddressPools(d *schema.ResourceData) *[]network.ApplicationGatewayBackendAddressPool {
vs := d.Get("backend_address_pool").([]interface{})
vs := d.Get("backend_address_pool").(*schema.Set).List()
results := make([]network.ApplicationGatewayBackendAddressPool, 0)

for _, raw := range vs {
Expand Down Expand Up @@ -1896,7 +1898,7 @@ func flattenApplicationGatewayBackendAddressPools(input *[]network.ApplicationGa

func expandApplicationGatewayBackendHTTPSettings(d *schema.ResourceData, gatewayID string) *[]network.ApplicationGatewayBackendHTTPSettings {
results := make([]network.ApplicationGatewayBackendHTTPSettings, 0)
vs := d.Get("backend_http_settings").([]interface{})
vs := d.Get("backend_http_settings").(*schema.Set).List()

for _, raw := range vs {
v := raw.(map[string]interface{})
Expand Down Expand Up @@ -1933,7 +1935,7 @@ func expandApplicationGatewayBackendHTTPSettings(d *schema.ResourceData, gateway
}

if v["authentication_certificate"] != nil {
authCerts := v["authentication_certificate"].([]interface{})
authCerts := v["authentication_certificate"].(*schema.Set).List()
authCertSubResources := make([]network.SubResource, 0)

for _, rawAuthCert := range authCerts {
Expand Down Expand Up @@ -2196,7 +2198,7 @@ func flattenApplicationGatewaySslPolicy(input *network.ApplicationGatewaySslPoli
}

func expandApplicationGatewayHTTPListeners(d *schema.ResourceData, gatewayID string) *[]network.ApplicationGatewayHTTPListener {
vs := d.Get("http_listener").([]interface{})
vs := d.Get("http_listener").(*schema.Set).List()
results := make([]network.ApplicationGatewayHTTPListener, 0)

for _, raw := range vs {
Expand All @@ -2211,7 +2213,7 @@ func expandApplicationGatewayHTTPListeners(d *schema.ResourceData, gatewayID str
frontendIPConfigID := fmt.Sprintf("%s/frontendIPConfigurations/%s", gatewayID, frontendIPConfigName)
frontendPortID := fmt.Sprintf("%s/frontendPorts/%s", gatewayID, frontendPortName)

customErrorConfigurations := expandApplicationGatewayCustomErrorConfigurations(v["custom_error_configuration"].([]interface{}))
customErrorConfigurations := expandApplicationGatewayCustomErrorConfigurations(v["custom_error_configuration"].(*schema.Set).List())

listener := network.ApplicationGatewayHTTPListener{
Name: utils.String(name),
Expand Down Expand Up @@ -2455,7 +2457,7 @@ func flattenApplicationGatewayFrontendPorts(input *[]network.ApplicationGatewayF
}

func expandApplicationGatewayFrontendIPConfigurations(d *schema.ResourceData) *[]network.ApplicationGatewayFrontendIPConfiguration {
vs := d.Get("frontend_ip_configuration").([]interface{})
vs := d.Get("frontend_ip_configuration").(*schema.Set).List()
results := make([]network.ApplicationGatewayFrontendIPConfiguration, 0)

for _, raw := range vs {
Expand Down Expand Up @@ -2534,7 +2536,7 @@ func flattenApplicationGatewayFrontendIPConfigurations(input *[]network.Applicat
}

func expandApplicationGatewayProbes(d *schema.ResourceData) *[]network.ApplicationGatewayProbe {
vs := d.Get("probe").([]interface{})
vs := d.Get("probe").(*schema.Set).List()
results := make([]network.ApplicationGatewayProbe, 0)

for _, raw := range vs {
Expand Down Expand Up @@ -2662,7 +2664,7 @@ func flattenApplicationGatewayProbes(input *[]network.ApplicationGatewayProbe) [
}

func expandApplicationGatewayRequestRoutingRules(d *schema.ResourceData, gatewayID string) (*[]network.ApplicationGatewayRequestRoutingRule, error) {
vs := d.Get("request_routing_rule").([]interface{})
vs := d.Get("request_routing_rule").(*schema.Set).List()
results := make([]network.ApplicationGatewayRequestRoutingRule, 0)

for _, raw := range vs {
Expand Down Expand Up @@ -2835,7 +2837,7 @@ func flattenApplicationGatewayRequestRoutingRules(input *[]network.ApplicationGa
}

func expandApplicationGatewayRewriteRuleSets(d *schema.ResourceData) *[]network.ApplicationGatewayRewriteRuleSet {
vs := d.Get("rewrite_rule_set").([]interface{})
vs := d.Get("rewrite_rule_set").(*schema.Set).List()
ruleSets := make([]network.ApplicationGatewayRewriteRuleSet, 0)

for _, raw := range vs {
Expand Down Expand Up @@ -3014,7 +3016,7 @@ func flattenApplicationGatewayRewriteRuleSets(input *[]network.ApplicationGatewa
}

func expandApplicationGatewayRedirectConfigurations(d *schema.ResourceData, gatewayID string) (*[]network.ApplicationGatewayRedirectConfiguration, error) {
vs := d.Get("redirect_configuration").([]interface{})
vs := d.Get("redirect_configuration").(*schema.Set).List()
results := make([]network.ApplicationGatewayRedirectConfiguration, 0)

for _, raw := range vs {
Expand Down Expand Up @@ -3181,7 +3183,7 @@ func flattenApplicationGatewaySku(input *network.ApplicationGatewaySku) []interf
}

func expandApplicationGatewaySslCertificates(d *schema.ResourceData) (*[]network.ApplicationGatewaySslCertificate, error) {
vs := d.Get("ssl_certificate").([]interface{})
vs := d.Get("ssl_certificate").(*schema.Set).List()
results := make([]network.ApplicationGatewaySslCertificate, 0)

for _, raw := range vs {
Expand Down Expand Up @@ -3257,7 +3259,7 @@ func flattenApplicationGatewaySslCertificates(input *[]network.ApplicationGatewa

// since the certificate data isn't returned we have to load it from the same index
if existing, ok := d.GetOk("ssl_certificate"); ok && existing != nil {
existingVals := existing.([]interface{})
existingVals := existing.(*schema.Set).List()
for _, existingVal := range existingVals {
existingCerts := existingVal.(map[string]interface{})
existingName := existingCerts["name"].(string)
Expand All @@ -3282,7 +3284,7 @@ func flattenApplicationGatewaySslCertificates(input *[]network.ApplicationGatewa
}

func expandApplicationGatewayURLPathMaps(d *schema.ResourceData, gatewayID string) (*[]network.ApplicationGatewayURLPathMap, error) {
vs := d.Get("url_path_map").([]interface{})
vs := d.Get("url_path_map").(*schema.Set).List()
results := make([]network.ApplicationGatewayURLPathMap, 0)

for _, raw := range vs {
Expand All @@ -3291,7 +3293,7 @@ func expandApplicationGatewayURLPathMaps(d *schema.ResourceData, gatewayID strin
name := v["name"].(string)

pathRules := make([]network.ApplicationGatewayPathRule, 0)
for _, ruleConfig := range v["path_rule"].([]interface{}) {
for _, ruleConfig := range v["path_rule"].(*schema.Set).List() {
ruleConfigMap := ruleConfig.(map[string]interface{})

ruleName := ruleConfigMap["name"].(string)
Expand Down

0 comments on commit 4324ffa

Please sign in to comment.