Skip to content

Commit

Permalink
fix original input being modified with s3control ARN operations (#3595)
Browse files Browse the repository at this point in the history
* modifies customization to update a copy of input shape when backfilling bucket, account id for s3 control ARNs

* generated s3, s3 control clients

* adds a return statement in case of error

* add changelog pending entry
  • Loading branch information
skotambkar committed Oct 13, 2020
1 parent 36f57c5 commit 776f18c
Show file tree
Hide file tree
Showing 8 changed files with 745 additions and 368 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
### SDK Enhancements

### SDK Bugs
* `s3control`: Fixes bug in SDK that caused input for certain s3control operation to be modified, when using ARNs. ([#3595](https://github.com/aws/aws-sdk-go/pull/3595))
* Fixes [#3583](https://github.com/aws/aws-sdk-go/issues/3583).

23 changes: 15 additions & 8 deletions private/model/api/endpoint_arn.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ const endpointARNShapeTmplDef = `
// updateArnableField updates the value of the input field that
// takes an ARN as an input. This method is useful to backfill
// the parsed resource name from ARN into the input member.
func (s *{{ $.ShapeName }}) updateArnableField(v string) error {
// the parsed resource name from ARN into the input member.
// It returns a pointer to a modified copy of input and an error.
// Note that original input is not modified.
func (s {{ $.ShapeName }}) updateArnableField(v string) (interface{}, error) {
if s.{{ $name }} == nil {
return fmt.Errorf("member {{ $name }} is nil")
return nil, fmt.Errorf("member {{ $name }} is nil")
}
s.{{ $name }} = aws.String(v)
return nil
return &s, nil
}
{{ end -}}
{{ end }}
Expand Down Expand Up @@ -74,13 +76,18 @@ const accountIDWithARNShapeTmplDef = `
{{ range $_, $name := $.MemberNames -}}
{{ $elem := index $.MemberRefs $name -}}
{{ if $elem.AccountIDMemberWithARN -}}
func (s *{{ $.ShapeName }}) updateAccountID(accountId string) error {
// updateAccountID returns a pointer to a modified copy of input,
// if account id is not provided, we update the account id in modified input
// if account id is provided, but doesn't match with the one in ARN, we throw an error
// if account id is not updated, we return nil. Note that original input is not modified.
func (s {{ $.ShapeName }}) updateAccountID(accountId string) (interface{}, error) {
if s.{{ $name }} == nil {
s.{{ $name }} = aws.String(accountId)
s.{{ $name }} = aws.String(accountId)
return &s, nil
} else if *s.{{ $name }} != accountId {
return fmt.Errorf("Account ID mismatch, the Account ID cannot be specified in an ARN and in the accountId field")
return &s, fmt.Errorf("Account ID mismatch, the Account ID cannot be specified in an ARN and in the accountId field")
}
return nil
return nil, nil
}
{{ end -}}
{{ end }}
Expand Down
Loading

0 comments on commit 776f18c

Please sign in to comment.