Skip to content

Commit

Permalink
AV-64554: changed the optional parameters without defaults to computed (
Browse files Browse the repository at this point in the history
#135)

* New terraform resources where optional fields without defaults are made computed

* removed the computed for the array fields

* added comments

* fixed pool datasource and added test for it

* AV-64554: Added more debugs
  • Loading branch information
Gaurav Rastogi authored and chaitanyaavi committed Jul 3, 2019
1 parent 8fc1833 commit 4751796
Show file tree
Hide file tree
Showing 80 changed files with 3,417 additions and 338 deletions.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test: fmtcheck

testacc: fmtcheck
@if [ "${specific_test}" ]; then \
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -run=TestAVI${specific_test}Basic; \
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -run=${specific_test}; \
else \
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m; \
fi
Expand Down
81 changes: 63 additions & 18 deletions avi/data_source_avi_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ func TestAVIDataSourcePoolBasic(t *testing.T) {
resource.TestCheckResourceAttr(
"avi_pool.testPool", "name", "test-Pool-abc"),
resource.TestCheckResourceAttr(
"avi_pool.testPool", "ignore_servers", "false"),
"avi_pool.testPool", "enabled", "false"),
),
},
{
Config: testAccAVIDSPoolConfigIgnoreServers,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"avi_pool.testPool2", "name", "test-Pool-2"),
resource.TestCheckResourceAttr(
"avi_pool.testPool2", "ignore_servers", "true"),
),
ExpectNonEmptyPlan: true,
},
},
})

Expand All @@ -35,27 +45,62 @@ data "avi_healthmonitor" "default_monitor" {
name= "System-HTTP"
}
resource "avi_pool" "testPool" {
"ignore_servers" = false
"name" = "test-Pool-abc"
"cloud_ref" = "${data.avi_cloud.default_cloud.id}"
"tenant_ref" = "${data.avi_tenant.default_tenant.id}"
"servers" {
"ip" {
"type" = "V4"
"addr" = "10.90.64.66"
}
"hostname" = "10.90.64.66"
"ratio" = "1"
"port" = "8080"
"enabled" = true
}
"health_monitor_refs" = ["${data.avi_healthmonitor.default_monitor.id}"]
"fail_action" {
"type" = "FAIL_ACTION_CLOSE_CONN"
"ignore_servers" = false
"name" = "test-Pool-abc"
"cloud_ref" = "${data.avi_cloud.default_cloud.id}"
"tenant_ref" = "${data.avi_tenant.default_tenant.id}"
"enabled" = false
"servers" {
"ip" {
"type" = "V4"
"addr" = "10.90.64.66"
}
"hostname" = "10.90.64.66"
"ratio" = "1"
"port" = "8080"
"enabled" = true
}
"health_monitor_refs" = ["${data.avi_healthmonitor.default_monitor.id}"]
"fail_action" {
"type" = "FAIL_ACTION_CLOSE_CONN"
}
}
data "avi_pool" "testPool" {
name= "${avi_pool.testPool.name}"
ignore_servers= false
}
`
const testAccAVIDSPoolConfigIgnoreServers = `
data "avi_tenant" "default_tenant"{
name= "admin"
}
data "avi_cloud" "default_cloud" {
name= "Default-Cloud"
}
data "avi_healthmonitor" "default_monitor" {
name= "System-HTTP"
}
resource "avi_pool" "testPool2" {
"ignore_servers" = true
"name" = "test-Pool-2"
"cloud_ref" = "${data.avi_cloud.default_cloud.id}"
"tenant_ref" = "${data.avi_tenant.default_tenant.id}"
"enabled" = false
"health_monitor_refs" = ["${data.avi_healthmonitor.default_monitor.id}"]
"fail_action" {
"type" = "FAIL_ACTION_CLOSE_CONN"
}
}
resource "avi_server" "server" {
ip = "10.90.64.66"
hostname= "10.90.64.66"
pool_ref = "${avi_pool.testPool2.id}"
}
data "avi_pool" "testPool2" {
name= "${avi_pool.testPool2.name}"
ignore_servers= true
}
`
4 changes: 2 additions & 2 deletions avi/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ func Provider() terraform.ResourceProvider {
"avi_l4policyset": dataSourceAviL4PolicySet(),
"avi_scheduler": dataSourceAviScheduler(),
"avi_backupconfiguration": dataSourceAviBackupConfiguration(),
"avi_tenant": dataSourceAviTenant(),
"avi_serviceenginegroup": dataSourceAviServiceEngineGroup(),
"avi_networkservice": dataSourceAviNetworkService(),
"avi_dnspolicy": dataSourceAviDnsPolicy(),
"avi_tenant": dataSourceAviTenant(),
"avi_hardwaresecuritymodulegroup": dataSourceAviHardwareSecurityModuleGroup(),
"avi_vrfcontext": dataSourceAviVrfContext(),
"avi_securitypolicy": dataSourceAviSecurityPolicy(),
Expand Down Expand Up @@ -148,10 +148,10 @@ func Provider() terraform.ResourceProvider {
"avi_l4policyset": resourceAviL4PolicySet(),
"avi_scheduler": resourceAviScheduler(),
"avi_backupconfiguration": resourceAviBackupConfiguration(),
"avi_tenant": resourceAviTenant(),
"avi_serviceenginegroup": resourceAviServiceEngineGroup(),
"avi_networkservice": resourceAviNetworkService(),
"avi_dnspolicy": resourceAviDnsPolicy(),
"avi_tenant": resourceAviTenant(),
"avi_hardwaresecuritymodulegroup": resourceAviHardwareSecurityModuleGroup(),
"avi_vrfcontext": resourceAviVrfContext(),
"avi_securitypolicy": resourceAviSecurityPolicy(),
Expand Down
1 change: 1 addition & 0 deletions avi/resource_avi_actiongroupconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func ResourceActionGroupConfigSchema() map[string]*schema.Schema {
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"email_config_ref": {
Type: schema.TypeString,
Expand Down
6 changes: 6 additions & 0 deletions avi/resource_avi_alertconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func ResourceAlertConfigSchema() map[string]*schema.Schema {
"autoscale_alert": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"category": {
Type: schema.TypeString,
Expand All @@ -35,6 +36,7 @@ func ResourceAlertConfigSchema() map[string]*schema.Schema {
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"enabled": {
Type: schema.TypeBool,
Expand All @@ -53,14 +55,17 @@ func ResourceAlertConfigSchema() map[string]*schema.Schema {
"obj_uuid": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"object_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"recommendation": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"rolling_window": {
Type: schema.TypeInt,
Expand All @@ -74,6 +79,7 @@ func ResourceAlertConfigSchema() map[string]*schema.Schema {
"summary": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"tenant_ref": {
Type: schema.TypeString,
Expand Down
2 changes: 2 additions & 0 deletions avi/resource_avi_alertemailconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ func ResourceAlertEmailConfigSchema() map[string]*schema.Schema {
"cc_emails": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"name": {
Type: schema.TypeString,
Expand Down
1 change: 1 addition & 0 deletions avi/resource_avi_alertscriptconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func ResourceAlertScriptConfigSchema() map[string]*schema.Schema {
"action_script": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"name": {
Type: schema.TypeString,
Expand Down
1 change: 1 addition & 0 deletions avi/resource_avi_alertsyslogconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func ResourceAlertSyslogConfigSchema() map[string]*schema.Schema {
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"name": {
Type: schema.TypeString,
Expand Down
1 change: 1 addition & 0 deletions avi/resource_avi_alertsyslogconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestAVIAlertSyslogConfigBasic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccAVIAlertSyslogConfig,
//ImportState: false,
Check: resource.ComposeTestCheckFunc(
testAccCheckAVIAlertSyslogConfigExists("avi_alertsyslogconfig.testalertsyslogconfig"),
resource.TestCheckResourceAttr(
Expand Down
4 changes: 4 additions & 0 deletions avi/resource_avi_analyticsprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ func ResourceAnalyticsProfileSchema() map[string]*schema.Schema {
"client_log_config": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceClientLogConfigurationSchema(),
},
"client_log_streaming_config": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceClientLogStreamingConfigSchema(),
},
"conn_lossy_ooo_threshold": {
Expand Down Expand Up @@ -117,6 +119,7 @@ func ResourceAnalyticsProfileSchema() map[string]*schema.Schema {
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"disable_ondemand_metrics": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -375,6 +378,7 @@ func ResourceAnalyticsProfileSchema() map[string]*schema.Schema {
"sensitive_log_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceSensitiveLogProfileSchema(),
},
"sip_log_depth": {
Expand Down
5 changes: 5 additions & 0 deletions avi/resource_avi_applicationpersistenceprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,30 @@ func ResourceApplicationPersistenceProfileSchema() map[string]*schema.Schema {
"app_cookie_persistence_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceAppCookiePersistenceProfileSchema(),
},
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"hdr_persistence_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceHdrPersistenceProfileSchema(),
},
"http_cookie_persistence_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceHttpCookiePersistenceProfileSchema(),
},
"ip_persistence_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceIPPersistenceProfileSchema(),
},
"is_federated": {
Expand Down
8 changes: 8 additions & 0 deletions avi/resource_avi_applicationprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,34 @@ func ResourceApplicationProfileSchema() map[string]*schema.Schema {
"cloud_config_cksum": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"created_by": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"dns_service_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceDnsServiceApplicationProfileSchema(),
},
"dos_rl_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceDosRateLimitProfileSchema(),
},
"http_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceHTTPApplicationProfileSchema(),
},
"name": {
Expand All @@ -58,11 +64,13 @@ func ResourceApplicationProfileSchema() map[string]*schema.Schema {
"sip_service_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceSipServiceApplicationProfileSchema(),
},
"tcp_app_profile": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceTCPApplicationProfileSchema(),
},
"tenant_ref": {
Expand Down
5 changes: 5 additions & 0 deletions avi/resource_avi_authprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ func ResourceAuthProfileSchema() map[string]*schema.Schema {
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"http": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceAuthProfileHTTPClientParamsSchema(),
},
"ldap": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceLdapAuthSettingsSchema(),
},
"name": {
Expand All @@ -40,11 +43,13 @@ func ResourceAuthProfileSchema() map[string]*schema.Schema {
"saml": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceSamlSettingsSchema(),
},
"tacacs_plus": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceTacacsPlusAuthSettingsSchema(),
},
"tenant_ref": {
Expand Down
4 changes: 4 additions & 0 deletions avi/resource_avi_autoscalelaunchconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ func ResourceAutoScaleLaunchConfigSchema() map[string]*schema.Schema {
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"image_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"mesos": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceAutoScaleMesosSettingsSchema(),
},
"name": {
Expand All @@ -34,6 +37,7 @@ func ResourceAutoScaleLaunchConfigSchema() map[string]*schema.Schema {
"openstack": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: ResourceAutoScaleOpenStackSettingsSchema(),
},
"tenant_ref": {
Expand Down
Loading

0 comments on commit 4751796

Please sign in to comment.