mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Update vendored deps, including AWS SDK, openpgp, ftp, ...
This commit is contained in:
+70
-22
@@ -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
|
||||
@@ -164,7 +168,7 @@ func (a *API) fixStutterNames() {
|
||||
|
||||
for name, op := range a.Operations {
|
||||
newName := re.ReplaceAllString(name, "")
|
||||
if newName != name {
|
||||
if newName != name && len(newName) > 0 {
|
||||
delete(a.Operations, name)
|
||||
a.Operations[newName] = op
|
||||
}
|
||||
@@ -173,7 +177,7 @@ func (a *API) fixStutterNames() {
|
||||
|
||||
for k, s := range a.Shapes {
|
||||
newName := re.ReplaceAllString(k, "")
|
||||
if newName != s.ShapeName {
|
||||
if newName != s.ShapeName && len(newName) > 0 {
|
||||
s.Rename(newName)
|
||||
}
|
||||
}
|
||||
@@ -244,6 +248,50 @@ func (a *API) renameExportable() {
|
||||
}
|
||||
}
|
||||
|
||||
// renameCollidingFields will rename any fields that uses an SDK or Golang
|
||||
// specific name.
|
||||
func (a *API) renameCollidingFields() {
|
||||
for _, v := range a.Shapes {
|
||||
namesWithSet := map[string]struct{}{}
|
||||
for k, field := range v.MemberRefs {
|
||||
if strings.HasPrefix(k, "Set") {
|
||||
namesWithSet[k] = struct{}{}
|
||||
}
|
||||
|
||||
if collides(k) {
|
||||
renameCollidingField(k, v, field)
|
||||
}
|
||||
}
|
||||
|
||||
// checks if any field names collide with setters.
|
||||
for name := range namesWithSet {
|
||||
if field, ok := v.MemberRefs["Set"+name]; ok {
|
||||
renameCollidingField(name, v, field)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func renameCollidingField(name string, v *Shape, field *ShapeRef) {
|
||||
newName := name + "_"
|
||||
fmt.Printf("Shape %s's field %q renamed to %q\n", v.ShapeName, name, newName)
|
||||
delete(v.MemberRefs, name)
|
||||
v.MemberRefs[newName] = field
|
||||
}
|
||||
|
||||
// collides will return true if it is a name used by the SDK or Golang.
|
||||
func collides(name string) bool {
|
||||
switch name {
|
||||
case "String",
|
||||
"GoString",
|
||||
"Validate":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// createInputOutputShapes creates toplevel input/output shapes if they
|
||||
// have not been defined in the API. This normalizes all APIs to always
|
||||
// have an input and output structure in the signature.
|
||||
@@ -278,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user