mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Upgrade AWS SDK to the latest version
This commit is contained in:
+42
-13
@@ -62,6 +62,20 @@ func newGenerateInfo(modelFile, svcPath, svcImportPath string) *generateInfo {
|
||||
fmt.Println("waiters-2.json error:", err)
|
||||
}
|
||||
|
||||
examplesFile := strings.Replace(modelFile, "api-2.json", "examples-1.json", -1)
|
||||
if _, err := os.Stat(examplesFile); err == nil {
|
||||
g.API.AttachExamples(examplesFile)
|
||||
} else if !os.IsNotExist(err) {
|
||||
fmt.Println("examples-1.json error:", err)
|
||||
}
|
||||
|
||||
// pkgDocAddonsFile := strings.Replace(modelFile, "api-2.json", "go-pkg-doc.gotmpl", -1)
|
||||
// if _, err := os.Stat(pkgDocAddonsFile); err == nil {
|
||||
// g.API.AttachPackageDocAddons(pkgDocAddonsFile)
|
||||
// } else if !os.IsNotExist(err) {
|
||||
// fmt.Println("go-pkg-doc.gotmpl error:", err)
|
||||
// }
|
||||
|
||||
g.API.Setup()
|
||||
|
||||
if svc := os.Getenv("SERVICES"); svc != "" {
|
||||
@@ -175,13 +189,14 @@ func writeServiceFiles(g *generateInfo, filename string) {
|
||||
fmt.Printf("Generating %s (%s)...\n",
|
||||
g.API.PackageName(), g.API.Metadata.APIVersion)
|
||||
|
||||
// write api.go and service.go files
|
||||
// write files for service client and API
|
||||
Must(writeServiceDocFile(g))
|
||||
Must(writeAPIFile(g))
|
||||
Must(writeExamplesFile(g))
|
||||
Must(writeServiceFile(g))
|
||||
Must(writeInterfaceFile(g))
|
||||
Must(writeWaitersFile(g))
|
||||
Must(writeAPIErrorsFile(g))
|
||||
Must(writeExamplesFile(g))
|
||||
}
|
||||
|
||||
// Must will panic if the error passed in is not nil.
|
||||
@@ -191,7 +206,8 @@ func Must(err error) {
|
||||
}
|
||||
}
|
||||
|
||||
const codeLayout = `// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
||||
const codeLayout = `// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
%s
|
||||
package %s
|
||||
|
||||
@@ -202,14 +218,28 @@ func writeGoFile(file string, layout string, args ...interface{}) error {
|
||||
return ioutil.WriteFile(file, []byte(util.GoFmt(fmt.Sprintf(layout, args...))), 0664)
|
||||
}
|
||||
|
||||
// writeServiceDocFile generates the documentation for service package.
|
||||
func writeServiceDocFile(g *generateInfo) error {
|
||||
return writeGoFile(filepath.Join(g.PackageDir, "doc.go"),
|
||||
codeLayout,
|
||||
strings.TrimSpace(g.API.ServicePackageDoc()),
|
||||
g.API.PackageName(),
|
||||
"",
|
||||
)
|
||||
}
|
||||
|
||||
// writeExamplesFile writes out the service example file.
|
||||
func writeExamplesFile(g *generateInfo) error {
|
||||
return writeGoFile(filepath.Join(g.PackageDir, "examples_test.go"),
|
||||
codeLayout,
|
||||
"",
|
||||
g.API.PackageName()+"_test",
|
||||
g.API.ExampleGoCode(),
|
||||
)
|
||||
code := g.API.ExamplesGoCode()
|
||||
if len(code) > 0 {
|
||||
return writeGoFile(filepath.Join(g.PackageDir, "examples_test.go"),
|
||||
codeLayout,
|
||||
"",
|
||||
g.API.PackageName()+"_test",
|
||||
code,
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// writeServiceFile writes out the service initialization file.
|
||||
@@ -252,18 +282,17 @@ func writeWaitersFile(g *generateInfo) error {
|
||||
)
|
||||
}
|
||||
|
||||
// writeAPIFile writes out the service api file.
|
||||
// writeAPIFile writes out the service API file.
|
||||
func writeAPIFile(g *generateInfo) error {
|
||||
return writeGoFile(filepath.Join(g.PackageDir, "api.go"),
|
||||
codeLayout,
|
||||
fmt.Sprintf("\n// Package %s provides a client for %s.",
|
||||
g.API.PackageName(), g.API.Metadata.ServiceFullName),
|
||||
"",
|
||||
g.API.PackageName(),
|
||||
g.API.APIGoCode(),
|
||||
)
|
||||
}
|
||||
|
||||
// writeAPIErrorsFile writes out the service api errors file.
|
||||
// writeAPIErrorsFile writes out the service API errors file.
|
||||
func writeAPIErrorsFile(g *generateInfo) error {
|
||||
return writeGoFile(filepath.Join(g.PackageDir, "errors.go"),
|
||||
codeLayout,
|
||||
|
||||
Reference in New Issue
Block a user