Skip to content
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
2 changes: 1 addition & 1 deletion pkg/iac/adapters/terraform/google/storage/adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (a *adapter) adaptBucketResource(resourceBlock *terraform.Block) storage.Bu

if logBlock := resourceBlock.GetBlock("logging"); logBlock.IsNotNil() {
bucket.Logging.Metadata = logBlock.GetMetadata()
bucket.Logging.LogBucket = logBlock.GetAttribute("target_bucket").AsStringValueOrDefault("", logBlock)
bucket.Logging.LogBucket = logBlock.GetAttribute("log_bucket").AsStringValueOrDefault("", logBlock)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rethink the .AsStringValueOrDefault() approach? The reason I say it is because if it's not set the default will be the empty value "".

Would using a "known" placeholder be better than an empty value like ""? For instance, that would eliminate the issue where a value is mistakenly forgotten to be set vs. actually being empty due to a bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikpivkin I think we can handle this in a different PR, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. We will need to find a better solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - I created #9341 to track.

bucket.Logging.LogObjectPrefix = logBlock.GetAttribute("log_object_prefix").AsStringValueOrDefault("", logBlock)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/iac/adapters/terraform/google/storage/adapt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func Test_Adapt(t *testing.T) {
location = "US"

logging {
target_bucket = "access-logs-bucket"
log_bucket = "access-logs-bucket"
}

versioning {
Expand Down Expand Up @@ -188,7 +188,7 @@ func Test_Adapt(t *testing.T) {
location = "US"

logging {
target_bucket = "access-logs-bucket"
log_bucket = "access-logs-bucket"
log_object_prefix = "access-logs/"
}
}`,
Expand Down
Loading