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

service/s3: Use interfaces assertions instead of ValuesAtPath for S3 field lookups. #1401

Merged
merged 3 commits into from
Jul 18, 2017
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
6 changes: 6 additions & 0 deletions private/model/api/customization_passes.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ func s3Customizations(a *API) {
delete(s.MemberRefs, "ContentMD5")
}

for _, refName := range []string{"Bucket", "SSECustomerKey", "CopySourceSSECustomerKey"} {
if ref, ok := s.MemberRefs[refName]; ok {
ref.GenerateGetter = true
}
}

// Expires should be a string not time.Time since the format is not
// enforced by S3, and any value can be set to this field outside of the SDK.
if strings.HasSuffix(name, "Output") {
Expand Down
15 changes: 15 additions & 0 deletions private/model/api/shape.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type ShapeRef struct {
Deprecated bool `json:"deprecated"`

OrigShapeName string `json:"-"`

GenerateGetter bool
}

// ErrorInfo represents the error block of a shape's structure
Expand Down Expand Up @@ -580,6 +582,19 @@ func (s *{{ $builderShapeName }}) Set{{ $name }}(v {{ $context.GoStructValueType
return s
}

{{ if $elem.GenerateGetter -}}
func (s *{{ $builderShapeName }}) get{{ $name }}() (v {{ $context.GoStructValueType $name $elem }}) {
{{ if $elem.UseIndirection -}}
if s.{{ $name }} == nil {
return v
}
return *s.{{ $name }}
{{ else -}}
return s.{{ $name }}
{{ end -}}
}
{{- end }}

{{ end }}
{{ end }}
`))
Expand Down
Loading