vendor: update all dependencies

* Update all dependencies
  * Remove all `[[constraint]]` from Gopkg.toml
  * Add in the minimum number of `[[override]]` to build
  * Remove go get of github.com/inconshreveable/mousetrap as it is vendored
  * Update docs with new policy on constraints
This commit is contained in:
Nick Craig-Wood 2018-05-02 17:09:45 +01:00
parent 21383877df
commit 6427029c4e
4902 changed files with 1443417 additions and 227283 deletions

View file

@ -488,16 +488,17 @@ func New(p client.ConfigProvider, cfgs ...*aws.Config) *{{ .StructName }} {
{{- else -}}
c := p.ClientConfig({{ EndpointsIDValue . }}, cfgs...)
{{- end }}
{{- if .Metadata.SigningName }}
if c.SigningNameDerived || len(c.SigningName) == 0{
c.SigningName = "{{ .Metadata.SigningName }}"
}
{{- end }}
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
}
// newClient creates, initializes and returns a new service client instance.
func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *{{ .StructName }} {
{{- if .Metadata.SigningName }}
if len(signingName) == 0 {
signingName = "{{ .Metadata.SigningName }}"
}
{{- end }}
svc := &{{ .StructName }}{
Client: client.New(
cfg,
@ -801,3 +802,52 @@ func (a *API) APIErrorsGoCode() string {
return strings.TrimSpace(buf.String())
}
// removeOperation removes an operation, its input/output shapes, as well as
// any references/shapes that are unique to this operation.
func (a *API) removeOperation(name string) {
fmt.Println("removing operation,", name)
op := a.Operations[name]
delete(a.Operations, name)
delete(a.Examples, name)
a.removeShape(op.InputRef.Shape)
a.removeShape(op.OutputRef.Shape)
}
// removeShape removes the given shape, and all form member's reference target
// shapes. Will also remove member reference targeted shapes if those shapes do
// not have any additional references.
func (a *API) removeShape(s *Shape) {
fmt.Println("removing shape,", s.ShapeName)
delete(a.Shapes, s.ShapeName)
for name, ref := range s.MemberRefs {
a.removeShapeRef(ref)
delete(s.MemberRefs, name)
}
for _, ref := range []*ShapeRef{&s.MemberRef, &s.KeyRef, &s.ValueRef} {
if ref.Shape == nil {
continue
}
a.removeShapeRef(ref)
*ref = ShapeRef{}
}
}
// removeShapeRef removes the shape reference from its target shape. If the
// reference was the last reference to the target shape, the shape will also be
// removed.
func (a *API) removeShapeRef(ref *ShapeRef) {
if ref.Shape == nil {
return
}
ref.Shape.removeRef(ref)
if len(ref.Shape.refs) == 0 {
a.removeShape(ref.Shape)
}
}

View file

@ -0,0 +1,28 @@
// +build codegen
package api
func (a *API) suppressEventStreams() {
const eventStreamMemberName = "EventStream"
for name, op := range a.Operations {
outbound := hasEventStream(op.InputRef.Shape)
inbound := hasEventStream(op.OutputRef.Shape)
if !(outbound || inbound) {
continue
}
a.removeOperation(name)
}
}
func hasEventStream(topShape *Shape) bool {
for _, ref := range topShape.MemberRefs {
if ref.Shape.IsEventStream {
return true
}
}
return false
}

View file

@ -0,0 +1,79 @@
// +build go1.6,codegen
package api
import (
"testing"
)
func TestSuppressEventStream(t *testing.T) {
cases := []struct {
API *API
Ops []string
Shapes []string
}{
{
API: &API{
Operations: map[string]*Operation{
"abc": {
InputRef: ShapeRef{
ShapeName: "abcRequest",
},
OutputRef: ShapeRef{
ShapeName: "abcResponse",
},
},
"eventStreamOp": {
InputRef: ShapeRef{
ShapeName: "eventStreamOpRequest",
},
OutputRef: ShapeRef{
ShapeName: "eventStreamOpResponse",
},
},
},
Shapes: map[string]*Shape{
"abcRequest": {},
"abcResponse": {},
"eventStreamOpRequest": {},
"eventStreamOpResponse": {
MemberRefs: map[string]*ShapeRef{
"eventStreamShape": {
ShapeName: "eventStreamShape",
},
},
},
"eventStreamShape": {
IsEventStream: true,
},
},
},
Ops: []string{"Abc"},
Shapes: []string{"AbcInput", "AbcOutput"},
},
}
for _, c := range cases {
c.API.Setup()
if e, a := c.Ops, c.API.OperationNames(); !stringsEqual(e, a) {
t.Errorf("expect %v ops, got %v", e, a)
}
if e, a := c.Shapes, c.API.ShapeNames(); !stringsEqual(e, a) {
t.Errorf("expect %v ops, got %v", e, a)
}
}
}
func stringsEqual(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i := 0; i < len(a); i++ {
if a[i] != b[i] {
return false
}
}
return true
}

View file

@ -9,21 +9,6 @@ import (
"path/filepath"
)
// Load takes a set of files for each filetype and returns an API pointer.
// The API will be initialized once all files have been loaded and parsed.
//
// Will panic if any failure opening the definition JSON files, or there
// are unrecognized exported names.
func Load(api, docs, paginators, waiters string) *API {
a := API{}
a.Attach(api)
a.Attach(docs)
a.Attach(paginators)
a.Attach(waiters)
a.Setup()
return &a
}
// Attach opens a file by name, and unmarshal its JSON data.
// Will proceed to setup the API if not already done so.
func (a *API) Attach(filename string) {
@ -62,6 +47,7 @@ func (a *API) Setup() {
a.renameCollidingFields()
a.updateTopLevelShapeReferences()
a.createInputOutputShapes()
a.suppressEventStreams()
a.customizationPasses()
if !a.NoRemoveUnusedShapes {

View file

@ -72,7 +72,7 @@ const op{{ .ExportedName }} = "{{ .Name }}"
// {{ .ExportedName }}Request generates a "aws/request.Request" representing the
// client's request for the {{ .ExportedName }} operation. The "output" return
// value will be populated with the request's response once the request complets
// value will be populated with the request's response once the request completes
// successfuly.
//
// Use "Send" method on the returned Request to send the API call to the service.

View file

@ -85,25 +85,29 @@ func (r *referenceResolver) resolveReference(ref *ShapeRef) {
return
}
if shape, ok := r.API.Shapes[ref.ShapeName]; ok {
if ref.JSONValue {
ref.ShapeName = "JSONValue"
r.API.Shapes[ref.ShapeName] = jsonvalueShape
}
ref.API = r.API // resolve reference back to API
ref.Shape = shape // resolve shape reference
if r.visited[ref] {
return
}
r.visited[ref] = true
shape.refs = append(shape.refs, ref) // register the ref
// resolve shape's references, if it has any
r.resolveShape(shape)
shape, ok := r.API.Shapes[ref.ShapeName]
if !ok {
panic(fmt.Sprintf("unable resolve reference, %s", ref.ShapeName))
return
}
if ref.JSONValue {
ref.ShapeName = "JSONValue"
r.API.Shapes[ref.ShapeName] = jsonvalueShape
}
ref.API = r.API // resolve reference back to API
ref.Shape = shape // resolve shape reference
if r.visited[ref] {
return
}
r.visited[ref] = true
shape.refs = append(shape.refs, ref) // register the ref
// resolve shape's references, if it has any
r.resolveShape(shape)
}
// resolveShape resolves a shape's Member Key Value, and nested member
@ -322,9 +326,9 @@ func (a *API) makeIOShape(name string) *Shape {
// removeUnusedShapes removes shapes from the API which are not referenced by any
// other shape in the API.
func (a *API) removeUnusedShapes() {
for n, s := range a.Shapes {
for _, s := range a.Shapes {
if len(s.refs) == 0 {
delete(a.Shapes, n)
a.removeShape(s)
}
}
}

View file

@ -55,9 +55,9 @@ type Shape struct {
ShapeName string
Documentation string
MemberRefs map[string]*ShapeRef `json:"members"`
MemberRef ShapeRef `json:"member"`
KeyRef ShapeRef `json:"key"`
ValueRef ShapeRef `json:"value"`
MemberRef ShapeRef `json:"member"` // List ref
KeyRef ShapeRef `json:"key"` // map key ref
ValueRef ShapeRef `json:"value"` // map value ref
Required []string
Payload string
Type string
@ -73,6 +73,8 @@ type Shape struct {
Min float64 // optional Minimum length (string, list) or value (number)
Max float64 // optional Maximum length (string, list) or value (number)
IsEventStream bool `json:"eventstream"`
refs []*ShapeRef // References to this shape
resolvePkg string // use this package in the goType() if present