-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
New Resource: aws_storagegateway_working_storage #5285
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall approved! I had some minor code suggestions but nothing I felt strongly about.
|
||
for _, disk := range output.Disks { | ||
if aws.StringValue(disk.DiskPath) == diskPath { | ||
matchingDisks = append(matchingDisks, disk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears finding more than 1 disk is an error? Perhaps refactor to single match and break when you find it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A disk path is a unique identifier on a system, e.g. /dev/sdb
return errors.New("multiple results found for query, try adjusting your search criteria") | ||
} | ||
|
||
disk := matchingDisks[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again do we foresee multiple matches being something that comes later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would create a separate pluralized data source (e.g. aws_storagegateway_local_disks
) in that case
return nil | ||
} | ||
|
||
found := false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick var found bool
would begin false... I'm okay either way :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go newcomers might be confused by variable type zero-value behavior -- explicit > implicit IMO since it doesn't cost any extra lines of code. 👍
} | ||
|
||
func decodeStorageGatewayWorkingStorageID(id string) (string, string, error) { | ||
// id = arn:aws:storagegateway:us-east-1:123456789012:gateway/sgw-12345678:pci-0000:03:00.0-scsi-0:0:0:0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remnant from development?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm showing these for future travelers since the logic might be seen as non-trivial
if err != nil { | ||
return "", "", idFormatErr | ||
} | ||
// gatewayARNAndDisk.Resource = gateway/sgw-12345678:pci-0000:03:00.0-scsi-0:0:0:0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
development remnant?
if len(resourceParts) != 2 { | ||
return "", "", idFormatErr | ||
} | ||
// resourceParts = ["gateway/sgw-12345678", "pci-0000:03:00.0-scsi-0:0:0:0"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remnant?
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
func TestDecodeStorageGatewayWorkingStorageID(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for unit tests!
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
// Storage Gateway API does not support removing working storages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no clue what this service is, I'm assuming we aren't leaving around costly infrastructure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct 😄 Storage Gateway caches, upload buffers, and working storages are all associated with a gateway and deleted when the gateway is deleted.
13729f9
to
fd739fb
Compare
Rebased on top of master to resolve conflicts, no surprises from CI, merging! |
This has been released in version 1.30.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Built on #5279
Reference #943
Changes proposed in this pull request:
aws_storagegateway_working_storage
Output from acceptance testing: