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:
+107
-19
@@ -10,10 +10,10 @@ import (
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/template"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// An API defines a service API's definition. and logic to serialize the definition.
|
||||
@@ -94,23 +94,53 @@ func (a *API) InterfacePackageName() string {
|
||||
return a.PackageName() + "iface"
|
||||
}
|
||||
|
||||
var nameRegex = regexp.MustCompile(`^Amazon|AWS\s*|\(.*|\s+|\W+`)
|
||||
var stripServiceNamePrefixes = []string{
|
||||
"Amazon",
|
||||
"AWS",
|
||||
}
|
||||
|
||||
// StructName returns the struct name for a given API.
|
||||
func (a *API) StructName() string {
|
||||
if a.name == "" {
|
||||
name := a.Metadata.ServiceAbbreviation
|
||||
if name == "" {
|
||||
name = a.Metadata.ServiceFullName
|
||||
}
|
||||
if len(a.name) != 0 {
|
||||
return a.name
|
||||
}
|
||||
|
||||
name = nameRegex.ReplaceAllString(name, "")
|
||||
name := a.Metadata.ServiceAbbreviation
|
||||
if len(name) == 0 {
|
||||
name = a.Metadata.ServiceFullName
|
||||
}
|
||||
|
||||
a.name = name
|
||||
if name, ok := serviceAliases[strings.ToLower(name)]; ok {
|
||||
a.name = name
|
||||
name = strings.TrimSpace(name)
|
||||
|
||||
// Strip out prefix names not reflected in service client symbol names.
|
||||
for _, prefix := range stripServiceNamePrefixes {
|
||||
if strings.HasPrefix(name, prefix) {
|
||||
name = name[len(prefix):]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Replace all Non-letter/number values with space
|
||||
runes := []rune(name)
|
||||
for i := 0; i < len(runes); i++ {
|
||||
if r := runes[i]; !(unicode.IsNumber(r) || unicode.IsLetter(r)) {
|
||||
runes[i] = ' '
|
||||
}
|
||||
}
|
||||
name = string(runes)
|
||||
|
||||
// Title case name so its readable as a symbol.
|
||||
name = strings.Title(name)
|
||||
|
||||
// Strip out spaces.
|
||||
name = strings.Replace(name, " ", "", -1)
|
||||
|
||||
// Swap out for alias name if one is defined.
|
||||
if alias, ok := serviceAliases[strings.ToLower(name)]; ok {
|
||||
name = alias
|
||||
}
|
||||
|
||||
a.name = name
|
||||
return a.name
|
||||
}
|
||||
|
||||
@@ -307,6 +337,12 @@ var noCrossLinkServices = map[string]struct{}{
|
||||
"swf": {},
|
||||
}
|
||||
|
||||
// HasCrosslinks will return whether or not a service has crosslinking .
|
||||
func HasCrosslinks(service string) bool {
|
||||
_, ok := noCrossLinkServices[service]
|
||||
return !ok
|
||||
}
|
||||
|
||||
// GetCrosslinkURL returns the crosslinking URL for the shape based on the name and
|
||||
// uid provided. Empty string is returned if no crosslink link could be determined.
|
||||
func GetCrosslinkURL(baseURL, uid string, params ...string) string {
|
||||
@@ -314,14 +350,16 @@ func GetCrosslinkURL(baseURL, uid string, params ...string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
if _, ok := noCrossLinkServices[strings.ToLower(serviceIDFromUID(uid))]; ok {
|
||||
if !HasCrosslinks(strings.ToLower(ServiceIDFromUID(uid))) {
|
||||
return ""
|
||||
}
|
||||
|
||||
return strings.Join(append([]string{baseURL, "goto", "WebAPI", uid}, params...), "/")
|
||||
}
|
||||
|
||||
func serviceIDFromUID(uid string) string {
|
||||
// ServiceIDFromUID will parse the service id from the uid and return
|
||||
// the service id that was found.
|
||||
func ServiceIDFromUID(uid string) string {
|
||||
found := 0
|
||||
i := len(uid) - 1
|
||||
for ; i >= 0; i-- {
|
||||
@@ -363,7 +401,7 @@ var tplServiceDoc = template.Must(template.New("service docs").Funcs(template.Fu
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To {{ .Metadata.ServiceFullName }} with the SDK use the New function to create
|
||||
// To contact {{ .Metadata.ServiceFullName }} with the SDK use the New function to create
|
||||
// a new service client. With that client you can make API requests to the service.
|
||||
// These clients are safe to use concurrently.
|
||||
//
|
||||
@@ -450,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,
|
||||
@@ -763,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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user