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

Add support for file_max_bytes configuration for azure logging endpoint #398

Merged
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
1 change: 1 addition & 0 deletions docs/resources/service_compute.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ Required:

Optional:

- **file_max_bytes** (Number) Maximum size of an uploaded log file, if non-zero.
- **gzip_level** (Number) Level of Gzip compression from `0-9`. `0` means no compression. `1` is the fastest and the least compressed version, `9` is the slowest and the most compressed version. Default `0`
- **message_type** (String) How the message should be formatted. Can be either `classic`, `loggly`, `logplex` or `blank`. Default `classic`
- **path** (String) The path to upload logs to. Must end with a trailing slash. If this field is left empty, the files will be saved in the container's root path
Expand Down
1 change: 1 addition & 0 deletions docs/resources/service_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ Required:

Optional:

- **file_max_bytes** (Number) Maximum size of an uploaded log file, if non-zero.
- **format** (String) Apache-style string or VCL variables to use for log formatting (default: `%h %l %u %t "%r" %>s %b`)
- **format_version** (Number) The version of the custom logging format used for the configured endpoint. Can be either 1 or 2. (default: 2)
- **gzip_level** (Number) Level of Gzip compression from `0-9`. `0` means no compression. `1` is the fastest and the least compressed version, `9` is the slowest and the most compressed version. Default `0`
Expand Down
10 changes: 10 additions & 0 deletions fastly/block_fastly_service_v1_blobstoragelogging.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (h *BlobStorageLoggingServiceAttributeHandler) Process(d *schema.ResourceDa
FormatVersion: uintOrDefault(vla.formatVersion),
Placement: vla.placement,
ResponseCondition: vla.responseCondition,
FileMaxBytes: uint(resource["file_max_bytes"].(int)),
}

log.Printf("[DEBUG] Blob Storage logging create opts: %#v", opts)
Expand Down Expand Up @@ -175,6 +176,9 @@ func (h *BlobStorageLoggingServiceAttributeHandler) Process(d *schema.ResourceDa
if v, ok := modified["response_condition"]; ok {
opts.ResponseCondition = gofastly.String(v.(string))
}
if v, ok := modified["file_max_bytes"]; ok {
opts.FileMaxBytes = gofastly.Uint(uint(v.(int)))
}

log.Printf("[DEBUG] Update Blob Storage Opts: %#v", opts)
_, err := conn.UpdateBlobStorage(&opts)
Expand Down Expand Up @@ -272,6 +276,11 @@ func (h *BlobStorageLoggingServiceAttributeHandler) Register(s *schema.Resource)
Description: "How the message should be formatted. Can be either `classic`, `loggly`, `logplex` or `blank`. Default `classic`",
ValidateDiagFunc: validateLoggingMessageType(),
},
"file_max_bytes": {
Type: schema.TypeInt,
Optional: true,
Description: "Maximum size of an uploaded log file, if non-zero.",
},
}

if h.GetServiceMetadata().serviceType == ServiceTypeVCL {
Expand Down Expand Up @@ -331,6 +340,7 @@ func flattenBlobStorages(blobStorageList []*gofastly.BlobStorage) []map[string]i
"message_type": bs.MessageType,
"placement": bs.Placement,
"response_condition": bs.ResponseCondition,
"file_max_bytes": bs.FileMaxBytes,
}

// prune any empty values that come from the default string value in structs
Expand Down
10 changes: 10 additions & 0 deletions fastly/block_fastly_service_v1_blobstoragelogging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestResourceFastlyFlattenBlobStorage(t *testing.T) {
MessageType: "classic",
Placement: "waf_debug",
ResponseCondition: "error_response",
FileMaxBytes: 1048576,
},
},
local: []map[string]interface{}{
Expand All @@ -52,6 +53,7 @@ func TestResourceFastlyFlattenBlobStorage(t *testing.T) {
"message_type": "classic",
"placement": "waf_debug",
"response_condition": "error_response",
"file_max_bytes": uint(1048576),
},
},
},
Expand Down Expand Up @@ -84,6 +86,7 @@ func TestAccFastlyServiceV1_blobstoragelogging_basic(t *testing.T) {
MessageType: "blank",
Placement: "waf_debug",
ResponseCondition: "error_response_5XX",
FileMaxBytes: 1048576,
}

blobStorageLogOneUpdated := gofastly.BlobStorage{
Expand All @@ -101,6 +104,7 @@ func TestAccFastlyServiceV1_blobstoragelogging_basic(t *testing.T) {
MessageType: "blank",
Placement: "waf_debug",
ResponseCondition: "error_response_5XX",
FileMaxBytes: 1048576,
}

blobStorageLogTwo := gofastly.BlobStorage{
Expand All @@ -118,6 +122,7 @@ func TestAccFastlyServiceV1_blobstoragelogging_basic(t *testing.T) {
MessageType: "blank",
Placement: "waf_debug",
ResponseCondition: "ok_response_2XX",
FileMaxBytes: 2097152,
}

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -167,6 +172,7 @@ func TestAccFastlyServiceV1_blobstoragelogging_basic_compute(t *testing.T) {
GzipLevel: 9,
PublicKey: pgpPublicKey(t),
MessageType: "blank",
FileMaxBytes: 1048576,
}

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -360,6 +366,7 @@ resource "fastly_service_v1" "foo" {
message_type = "blank"
placement = "waf_debug"
response_condition = "error_response_5XX"
file_max_bytes = 1048576
}

force_destroy = true
Expand Down Expand Up @@ -394,6 +401,7 @@ resource "fastly_service_compute" "foo" {
gzip_level = 9
public_key = file("test_fixtures/fastly_test_publickey")
message_type = "blank"
file_max_bytes = 1048576
}

package {
Expand Down Expand Up @@ -452,6 +460,7 @@ resource "fastly_service_v1" "foo" {
message_type = "blank"
placement = "waf_debug"
response_condition = "error_response_5XX"
file_max_bytes = 1048576
}

blobstoragelogging {
Expand All @@ -469,6 +478,7 @@ resource "fastly_service_v1" "foo" {
message_type = "blank"
placement = "waf_debug"
response_condition = "ok_response_2XX"
file_max_bytes = 2097152
}

force_destroy = true
Expand Down