Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing formatVersion in VCLLoggingAttributes to be a *uint #307

Merged
merged 1 commit into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fastly/base_fastly_service_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_blobstoragelogging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: uintOrDefault(vla.formatVersion),
Placement: vla.placement,
ResponseCondition: vla.responseCondition,
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_httpslogging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: uintOrDefault(vla.formatVersion),
ResponseCondition: vla.responseCondition,
Placement: vla.placement,
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logentries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: uintOrDefault(vla.formatVersion),
Placement: vla.placement,
ResponseCondition: vla.responseCondition,
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_cloudfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_cloudfiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_datadog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: uintOrDefault(vla.formatVersion),
Placement: vla.placement,
ResponseCondition: vla.responseCondition,
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_googlepubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_heroku.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_heroku_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_honeycomb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_honeycomb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_loggly.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_logshuttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_logshuttle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_newrelic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_openstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_scalyr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_logging_sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_s3logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: uintOrDefault(vla.formatVersion),
ResponseCondition: vla.responseCondition,
Placement: vla.placement,
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_splunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: uintOrDefault(vla.formatVersion),
ResponseCondition: vla.responseCondition,
Placement: vla.placement,
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_sumologic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(uintOrDefault(vla.formatVersion)),
ResponseCondition: vla.responseCondition,
Placement: vla.placement,
}
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_v1_syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: uintOrDefault(vla.formatVersion),
ResponseCondition: vla.responseCondition,
Placement: vla.placement,
}
Expand Down
7 changes: 7 additions & 0 deletions fastly/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ func intToPtr(i int) *int {
func boolToPtr(i bool) *bool {
return &i
}

func uintOrDefault(int *uint) uint {
if int == nil {
return 0
}
return *int
}
9 changes: 9 additions & 0 deletions fastly/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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), uintOrDefault(nil))
}

func TestDefaultUint(t *testing.T) {
v := uint(10)
assert.Equal(t, v, uintOrDefault(&v))
}
16 changes: 8 additions & 8 deletions fastly/resource_fastly_service_compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ 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))

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(
Expand All @@ -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
Expand All @@ -144,15 +144,15 @@ 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) },
Providers: testAccProviders,
CheckDestroy: testAccCheckServiceV1Destroy,
Steps: []resource.TestStep{
{
Config: testAccServiceComputeV1ImportConfig(),
Config: testAccServiceComputeImportConfig(),
Check: resource.ComposeTestCheckFunc(
testAccCheckServiceV1Exists("fastly_service_compute.foo", &service),
),
Expand All @@ -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"
Expand All @@ -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"
Expand Down