Bump sigs.k8s.io/controller-tools from 0.6.2 to 0.11.1 (#5432)
This commit is contained in:
12
vendor/sigs.k8s.io/controller-tools/pkg/markers/collect.go
generated
vendored
12
vendor/sigs.k8s.io/controller-tools/pkg/markers/collect.go
generated
vendored
@@ -65,13 +65,13 @@ func (c *Collector) init() {
|
||||
//
|
||||
// - it's in the Godoc for that AST node
|
||||
//
|
||||
// - it's in the closest non-godoc comment group above that node,
|
||||
// *and* that node is a type or field node, *and* [it's either
|
||||
// registered as type-level *or* it's not registered as being
|
||||
// package-level]
|
||||
// - it's in the closest non-godoc comment group above that node,
|
||||
// *and* that node is a type or field node, *and* [it's either
|
||||
// registered as type-level *or* it's not registered as being
|
||||
// package-level]
|
||||
//
|
||||
// - it's not in the Godoc of a node, doesn't meet the above criteria, and
|
||||
// isn't in a struct definition (in which case it's package-level)
|
||||
// - it's not in the Godoc of a node, doesn't meet the above criteria, and
|
||||
// isn't in a struct definition (in which case it's package-level)
|
||||
func (c *Collector) MarkersInPackage(pkg *loader.Package) (map[ast.Node]MarkerValues, error) {
|
||||
c.mu.Lock()
|
||||
c.init()
|
||||
|
||||
22
vendor/sigs.k8s.io/controller-tools/pkg/markers/doc.go
generated
vendored
22
vendor/sigs.k8s.io/controller-tools/pkg/markers/doc.go
generated
vendored
@@ -19,7 +19,7 @@ limitations under the License.
|
||||
// avoid confusing with struct tags). Parsed result (output) values take the
|
||||
// form of Go values, much like the "encoding/json" package.
|
||||
//
|
||||
// Definitions and Parsing
|
||||
// # Definitions and Parsing
|
||||
//
|
||||
// Markers are defined as structured Definitions which can be used to
|
||||
// consistently parse marker comments. A Definition contains an concrete
|
||||
@@ -29,20 +29,20 @@ limitations under the License.
|
||||
//
|
||||
// Markers take the general form
|
||||
//
|
||||
// +path:to:marker=val
|
||||
// +path:to:marker=val
|
||||
//
|
||||
// +path:to:marker:arg1=val,arg2=val2
|
||||
// +path:to:marker:arg1=val,arg2=val2
|
||||
//
|
||||
// +path:to:marker
|
||||
// +path:to:marker
|
||||
//
|
||||
// Arguments may be ints, bools, strings, and slices. Ints and bool take their
|
||||
// standard form from Go. Strings may take any of their standard forms, or any
|
||||
// sequence of unquoted characters up until a `,` or `;` is encountered. Lists
|
||||
// take either of the following forms:
|
||||
//
|
||||
// val;val;val
|
||||
// val;val;val
|
||||
//
|
||||
// {val, val, val}
|
||||
// {val, val, val}
|
||||
//
|
||||
// Note that the first form will not properly parse nested slices, but is
|
||||
// generally convenient and is the form used in many existing markers.
|
||||
@@ -61,7 +61,7 @@ limitations under the License.
|
||||
// non-optional fields aren't mentioned, an error will be raised unless
|
||||
// `Strict` is set to false.
|
||||
//
|
||||
// Registries and Lookup
|
||||
// # Registries and Lookup
|
||||
//
|
||||
// Definitions can be added to registries to facilitate lookups. Each
|
||||
// definition is marked as either describing a type, struct field, or package
|
||||
@@ -69,7 +69,7 @@ limitations under the License.
|
||||
// long as each describes a different construct (type, field, or package).
|
||||
// Definitions can then be looked up by passing unparsed markers.
|
||||
//
|
||||
// Collection and Extraction
|
||||
// # Collection and Extraction
|
||||
//
|
||||
// Markers can be collected from a loader.Package using a Collector. The
|
||||
// Collector will read from a given Registry, collecting comments that look
|
||||
@@ -85,7 +85,7 @@ limitations under the License.
|
||||
// Like loader.Package, Collector's methods are idempotent and will not
|
||||
// reperform work.
|
||||
//
|
||||
// Traversal
|
||||
// # Traversal
|
||||
//
|
||||
// EachType function iterates over each type in a Package, providing
|
||||
// conveniently structured type and field information with marker values
|
||||
@@ -93,14 +93,14 @@ limitations under the License.
|
||||
//
|
||||
// PackageMarkers can be used to fetch just package-level markers.
|
||||
//
|
||||
// Help
|
||||
// # Help
|
||||
//
|
||||
// Help can be defined for each marker using the DefinitionHelp struct. It's
|
||||
// mostly intended to be generated off of godocs using cmd/helpgen, which takes
|
||||
// the first line as summary (removing the type/field name), and considers the
|
||||
// rest as details. It looks for the
|
||||
//
|
||||
// +controllertools:generateHelp[:category=<string>]
|
||||
// +controllertools:generateHelp[:category=<string>]
|
||||
//
|
||||
// marker to start generation.
|
||||
//
|
||||
|
||||
44
vendor/sigs.k8s.io/controller-tools/pkg/markers/parse.go
generated
vendored
44
vendor/sigs.k8s.io/controller-tools/pkg/markers/parse.go
generated
vendored
@@ -84,6 +84,8 @@ const (
|
||||
InvalidType ArgumentType = iota
|
||||
// IntType is an int
|
||||
IntType
|
||||
// NumberType is a float64
|
||||
NumberType
|
||||
// StringType is a string
|
||||
StringType
|
||||
// BoolType is a bool
|
||||
@@ -127,6 +129,8 @@ func (a Argument) typeString(out *strings.Builder) {
|
||||
out.WriteString("<invalid>")
|
||||
case IntType:
|
||||
out.WriteString("int")
|
||||
case NumberType:
|
||||
out.WriteString("float64")
|
||||
case StringType:
|
||||
out.WriteString("string")
|
||||
case BoolType:
|
||||
@@ -180,6 +184,8 @@ func makeSliceType(itemType Argument) (reflect.Type, error) {
|
||||
switch itemType.Type {
|
||||
case IntType:
|
||||
itemReflectedType = reflect.TypeOf(int(0))
|
||||
case NumberType:
|
||||
itemReflectedType = reflect.TypeOf(float64(0))
|
||||
case StringType:
|
||||
itemReflectedType = reflect.TypeOf("")
|
||||
case BoolType:
|
||||
@@ -215,6 +221,8 @@ func makeMapType(itemType Argument) (reflect.Type, error) {
|
||||
switch itemType.Type {
|
||||
case IntType:
|
||||
itemReflectedType = reflect.TypeOf(int(0))
|
||||
case NumberType:
|
||||
itemReflectedType = reflect.TypeOf(float64(0))
|
||||
case StringType:
|
||||
itemReflectedType = reflect.TypeOf("")
|
||||
case BoolType:
|
||||
@@ -346,9 +354,13 @@ func guessType(scanner *sc.Scanner, raw string, allowSlice bool) *Argument {
|
||||
if nextTok == '-' {
|
||||
nextTok = subScanner.Scan()
|
||||
}
|
||||
|
||||
if nextTok == sc.Int {
|
||||
return &Argument{Type: IntType}
|
||||
}
|
||||
if nextTok == sc.Float {
|
||||
return &Argument{Type: NumberType}
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise assume bare strings
|
||||
@@ -471,7 +483,7 @@ func (a *Argument) parseMap(scanner *sc.Scanner, raw string, out reflect.Value)
|
||||
func (a *Argument) parse(scanner *sc.Scanner, raw string, out reflect.Value, inSlice bool) {
|
||||
// nolint:gocyclo
|
||||
if a.Type == InvalidType {
|
||||
scanner.Error(scanner, fmt.Sprintf("cannot parse invalid type"))
|
||||
scanner.Error(scanner, "cannot parse invalid type")
|
||||
return
|
||||
}
|
||||
if a.Pointer {
|
||||
@@ -485,6 +497,32 @@ func (a *Argument) parse(scanner *sc.Scanner, raw string, out reflect.Value, inS
|
||||
// consume everything else
|
||||
for tok := scanner.Scan(); tok != sc.EOF; tok = scanner.Scan() {
|
||||
}
|
||||
case NumberType:
|
||||
nextChar := scanner.Peek()
|
||||
isNegative := false
|
||||
if nextChar == '-' {
|
||||
isNegative = true
|
||||
scanner.Scan() // eat the '-'
|
||||
}
|
||||
|
||||
tok := scanner.Scan()
|
||||
if tok != sc.Float && tok != sc.Int {
|
||||
scanner.Error(scanner, fmt.Sprintf("expected integer or float, got %q", scanner.TokenText()))
|
||||
return
|
||||
}
|
||||
|
||||
text := scanner.TokenText()
|
||||
if isNegative {
|
||||
text = "-" + text
|
||||
}
|
||||
|
||||
val, err := strconv.ParseFloat(text, 64)
|
||||
if err != nil {
|
||||
scanner.Error(scanner, fmt.Sprintf("unable to parse number: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
castAndSet(out, reflect.ValueOf(val))
|
||||
case IntType:
|
||||
nextChar := scanner.Peek()
|
||||
isNegative := false
|
||||
@@ -597,6 +635,8 @@ func ArgumentFromType(rawType reflect.Type) (Argument, error) {
|
||||
arg.Type = StringType
|
||||
case reflect.Int, reflect.Int32: // NB(directxman12): all ints in kubernetes are int32, so explicitly support that
|
||||
arg.Type = IntType
|
||||
case reflect.Float64:
|
||||
arg.Type = NumberType
|
||||
case reflect.Bool:
|
||||
arg.Type = BoolType
|
||||
case reflect.Slice:
|
||||
@@ -755,7 +795,7 @@ func (d *Definition) loadFields() error {
|
||||
func parserScanner(raw string, err func(*sc.Scanner, string)) *sc.Scanner {
|
||||
scanner := &sc.Scanner{}
|
||||
scanner.Init(bytes.NewBufferString(raw))
|
||||
scanner.Mode = sc.ScanIdents | sc.ScanInts | sc.ScanStrings | sc.ScanRawStrings | sc.SkipComments
|
||||
scanner.Mode = sc.ScanIdents | sc.ScanInts | sc.ScanFloats | sc.ScanStrings | sc.ScanRawStrings | sc.SkipComments
|
||||
scanner.Error = err
|
||||
|
||||
return scanner
|
||||
|
||||
3
vendor/sigs.k8s.io/controller-tools/pkg/markers/reg.go
generated
vendored
3
vendor/sigs.k8s.io/controller-tools/pkg/markers/reg.go
generated
vendored
@@ -52,7 +52,8 @@ func (r *Registry) init() {
|
||||
|
||||
// Define defines a new marker with the given name, target, and output type.
|
||||
// It's a shortcut around
|
||||
// r.Register(MakeDefinition(name, target, obj))
|
||||
//
|
||||
// r.Register(MakeDefinition(name, target, obj))
|
||||
func (r *Registry) Define(name string, target TargetType, obj interface{}) error {
|
||||
def, err := MakeDefinition(name, target, obj)
|
||||
if err != nil {
|
||||
|
||||
22
vendor/sigs.k8s.io/controller-tools/pkg/markers/zip.go
generated
vendored
22
vendor/sigs.k8s.io/controller-tools/pkg/markers/zip.go
generated
vendored
@@ -67,12 +67,22 @@ func extractDoc(node ast.Node, decl *ast.GenDecl) string {
|
||||
// chop off the extraneous last part
|
||||
outLines = outLines[:len(outLines)-1]
|
||||
}
|
||||
// respect double-newline meaning actual newline
|
||||
|
||||
for i, line := range outLines {
|
||||
// Trim any extranous whitespace,
|
||||
// for handling /*…*/-style comments,
|
||||
// which have whitespace preserved in go/ast:
|
||||
line = strings.TrimSpace(line)
|
||||
|
||||
// Respect that double-newline means
|
||||
// actual newline:
|
||||
if line == "" {
|
||||
outLines[i] = "\n"
|
||||
} else {
|
||||
outLines[i] = line
|
||||
}
|
||||
}
|
||||
|
||||
return strings.Join(outLines, " ")
|
||||
}
|
||||
|
||||
@@ -139,11 +149,11 @@ type TypeCallback func(info *TypeInfo)
|
||||
// EachType collects all markers, then calls the given callback for each type declaration in a package.
|
||||
// Each individual spec is considered separate, so
|
||||
//
|
||||
// type (
|
||||
// Foo string
|
||||
// Bar int
|
||||
// Baz struct{}
|
||||
// )
|
||||
// type (
|
||||
// Foo string
|
||||
// Bar int
|
||||
// Baz struct{}
|
||||
// )
|
||||
//
|
||||
// yields three calls to the callback.
|
||||
func EachType(col *Collector, pkg *loader.Package, cb TypeCallback) error {
|
||||
|
||||
Reference in New Issue
Block a user