From cc7bec3f709ab0842b5863d33c6ff2166b87addd Mon Sep 17 00:00:00 2001 From: Mateus Pimenta <1920261+matpimenta@users.noreply.github.com> Date: Thu, 20 Aug 2020 09:54:55 +0100 Subject: [PATCH] Changing formatVersion in VCLLoggingAttributes to be a *uint As some logging endpoints on go-fastly use uint and some *uint, and VCLLoggingAttributes needs to cater for both. The most generic and recommended way to express empty value is using nil instead of zero. For the Request objects that are still using uint, the provider will set the value to 0 (zero) when the VCLLoggingAttributes.formatVersion pointer is nil. This is compatible with the previous behaviour. Request objects using *uint which were failing before (as zero was being sent instead of nill) are now working again. --- fastly/base_fastly_service_v1.go | 4 ++-- ...block_fastly_service_v1_blobstoragelogging.go | 2 +- fastly/block_fastly_service_v1_httpslogging.go | 2 +- fastly/block_fastly_service_v1_logentries.go | 2 +- ...block_fastly_service_v1_logging_cloudfiles.go | 2 +- ..._fastly_service_v1_logging_cloudfiles_test.go | 2 +- .../block_fastly_service_v1_logging_datadog.go | 2 +- ...ock_fastly_service_v1_logging_datadog_test.go | 2 +- ...ock_fastly_service_v1_logging_digitalocean.go | 2 +- ...astly_service_v1_logging_digitalocean_test.go | 2 +- ...ck_fastly_service_v1_logging_elasticsearch.go | 2 +- fastly/block_fastly_service_v1_logging_ftp.go | 2 +- ...ock_fastly_service_v1_logging_googlepubsub.go | 2 +- fastly/block_fastly_service_v1_logging_heroku.go | 2 +- ...lock_fastly_service_v1_logging_heroku_test.go | 2 +- .../block_fastly_service_v1_logging_honeycomb.go | 2 +- ...k_fastly_service_v1_logging_honeycomb_test.go | 2 +- fastly/block_fastly_service_v1_logging_kafka.go | 2 +- fastly/block_fastly_service_v1_logging_loggly.go | 2 +- ...block_fastly_service_v1_logging_logshuttle.go | 2 +- ..._fastly_service_v1_logging_logshuttle_test.go | 2 +- .../block_fastly_service_v1_logging_newrelic.go | 2 +- .../block_fastly_service_v1_logging_openstack.go | 2 +- ...k_fastly_service_v1_logging_openstack_test.go | 2 +- fastly/block_fastly_service_v1_logging_scalyr.go | 2 +- fastly/block_fastly_service_v1_logging_sftp.go | 2 +- fastly/block_fastly_service_v1_s3logging.go | 2 +- fastly/block_fastly_service_v1_splunk.go | 2 +- fastly/block_fastly_service_v1_sumologic.go | 2 +- fastly/block_fastly_service_v1_syslog.go | 2 +- fastly/convert.go | 7 +++++++ fastly/convert_test.go | 9 +++++++++ fastly/resource_fastly_service_compute_test.go | 16 ++++++++-------- 33 files changed, 55 insertions(+), 39 deletions(-) diff --git a/fastly/base_fastly_service_v1.go b/fastly/base_fastly_service_v1.go index ce79ce16f..14e2b5234 100644 --- a/fastly/base_fastly_service_v1.go +++ b/fastly/base_fastly_service_v1.go @@ -74,7 +74,7 @@ func (h *DefaultServiceAttributeHandler) MustProcess(d *schema.ResourceData, ini type VCLLoggingAttributes struct { format string - formatVersion uint + formatVersion *uint placement string responseCondition string } @@ -89,7 +89,7 @@ func (h *DefaultServiceAttributeHandler) getVCLLoggingAttributes(data map[string vla.format = val.(string) } if val, ok := data["format_version"]; ok { - vla.formatVersion = uint(val.(int)) + vla.formatVersion = gofastly.Uint(uint(val.(int))) } if val, ok := data["placement"]; ok { vla.placement = val.(string) diff --git a/fastly/block_fastly_service_v1_blobstoragelogging.go b/fastly/block_fastly_service_v1_blobstoragelogging.go index 40ffa2b2c..94a7c82b5 100644 --- a/fastly/block_fastly_service_v1_blobstoragelogging.go +++ b/fastly/block_fastly_service_v1_blobstoragelogging.go @@ -89,7 +89,7 @@ func (h *BlobStorageLoggingServiceAttributeHandler) Process(d *schema.ResourceDa PublicKey: bslf["public_key"].(string), MessageType: bslf["message_type"].(string), Format: vla.format, - FormatVersion: vla.formatVersion, + FormatVersion: uintWithDefault(vla.formatVersion), Placement: vla.placement, ResponseCondition: vla.responseCondition, } diff --git a/fastly/block_fastly_service_v1_httpslogging.go b/fastly/block_fastly_service_v1_httpslogging.go index 9e0054c98..742df6372 100644 --- a/fastly/block_fastly_service_v1_httpslogging.go +++ b/fastly/block_fastly_service_v1_httpslogging.go @@ -310,7 +310,7 @@ func (h *HTTPSLoggingServiceAttributeHandler) buildCreate(httpsMap interface{}, TLSHostname: df["tls_hostname"].(string), MessageType: df["message_type"].(string), Format: vla.format, - FormatVersion: vla.formatVersion, + FormatVersion: uintWithDefault(vla.formatVersion), ResponseCondition: vla.responseCondition, Placement: vla.placement, } diff --git a/fastly/block_fastly_service_v1_logentries.go b/fastly/block_fastly_service_v1_logentries.go index 5f1689fda..759784ccc 100644 --- a/fastly/block_fastly_service_v1_logentries.go +++ b/fastly/block_fastly_service_v1_logentries.go @@ -68,7 +68,7 @@ func (h *LogentriesServiceAttributeHandler) Process(d *schema.ResourceData, late UseTLS: gofastly.CBool(slf["use_tls"].(bool)), Token: slf["token"].(string), Format: vla.format, - FormatVersion: vla.formatVersion, + FormatVersion: uintWithDefault(vla.formatVersion), Placement: vla.placement, ResponseCondition: vla.responseCondition, } diff --git a/fastly/block_fastly_service_v1_logging_cloudfiles.go b/fastly/block_fastly_service_v1_logging_cloudfiles.go index f7211e442..9b0fb62ba 100644 --- a/fastly/block_fastly_service_v1_logging_cloudfiles.go +++ b/fastly/block_fastly_service_v1_logging_cloudfiles.go @@ -176,7 +176,7 @@ func (h *CloudfilesServiceAttributeHandler) buildCreate(cloudfilesMap interface{ Period: gofastly.Uint(uint(df["period"].(int))), TimestampFormat: gofastly.NullString(df["timestamp_format"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_cloudfiles_test.go b/fastly/block_fastly_service_v1_logging_cloudfiles_test.go index 485385391..d7cf461e4 100644 --- a/fastly/block_fastly_service_v1_logging_cloudfiles_test.go +++ b/fastly/block_fastly_service_v1_logging_cloudfiles_test.go @@ -162,7 +162,7 @@ func TestAccFastlyServiceV1_logging_cloudfiles_basic(t *testing.T) { }) } -func TestAccFastlyServiceV1_logging_cloudfiles_basicCompute(t *testing.T) { +func TestAccFastlyServiceV1_logging_cloudfiles_basic_compute(t *testing.T) { var service gofastly.ServiceDetail name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domain := fmt.Sprintf("fastly-test.%s.com", name) diff --git a/fastly/block_fastly_service_v1_logging_datadog.go b/fastly/block_fastly_service_v1_logging_datadog.go index 472273ebd..1d612cc7a 100644 --- a/fastly/block_fastly_service_v1_logging_datadog.go +++ b/fastly/block_fastly_service_v1_logging_datadog.go @@ -207,7 +207,7 @@ func (h *DatadogServiceAttributeHandler) buildCreate(datadogMap interface{}, ser Token: gofastly.NullString(df["token"].(string)), Region: gofastly.NullString(df["region"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_datadog_test.go b/fastly/block_fastly_service_v1_logging_datadog_test.go index b59269f11..baafe4f4b 100644 --- a/fastly/block_fastly_service_v1_logging_datadog_test.go +++ b/fastly/block_fastly_service_v1_logging_datadog_test.go @@ -192,7 +192,7 @@ func TestAccFastlyServiceV1_logging_datadog_basic(t *testing.T) { }) } -func TestAccFastlyServiceV1_logging_datadog_basicCompute(t *testing.T) { +func TestAccFastlyServiceV1_logging_datadog_basic_compute(t *testing.T) { var service gofastly.ServiceDetail name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domain := fmt.Sprintf("fastly-test.%s.com", name) diff --git a/fastly/block_fastly_service_v1_logging_digitalocean.go b/fastly/block_fastly_service_v1_logging_digitalocean.go index fe472703a..2caab70a8 100644 --- a/fastly/block_fastly_service_v1_logging_digitalocean.go +++ b/fastly/block_fastly_service_v1_logging_digitalocean.go @@ -177,7 +177,7 @@ func (h *DigitalOceanServiceAttributeHandler) buildCreate(digitaloceanMap interf TimestampFormat: gofastly.NullString(df["timestamp_format"].(string)), MessageType: gofastly.NullString(df["message_type"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_digitalocean_test.go b/fastly/block_fastly_service_v1_logging_digitalocean_test.go index 42a743284..5efff8396 100644 --- a/fastly/block_fastly_service_v1_logging_digitalocean_test.go +++ b/fastly/block_fastly_service_v1_logging_digitalocean_test.go @@ -162,7 +162,7 @@ func TestAccFastlyServiceV1_logging_digitalocean_basic(t *testing.T) { }) } -func TestAccFastlyServiceV1_logging_digitalocean_basicCompute(t *testing.T) { +func TestAccFastlyServiceV1_logging_digitalocean_basic_compute(t *testing.T) { var service gofastly.ServiceDetail name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domain := fmt.Sprintf("fastly-test.%s.com", name) diff --git a/fastly/block_fastly_service_v1_logging_elasticsearch.go b/fastly/block_fastly_service_v1_logging_elasticsearch.go index 73686e645..d5ae8d244 100644 --- a/fastly/block_fastly_service_v1_logging_elasticsearch.go +++ b/fastly/block_fastly_service_v1_logging_elasticsearch.go @@ -285,7 +285,7 @@ func (h *ElasticSearchServiceAttributeHandler) buildCreate(elasticsearchMap inte TLSClientKey: gofastly.NullString(df["tls_client_key"].(string)), TLSHostname: gofastly.NullString(df["tls_hostname"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_ftp.go b/fastly/block_fastly_service_v1_logging_ftp.go index cd61224b8..26cae477e 100644 --- a/fastly/block_fastly_service_v1_logging_ftp.go +++ b/fastly/block_fastly_service_v1_logging_ftp.go @@ -291,7 +291,7 @@ func (h *FTPServiceAttributeHandler) buildCreate(ftpMap interface{}, serviceID s TimestampFormat: df["timestamp_format"].(string), MessageType: df["message_type"].(string), Format: vla.format, - FormatVersion: vla.formatVersion, + FormatVersion: uintWithDefault(vla.formatVersion), Placement: vla.placement, ResponseCondition: vla.responseCondition, } diff --git a/fastly/block_fastly_service_v1_logging_googlepubsub.go b/fastly/block_fastly_service_v1_logging_googlepubsub.go index 5e481c476..4c1b3de07 100644 --- a/fastly/block_fastly_service_v1_logging_googlepubsub.go +++ b/fastly/block_fastly_service_v1_logging_googlepubsub.go @@ -221,7 +221,7 @@ func (h *GooglePubSubServiceAttributeHandler) buildCreate(googlepubsubMap interf ProjectID: fastly.NullString(df["project_id"].(string)), Topic: fastly.NullString(df["topic"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_heroku.go b/fastly/block_fastly_service_v1_logging_heroku.go index 7abf8973d..04b61c748 100644 --- a/fastly/block_fastly_service_v1_logging_heroku.go +++ b/fastly/block_fastly_service_v1_logging_heroku.go @@ -146,7 +146,7 @@ func (h *HerokuServiceAttributeHandler) buildCreate(herokuMap interface{}, servi Token: gofastly.NullString(df["token"].(string)), URL: gofastly.NullString(df["url"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_heroku_test.go b/fastly/block_fastly_service_v1_logging_heroku_test.go index f34cd3561..32210fe5e 100644 --- a/fastly/block_fastly_service_v1_logging_heroku_test.go +++ b/fastly/block_fastly_service_v1_logging_heroku_test.go @@ -118,7 +118,7 @@ func TestAccFastlyServiceV1_logging_heroku_basic(t *testing.T) { }) } -func TestAccFastlyServiceV1_logging_heroku_basicCompute(t *testing.T) { +func TestAccFastlyServiceV1_logging_heroku_basic_compute(t *testing.T) { var service gofastly.ServiceDetail name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domain := fmt.Sprintf("fastly-test.%s.com", name) diff --git a/fastly/block_fastly_service_v1_logging_honeycomb.go b/fastly/block_fastly_service_v1_logging_honeycomb.go index 8b117213f..d869c89bc 100644 --- a/fastly/block_fastly_service_v1_logging_honeycomb.go +++ b/fastly/block_fastly_service_v1_logging_honeycomb.go @@ -146,7 +146,7 @@ func (h *HoneycombServiceAttributeHandler) buildCreate(honeycombMap interface{}, Token: gofastly.NullString(df["token"].(string)), Dataset: gofastly.NullString(df["dataset"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_honeycomb_test.go b/fastly/block_fastly_service_v1_logging_honeycomb_test.go index 98fc65121..637085399 100644 --- a/fastly/block_fastly_service_v1_logging_honeycomb_test.go +++ b/fastly/block_fastly_service_v1_logging_honeycomb_test.go @@ -151,7 +151,7 @@ func TestAccFastlyServiceV1_logging_honeycomb_basic(t *testing.T) { }) } -func TestAccFastlyServiceV1_logging_honeycomb_basicCompute(t *testing.T) { +func TestAccFastlyServiceV1_logging_honeycomb_basic_compute(t *testing.T) { var service gofastly.ServiceDetail name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domain := fmt.Sprintf("fastly-test.%s.com", name) diff --git a/fastly/block_fastly_service_v1_logging_kafka.go b/fastly/block_fastly_service_v1_logging_kafka.go index 3048bc40a..e1939ab65 100644 --- a/fastly/block_fastly_service_v1_logging_kafka.go +++ b/fastly/block_fastly_service_v1_logging_kafka.go @@ -284,7 +284,7 @@ func (h *KafkaServiceAttributeHandler) buildCreate(kafkaMap interface{}, service TLSClientKey: fastly.NullString(df["tls_client_key"].(string)), TLSHostname: fastly.NullString(df["tls_hostname"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_loggly.go b/fastly/block_fastly_service_v1_logging_loggly.go index 56d2c42d9..f7dd81d38 100644 --- a/fastly/block_fastly_service_v1_logging_loggly.go +++ b/fastly/block_fastly_service_v1_logging_loggly.go @@ -144,7 +144,7 @@ func (h *LogglyServiceAttributeHandler) buildCreate(logglyMap interface{}, servi Name: gofastly.NullString(df["name"].(string)), Token: gofastly.NullString(df["token"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_logshuttle.go b/fastly/block_fastly_service_v1_logging_logshuttle.go index 4577c917a..2d9f10229 100644 --- a/fastly/block_fastly_service_v1_logging_logshuttle.go +++ b/fastly/block_fastly_service_v1_logging_logshuttle.go @@ -146,7 +146,7 @@ func (h *LogshuttleServiceAttributeHandler) buildCreate(logshuttleMap interface{ Token: gofastly.NullString(df["token"].(string)), URL: gofastly.NullString(df["url"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_logshuttle_test.go b/fastly/block_fastly_service_v1_logging_logshuttle_test.go index d013f610f..b8b3f0f40 100644 --- a/fastly/block_fastly_service_v1_logging_logshuttle_test.go +++ b/fastly/block_fastly_service_v1_logging_logshuttle_test.go @@ -118,7 +118,7 @@ func TestAccFastlyServiceV1_logging_logshuttle_basic(t *testing.T) { }) } -func TestAccFastlyServiceV1_logging_logshuttle_basicCompute(t *testing.T) { +func TestAccFastlyServiceV1_logging_logshuttle_basic_compute(t *testing.T) { var service gofastly.ServiceDetail name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domain := fmt.Sprintf("fastly-test.%s.com", name) diff --git a/fastly/block_fastly_service_v1_logging_newrelic.go b/fastly/block_fastly_service_v1_logging_newrelic.go index 75b548e27..c6767fd19 100644 --- a/fastly/block_fastly_service_v1_logging_newrelic.go +++ b/fastly/block_fastly_service_v1_logging_newrelic.go @@ -142,7 +142,7 @@ func (h *NewRelicServiceAttributeHandler) buildCreate(newrelicMap interface{}, s Name: gofastly.NullString(df["name"].(string)), Token: gofastly.NullString(df["token"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_openstack.go b/fastly/block_fastly_service_v1_logging_openstack.go index 9f13d5aed..dbc61aa64 100644 --- a/fastly/block_fastly_service_v1_logging_openstack.go +++ b/fastly/block_fastly_service_v1_logging_openstack.go @@ -177,7 +177,7 @@ func (h *OpenstackServiceAttributeHandler) buildCreate(openstackMap interface{}, Period: gofastly.Uint(uint(df["period"].(int))), TimestampFormat: gofastly.NullString(df["timestamp_format"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_openstack_test.go b/fastly/block_fastly_service_v1_logging_openstack_test.go index b339b7448..554f2bc8a 100644 --- a/fastly/block_fastly_service_v1_logging_openstack_test.go +++ b/fastly/block_fastly_service_v1_logging_openstack_test.go @@ -161,7 +161,7 @@ func TestAccFastlyServiceV1_logging_openstack_basic(t *testing.T) { }) } -func TestAccFastlyServiceV1_logging_openstack_basicCompute(t *testing.T) { +func TestAccFastlyServiceV1_logging_openstack_basic_compute(t *testing.T) { var service gofastly.ServiceDetail name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domain := fmt.Sprintf("fastly-test.%s.com", name) diff --git a/fastly/block_fastly_service_v1_logging_scalyr.go b/fastly/block_fastly_service_v1_logging_scalyr.go index eb75ac757..ca3c11974 100644 --- a/fastly/block_fastly_service_v1_logging_scalyr.go +++ b/fastly/block_fastly_service_v1_logging_scalyr.go @@ -205,7 +205,7 @@ func (h *ScalyrServiceAttributeHandler) buildCreate(scalyrMap interface{}, servi Region: fastly.NullString(df["region"].(string)), Token: fastly.NullString(df["token"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_logging_sftp.go b/fastly/block_fastly_service_v1_logging_sftp.go index 82f33ac9b..59ce9a6ef 100644 --- a/fastly/block_fastly_service_v1_logging_sftp.go +++ b/fastly/block_fastly_service_v1_logging_sftp.go @@ -316,7 +316,7 @@ func (h *SFTPServiceAttributeHandler) buildCreate(sftpMap interface{}, serviceID TimestampFormat: gofastly.NullString(df["timestamp_format"].(string)), MessageType: gofastly.NullString(df["message_type"].(string)), Format: gofastly.NullString(vla.format), - FormatVersion: gofastly.Uint(vla.formatVersion), + FormatVersion: vla.formatVersion, Placement: gofastly.NullString(vla.placement), ResponseCondition: gofastly.NullString(vla.responseCondition), } diff --git a/fastly/block_fastly_service_v1_s3logging.go b/fastly/block_fastly_service_v1_s3logging.go index 4c6089014..8fc98b113 100644 --- a/fastly/block_fastly_service_v1_s3logging.go +++ b/fastly/block_fastly_service_v1_s3logging.go @@ -313,7 +313,7 @@ func (h *S3LoggingServiceAttributeHandler) buildCreate(s3Map interface{}, servic PublicKey: df["public_key"].(string), ServerSideEncryptionKMSKeyID: df["server_side_encryption_kms_key_id"].(string), Format: vla.format, - FormatVersion: vla.formatVersion, + FormatVersion: uintWithDefault(vla.formatVersion), ResponseCondition: vla.responseCondition, Placement: vla.placement, } diff --git a/fastly/block_fastly_service_v1_splunk.go b/fastly/block_fastly_service_v1_splunk.go index 3bc8dbe4f..06f924bc8 100644 --- a/fastly/block_fastly_service_v1_splunk.go +++ b/fastly/block_fastly_service_v1_splunk.go @@ -84,7 +84,7 @@ func (h *SplunkServiceAttributeHandler) Process(d *schema.ResourceData, latestVe TLSHostname: sf["tls_hostname"].(string), TLSCACert: sf["tls_ca_cert"].(string), Format: vla.format, - FormatVersion: vla.formatVersion, + FormatVersion: uintWithDefault(vla.formatVersion), ResponseCondition: vla.responseCondition, Placement: vla.placement, } diff --git a/fastly/block_fastly_service_v1_sumologic.go b/fastly/block_fastly_service_v1_sumologic.go index d65763dfb..d7195e719 100644 --- a/fastly/block_fastly_service_v1_sumologic.go +++ b/fastly/block_fastly_service_v1_sumologic.go @@ -67,7 +67,7 @@ func (h *SumologicServiceAttributeHandler) Process(d *schema.ResourceData, lates URL: sf["url"].(string), MessageType: sf["message_type"].(string), Format: vla.format, - FormatVersion: int(vla.formatVersion), + FormatVersion: int(uintWithDefault(vla.formatVersion)), ResponseCondition: vla.responseCondition, Placement: vla.placement, } diff --git a/fastly/block_fastly_service_v1_syslog.go b/fastly/block_fastly_service_v1_syslog.go index bdb7ec15e..36a22baaa 100644 --- a/fastly/block_fastly_service_v1_syslog.go +++ b/fastly/block_fastly_service_v1_syslog.go @@ -74,7 +74,7 @@ func (h *SyslogServiceAttributeHandler) Process(d *schema.ResourceData, latestVe TLSClientKey: slf["tls_client_key"].(string), MessageType: slf["message_type"].(string), Format: vla.format, - FormatVersion: vla.formatVersion, + FormatVersion: uintWithDefault(vla.formatVersion), ResponseCondition: vla.responseCondition, Placement: vla.placement, } diff --git a/fastly/convert.go b/fastly/convert.go index 45c1750a9..fb0ca9c2f 100644 --- a/fastly/convert.go +++ b/fastly/convert.go @@ -14,3 +14,10 @@ func intToPtr(i int) *int { func boolToPtr(i bool) *bool { return &i } + +func uintWithDefault(int *uint) uint { + if int == nil { + return 0 + } + return *int +} diff --git a/fastly/convert_test.go b/fastly/convert_test.go index a8b89a8a7..5291e2c4a 100644 --- a/fastly/convert_test.go +++ b/fastly/convert_test.go @@ -20,3 +20,12 @@ func TestBoolPtr(t *testing.T) { v := true assert.Equal(t, v, *boolToPtr(v)) } + +func TestDefaultUintToZero(t *testing.T) { + assert.Equal(t, uint(0), uintWithDefault(nil)) +} + +func TestDefaultUint(t *testing.T) { + v := uint(10) + assert.Equal(t, v, uintWithDefault(&v)) +} diff --git a/fastly/resource_fastly_service_compute_test.go b/fastly/resource_fastly_service_compute_test.go index 0bd048070..9c38e3e73 100644 --- a/fastly/resource_fastly_service_compute_test.go +++ b/fastly/resource_fastly_service_compute_test.go @@ -88,7 +88,7 @@ func TestResourceFastlyFlattenBackendCompute(t *testing.T) { } } -func TestAccFastlyServiceCompute1_basic(t *testing.T) { +func TestAccFastlyServiceCompute_basic(t *testing.T) { var service gofastly.ServiceDetail name := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domainName1 := fmt.Sprintf("fastly-test1.tf-%s.com", acctest.RandString(10)) @@ -96,10 +96,10 @@ func TestAccFastlyServiceCompute1_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testAccCheckServiceComputeV1Destroy, + CheckDestroy: testAccCheckServiceComputeDestroy, Steps: []resource.TestStep{ { - Config: testAccServiceComputeV1Config(name, domainName1), + Config: testAccServiceComputeConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( testAccCheckServiceV1Exists("fastly_service_compute.foo", &service), resource.TestCheckResourceAttr( @@ -122,7 +122,7 @@ func TestAccFastlyServiceCompute1_basic(t *testing.T) { }) } -func testAccCheckServiceComputeV1Destroy(s *terraform.State) error { +func testAccCheckServiceComputeDestroy(s *terraform.State) error { for _, rs := range s.RootModule().Resources { if rs.Type != "fastly_service_compute" { continue @@ -144,7 +144,7 @@ func testAccCheckServiceComputeV1Destroy(s *terraform.State) error { return nil } -func TestAccFastlyServiceComputeV1_import(t *testing.T) { +func TestAccFastlyServiceCompute_import(t *testing.T) { var service gofastly.ServiceDetail resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -152,7 +152,7 @@ func TestAccFastlyServiceComputeV1_import(t *testing.T) { CheckDestroy: testAccCheckServiceV1Destroy, Steps: []resource.TestStep{ { - Config: testAccServiceComputeV1ImportConfig(), + Config: testAccServiceComputeImportConfig(), Check: resource.ComposeTestCheckFunc( testAccCheckServiceV1Exists("fastly_service_compute.foo", &service), ), @@ -169,7 +169,7 @@ func TestAccFastlyServiceComputeV1_import(t *testing.T) { } -func testAccServiceComputeV1Config(name, domain string) string { +func testAccServiceComputeConfig(name, domain string) string { return fmt.Sprintf(` resource "fastly_service_compute" "foo" { name = "%s" @@ -190,7 +190,7 @@ resource "fastly_service_compute" "foo" { }`, name, domain) } -func testAccServiceComputeV1ImportConfig() string { +func testAccServiceComputeImportConfig() string { return fmt.Sprintf(` resource "fastly_service_compute" "foo" { name = "tf-test-%s"