Update vendored dependencies

This commit is contained in:
Christian Huffman
2020-07-23 15:19:22 -04:00
parent 547e88e4fb
commit bda8f8c0ae
909 changed files with 119096 additions and 130549 deletions

View File

@@ -25,7 +25,7 @@ import (
"strconv"
"strings"
"k8s.io/klog"
"k8s.io/klog/v2"
"k8s.io/gengo/generator"
"k8s.io/gengo/namer"
@@ -371,7 +371,7 @@ func (b bodyGen) doStruct(sw *generator.SnippetWriter) error {
`, b.t)
if len(options) > 0 {
sort.Sort(sort.StringSlice(options))
sort.Strings(options)
for _, s := range options {
fmt.Fprintf(out, " option %s;\n", s)
}
@@ -399,7 +399,7 @@ func (b bodyGen) doStruct(sw *generator.SnippetWriter) error {
}
extras = append(extras, fmt.Sprintf("%s = %s", k, v))
}
sort.Sort(sort.StringSlice(extras))
sort.Strings(extras)
if len(extras) > 0 {
fmt.Fprintf(out, " [")
fmt.Fprint(out, strings.Join(extras, ", "))

View File

@@ -375,6 +375,21 @@ func RewriteTypesWithProtobufStructTags(name string, structTags map[string]map[s
})
}
func getFieldName(expr ast.Expr, structname string) (name string, err error) {
for {
switch t := expr.(type) {
case *ast.Ident:
return t.Name, nil
case *ast.SelectorExpr:
return t.Sel.Name, nil
case *ast.StarExpr:
expr = t.X
default:
return "", fmt.Errorf("unable to get name for tag from struct %q, field %#v", structname, t)
}
}
}
func updateStructTags(decl ast.Decl, structTags map[string]map[string]string, toCopy []string) []error {
var errs []error
t, ok := decl.(*ast.GenDecl)
@@ -403,14 +418,11 @@ func updateStructTags(decl ast.Decl, structTags map[string]map[string]string, to
for i := range st.Fields.List {
f := st.Fields.List[i]
var name string
var err error
if len(f.Names) == 0 {
switch t := f.Type.(type) {
case *ast.Ident:
name = t.Name
case *ast.SelectorExpr:
name = t.Sel.Name
default:
errs = append(errs, fmt.Errorf("unable to get name for tag from struct %q, field %#v", spec.Name.Name, t))
name, err = getFieldName(f.Type, spec.Name.Name)
if err != nil {
errs = append(errs, err)
continue
}
} else {

View File

@@ -18,7 +18,7 @@ package protobuf
import (
"k8s.io/gengo/types"
"k8s.io/klog"
"k8s.io/klog/v2"
)
// extractBoolTagOrDie gets the comment-tags for the key and asserts that, if