mirror of
https://github.com/restic/restic.git
synced 2025-12-22 22:26:27 +00:00
Update dependenciess
Exclude minio-go for now (pin to 3.x.y).
This commit is contained in:
60
vendor/google.golang.org/api/google-api-go-generator/gen.go
generated
vendored
60
vendor/google.golang.org/api/google-api-go-generator/gen.go
generated
vendored
@@ -7,6 +7,7 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/format"
|
||||
@@ -132,11 +133,11 @@ func main() {
|
||||
matches = append(matches, api)
|
||||
log.Printf("Generating API %s", api.ID)
|
||||
err := api.WriteGeneratedCode()
|
||||
if err != nil {
|
||||
if err != nil && err != errNoDoc {
|
||||
errors = append(errors, &generateError{api, err})
|
||||
continue
|
||||
}
|
||||
if *build {
|
||||
if *build && err == nil {
|
||||
var args []string
|
||||
if *install {
|
||||
args = append(args, "install")
|
||||
@@ -309,6 +310,10 @@ func slurpURL(urlStr string) []byte {
|
||||
if err != nil {
|
||||
log.Fatalf("Error fetching URL %s: %v", urlStr, err)
|
||||
}
|
||||
if res.StatusCode >= 300 {
|
||||
log.Printf("WARNING: URL %s served status code %d", urlStr, res.StatusCode)
|
||||
return nil
|
||||
}
|
||||
bs, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
log.Fatalf("Error reading body of URL %s: %v", urlStr, err)
|
||||
@@ -435,27 +440,40 @@ func (a *API) needsDataWrapper() bool {
|
||||
}
|
||||
|
||||
func (a *API) jsonBytes() []byte {
|
||||
if v := a.forceJSON; v != nil {
|
||||
return v
|
||||
}
|
||||
if *useCache {
|
||||
slurp, err := ioutil.ReadFile(a.JSONFile())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
if a.forceJSON == nil {
|
||||
var slurp []byte
|
||||
var err error
|
||||
if *useCache {
|
||||
slurp, err = ioutil.ReadFile(a.JSONFile())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
slurp = slurpURL(a.DiscoveryURL())
|
||||
}
|
||||
return slurp
|
||||
a.forceJSON = slurp
|
||||
}
|
||||
return slurpURL(a.DiscoveryURL())
|
||||
return a.forceJSON
|
||||
}
|
||||
|
||||
func (a *API) JSONFile() string {
|
||||
return filepath.Join(a.SourceDir(), a.Package()+"-api.json")
|
||||
}
|
||||
|
||||
var errNoDoc = errors.New("could not read discovery doc")
|
||||
|
||||
// WriteGeneratedCode generates code for a.
|
||||
// It returns errNoDoc if we couldn't read the discovery doc.
|
||||
func (a *API) WriteGeneratedCode() error {
|
||||
genfilename := *output
|
||||
jsonBytes := a.jsonBytes()
|
||||
// Skip generation if we don't have the discovery doc.
|
||||
if jsonBytes == nil {
|
||||
// No message here, because slurpURL printed one.
|
||||
return errNoDoc
|
||||
}
|
||||
if genfilename == "" {
|
||||
if err := writeFile(a.JSONFile(), a.jsonBytes()); err != nil {
|
||||
if err := writeFile(a.JSONFile(), jsonBytes); err != nil {
|
||||
return err
|
||||
}
|
||||
outdir := a.SourceDir()
|
||||
@@ -472,7 +490,10 @@ func (a *API) WriteGeneratedCode() error {
|
||||
if err == nil {
|
||||
err = errw
|
||||
}
|
||||
return err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var docsLink string
|
||||
@@ -1238,9 +1259,9 @@ func (s *Schema) writeSchemaStruct(api *API) {
|
||||
// by listing them in the field identified by nullFieldsName.
|
||||
func (s *Schema) writeSchemaMarshal(forceSendFieldName, nullFieldsName string) {
|
||||
s.api.pn("func (s *%s) MarshalJSON() ([]byte, error) {", s.GoName())
|
||||
s.api.pn("\ttype noMethod %s", s.GoName())
|
||||
s.api.pn("\ttype NoMethod %s", s.GoName())
|
||||
// pass schema as methodless type to prevent subsequent calls to MarshalJSON from recursing indefinitely.
|
||||
s.api.pn("\traw := noMethod(*s)")
|
||||
s.api.pn("\traw := NoMethod(*s)")
|
||||
s.api.pn("\treturn gensupport.MarshalJSON(raw, s.%s, s.%s)", forceSendFieldName, nullFieldsName)
|
||||
s.api.pn("}")
|
||||
}
|
||||
@@ -1257,7 +1278,7 @@ func (s *Schema) writeSchemaUnmarshal() {
|
||||
}
|
||||
pn := s.api.pn
|
||||
pn("\nfunc (s *%s) UnmarshalJSON(data []byte) error {", s.GoName())
|
||||
pn(" type noMethod %s", s.GoName()) // avoid infinite recursion
|
||||
pn(" type NoMethod %s", s.GoName()) // avoid infinite recursion
|
||||
pn(" var s1 struct {")
|
||||
// Hide the float64 fields of the schema with fields that correctly
|
||||
// unmarshal special values.
|
||||
@@ -1268,10 +1289,10 @@ func (s *Schema) writeSchemaUnmarshal() {
|
||||
}
|
||||
pn("%s %s `json:\"%s\"`", p.assignedGoName, typ, p.p.Name)
|
||||
}
|
||||
pn(" *noMethod") // embed the schema
|
||||
pn(" *NoMethod") // embed the schema
|
||||
pn(" }")
|
||||
// Set the schema value into the wrapper so its other fields are unmarshaled.
|
||||
pn(" s1.noMethod = (*noMethod)(s)")
|
||||
pn(" s1.NoMethod = (*NoMethod)(s)")
|
||||
pn(" if err := json.Unmarshal(data, &s1); err != nil {")
|
||||
pn(" return err")
|
||||
pn(" }")
|
||||
@@ -1925,8 +1946,7 @@ func (meth *Method) generateCode() {
|
||||
} else {
|
||||
pn("target := &ret")
|
||||
}
|
||||
|
||||
pn("if err := json.NewDecoder(res.Body).Decode(target); err != nil { return nil, err }")
|
||||
pn("if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err }")
|
||||
pn("return ret, nil")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user