diff --git a/contrib/tetragon-rthooks/go.mod b/contrib/tetragon-rthooks/go.mod index 497267dff12..ffc98190f19 100644 --- a/contrib/tetragon-rthooks/go.mod +++ b/contrib/tetragon-rthooks/go.mod @@ -6,7 +6,7 @@ go 1.22.1 toolchain go1.22.3 require ( - github.com/alecthomas/kong v0.9.0 + github.com/alecthomas/kong v1.2.1 github.com/cilium/lumberjack/v2 v2.3.0 github.com/cilium/tetragon/api v0.0.0-00010101000000-000000000000 github.com/containerd/containerd v1.7.21 diff --git a/contrib/tetragon-rthooks/go.sum b/contrib/tetragon-rthooks/go.sum index bc41881b78d..99407a54393 100644 --- a/contrib/tetragon-rthooks/go.sum +++ b/contrib/tetragon-rthooks/go.sum @@ -3,10 +3,10 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU= -github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/kong v0.9.0 h1:G5diXxc85KvoV2f0ZRVuMsi45IrBgx9zDNGNj165aPA= -github.com/alecthomas/kong v0.9.0/go.mod h1:Y47y5gKfHp1hDc7CH7OeXgLIpp+Q2m1Ni0L5s3bI8Os= +github.com/alecthomas/assert/v2 v2.10.0 h1:jjRCHsj6hBJhkmhznrCzoNpbA3zqy0fYiUcYZP/GkPY= +github.com/alecthomas/assert/v2 v2.10.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/kong v1.2.1 h1:E8jH4Tsgv6wCRX2nGrdPyHDUCSG83WH2qE4XLACD33Q= +github.com/alecthomas/kong v1.2.1/go.mod h1:rKTSFhbdp3Ryefn8x5MOEprnRFQ7nlmMC01GKhehhBM= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/.golangci.yml b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/.golangci.yml index e8980bfcf8d..c922a37bcf6 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/.golangci.yml +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/.golangci.yml @@ -47,6 +47,8 @@ linters: - varcheck # deprecated since v1.49.0 - depguard # nothing to guard against yet - tagalign # hurts readability of kong tags + - mnd + - perfsprint linters-settings: govet: @@ -76,6 +78,7 @@ issues: - 'bad syntax for struct tag key' - 'bad syntax for struct tag pair' - 'result .* \(error\) is always nil' + - 'Error return value of `fmt.Fprintln` is not checked' exclude-rules: # Don't warn on unused parameters. @@ -87,3 +90,7 @@ issues: # Duplicate words are okay in tests. - linters: [dupword] path: _test\.go + + - linters: [maintidx] + path: context\.go + text: 'Function name: trace' diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/README.md b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/README.md index 22e00f067a4..3936fde3e21 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/README.md +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/README.md @@ -554,29 +554,31 @@ Tags can be in two forms: Both can coexist with standard Tag parsing. | Tag | Description | -| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `cmd:""` | If present, struct is a command. | | `arg:""` | If present, field is an argument. Required by default. | | `env:"X,Y,..."` | Specify envars to use for default value. The envs are resolved in the declared order. The first value found is used. | | `name:"X"` | Long name, for overriding field name. | | `help:"X"` | Help text. | | `type:"X"` | Specify [named types](#custom-named-decoders) to use. | -| `placeholder:"X"` | Placeholder text. | +| `placeholder:"X"` | Placeholder input, if flag. e.g. `` `placeholder:""` `` will show `--flag-name=` when displaying help. | | `default:"X"` | Default value. | | `default:"1"` | On a command, make it the default. | | `default:"withargs"` | On a command, make it the default and allow args/flags from that command | | `short:"X"` | Short name, if flag. | -| `aliases:"X,Y"` | One or more aliases (for cmd or flag). | +| `aliases:"X,Y"` | One or more aliases (for cmd or flag). | | `required:""` | If present, flag/arg is required. | | `optional:""` | If present, flag/arg is optional. | | `hidden:""` | If present, command or flag is hidden. | | `negatable:""` | If present on a `bool` field, supports prefixing a flag with `--no-` to invert the default value | +| `negatable:"X"` | If present on a `bool` field, supports `--X` to invert the default value | | `format:"X"` | Format for parsing input, if supported. | | `sep:"X"` | Separator for sequences (defaults to ","). May be `none` to disable splitting. | | `mapsep:"X"` | Separator for maps (defaults to ";"). May be `none` to disable splitting. | | `enum:"X,Y,..."` | Set of valid values allowed for this flag. An enum field must be `required` or have a valid `default`. | | `group:"X"` | Logical group for a flag or command. | | `xor:"X,Y,..."` | Exclusive OR groups for flags. Only one flag in the group can be used which is restricted within the same command. When combined with `required`, at least one of the `xor` group will be required. | +| `and:"X,Y,..."` | AND groups for flags. All flags in the group must be used in the same command. When combined with `required`, all flags in the group will be required. | | `prefix:"X"` | Prefix for all sub-flags. | | `envprefix:"X"` | Envar prefix for all sub-flags. | | `set:"K=V"` | Set a variable for expansion by child elements. Multiples can occur. | @@ -733,7 +735,7 @@ All builtin Go types (as well as a bunch of useful stdlib types like `time.Time` The default help output is usually sufficient, but if not there are two solutions. 1. Use `ConfigureHelp(HelpOptions)` to configure how help is formatted (see [HelpOptions](https://godoc.org/github.com/alecthomas/kong#HelpOptions) for details). -2. Custom help can be wired into Kong via the `Help(HelpFunc)` option. The `HelpFunc` is passed a `Context`, which contains the parsed context for the current command-line. See the implementation of `PrintHelp` for an example. +2. Custom help can be wired into Kong via the `Help(HelpFunc)` option. The `HelpFunc` is passed a `Context`, which contains the parsed context for the current command-line. See the implementation of `DefaultHelpPrinter` for an example. 3. Use `ValueFormatter(HelpValueFormatter)` if you want to just customize the help text that is accompanied by flags and arguments. 4. Use `Groups([]Group)` if you want to customize group titles or add a header. diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/build.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/build.go index a52d90fa952..287beeb8e38 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/build.go +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/build.go @@ -51,6 +51,9 @@ type flattenedField struct { func flattenedFields(v reflect.Value, ptag *Tag) (out []flattenedField, err error) { v = reflect.Indirect(v) + if v.Kind() != reflect.Struct { + return out, nil + } for i := 0; i < v.NumField(); i++ { ft := v.Type().Field(i) fv := v.Field(i) @@ -170,6 +173,12 @@ MAIN: if flag.Short != 0 { delete(seenFlags, "-"+string(flag.Short)) } + if negFlag := negatableFlagName(flag.Name, flag.Tag.Negatable); negFlag != "" { + delete(seenFlags, negFlag) + } + for _, aflag := range flag.Aliases { + delete(seenFlags, "--"+aflag) + } } if err := validatePositionalArguments(node); err != nil { @@ -309,6 +318,13 @@ func buildField(k *Kong, node *Node, v reflect.Value, ft reflect.StructField, fv } seenFlags["-"+string(tag.Short)] = true } + if tag.Negatable != "" { + negFlag := negatableFlagName(value.Name, tag.Negatable) + if seenFlags[negFlag] { + return failField(v, ft, "duplicate negation flag %s", negFlag) + } + seenFlags[negFlag] = true + } flag := &Flag{ Value: value, Aliases: tag.Aliases, @@ -317,6 +333,7 @@ func buildField(k *Kong, node *Node, v reflect.Value, ft reflect.StructField, fv Envs: tag.Envs, Group: buildGroupForKey(k, tag.Group), Xor: tag.Xor, + And: tag.And, Hidden: tag.Hidden, } value.Flag = flag diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/context.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/context.go index b2bfea6933d..2ed5d28da52 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/context.go +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/context.go @@ -259,7 +259,7 @@ func (c *Context) Validate() error { //nolint: gocyclo if err := checkMissingPositionals(positionals, node.Positional); err != nil { return err } - if err := checkXorDuplicates(c.Path); err != nil { + if err := checkXorDuplicatedAndAndMissing(c.Path); err != nil { return err } @@ -383,9 +383,13 @@ func (c *Context) trace(node *Node) (err error) { //nolint: gocyclo // Indicates end of parsing. All remaining arguments are treated as positional arguments only. case v == "--": - c.scan.Pop() c.endParsing() + // Pop the -- token unless the next positional argument accepts passthrough arguments. + if !(positional < len(node.Positional) && node.Positional[positional].Passthrough) { + c.scan.Pop() + } + // Long flag. case strings.HasPrefix(v, "--"): c.scan.Pop() @@ -420,12 +424,22 @@ func (c *Context) trace(node *Node) (err error) { //nolint: gocyclo case FlagToken: if err := c.parseFlag(flags, token.String()); err != nil { - return err + if isUnknownFlagError(err) && positional < len(node.Positional) && node.Positional[positional].Passthrough { + c.scan.Pop() + c.scan.PushTyped(token.String(), PositionalArgumentToken) + } else { + return err + } } case ShortFlagToken: if err := c.parseFlag(flags, token.String()); err != nil { - return err + if isUnknownFlagError(err) && positional < len(node.Positional) && node.Positional[positional].Passthrough { + c.scan.Pop() + c.scan.PushTyped(token.String(), PositionalArgumentToken) + } else { + return err + } } case FlagValueToken: @@ -700,13 +714,13 @@ func (c *Context) parseFlag(flags []*Flag, match string) (err error) { candidates = append(candidates, alias) } - neg := "--no-" + flag.Name - if !matched && !(match == neg && flag.Tag.Negatable) { + neg := negatableFlagName(flag.Name, flag.Tag.Negatable) + if !matched && match != neg { continue } // Found a matching flag. c.scan.Pop() - if match == neg && flag.Tag.Negatable { + if match == neg && flag.Tag.Negatable != "" { flag.Negated = true } err := flag.Parse(c.scan, c.getValue(flag.Value)) @@ -728,9 +742,19 @@ func (c *Context) parseFlag(flags []*Flag, match string) (err error) { c.Path = append(c.Path, &Path{Flag: flag}) return nil } - return findPotentialCandidates(match, candidates, "unknown flag %s", match) + return &unknownFlagError{Cause: findPotentialCandidates(match, candidates, "unknown flag %s", match)} } +func isUnknownFlagError(err error) bool { + var unknown *unknownFlagError + return errors.As(err, &unknown) +} + +type unknownFlagError struct{ Cause error } + +func (e *unknownFlagError) Unwrap() error { return e.Cause } +func (e *unknownFlagError) Error() string { return e.Cause.Error() } + // Call an arbitrary function filling arguments with bound values. func (c *Context) Call(fn any, binds ...interface{}) (out []interface{}, err error) { fv := reflect.ValueOf(fn) @@ -811,23 +835,35 @@ func (c *Context) PrintUsage(summary bool) error { func checkMissingFlags(flags []*Flag) error { xorGroupSet := map[string]bool{} xorGroup := map[string][]string{} + andGroupSet := map[string]bool{} + andGroup := map[string][]string{} missing := []string{} + andGroupRequired := getRequiredAndGroupMap(flags) for _, flag := range flags { + for _, and := range flag.And { + flag.Required = andGroupRequired[and] + } if flag.Set { for _, xor := range flag.Xor { xorGroupSet[xor] = true } + for _, and := range flag.And { + andGroupSet[and] = true + } } if !flag.Required || flag.Set { continue } - if len(flag.Xor) > 0 { + if len(flag.Xor) > 0 || len(flag.And) > 0 { for _, xor := range flag.Xor { if xorGroupSet[xor] { continue } xorGroup[xor] = append(xorGroup[xor], flag.Summary()) } + for _, and := range flag.And { + andGroup[and] = append(andGroup[and], flag.Summary()) + } } else { missing = append(missing, flag.Summary()) } @@ -837,6 +873,11 @@ func checkMissingFlags(flags []*Flag) error { missing = append(missing, strings.Join(flags, " or ")) } } + for _, flags := range andGroup { + if len(flags) > 1 { + missing = append(missing, strings.Join(flags, " and ")) + } + } if len(missing) == 0 { return nil @@ -847,6 +888,18 @@ func checkMissingFlags(flags []*Flag) error { return fmt.Errorf("missing flags: %s", strings.Join(missing, ", ")) } +func getRequiredAndGroupMap(flags []*Flag) map[string]bool { + andGroupRequired := map[string]bool{} + for _, flag := range flags { + for _, and := range flag.And { + if flag.Required { + andGroupRequired[and] = true + } + } + } + return andGroupRequired +} + func checkMissingChildren(node *Node) error { missing := []string{} @@ -883,7 +936,7 @@ func checkMissingChildren(node *Node) error { if len(missing) == 1 { return fmt.Errorf("expected %s", missing[0]) } - return fmt.Errorf("expected one of %s", strings.Join(missing, ", ")) + return fmt.Errorf("expected one of %s", strings.Join(missing, ", ")) } // If we're missing any positionals and they're required, return an error. @@ -957,6 +1010,20 @@ func checkPassthroughArg(target reflect.Value) bool { } } +func checkXorDuplicatedAndAndMissing(paths []*Path) error { + errs := []string{} + if err := checkXorDuplicates(paths); err != nil { + errs = append(errs, err.Error()) + } + if err := checkAndMissing(paths); err != nil { + errs = append(errs, err.Error()) + } + if len(errs) > 0 { + return errors.New(strings.Join(errs, ", ")) + } + return nil +} + func checkXorDuplicates(paths []*Path) error { for _, path := range paths { seen := map[string]*Flag{} @@ -975,6 +1042,38 @@ func checkXorDuplicates(paths []*Path) error { return nil } +func checkAndMissing(paths []*Path) error { + for _, path := range paths { + missingMsgs := []string{} + andGroups := map[string][]*Flag{} + for _, flag := range path.Flags { + for _, and := range flag.And { + andGroups[and] = append(andGroups[and], flag) + } + } + for _, flags := range andGroups { + oneSet := false + notSet := []*Flag{} + flagNames := []string{} + for _, flag := range flags { + flagNames = append(flagNames, flag.Name) + if flag.Set { + oneSet = true + } else { + notSet = append(notSet, flag) + } + } + if len(notSet) > 0 && oneSet { + missingMsgs = append(missingMsgs, fmt.Sprintf("--%s must be used together", strings.Join(flagNames, " and --"))) + } + } + if len(missingMsgs) > 0 { + return fmt.Errorf("%s", strings.Join(missingMsgs, ", ")) + } + } + return nil +} + func findPotentialCandidates(needle string, haystack []string, format string, args ...interface{}) error { if len(haystack) == 0 { return fmt.Errorf(format, args...) diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/help.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/help.go index cf5a912c2e9..26f355df373 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/help.go +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/help.go @@ -491,27 +491,22 @@ func formatFlag(haveShort bool, flag *Flag) string { name := flag.Name isBool := flag.IsBool() isCounter := flag.IsCounter() + + short := "" if flag.Short != 0 { - if isBool && flag.Tag.Negatable { - flagString += fmt.Sprintf("-%c, --[no-]%s", flag.Short, name) - } else { - flagString += fmt.Sprintf("-%c, --%s", flag.Short, name) - } - } else { - if isBool && flag.Tag.Negatable { - if haveShort { - flagString = fmt.Sprintf(" --[no-]%s", name) - } else { - flagString = fmt.Sprintf("--[no-]%s", name) - } - } else { - if haveShort { - flagString += fmt.Sprintf(" --%s", name) - } else { - flagString += fmt.Sprintf("--%s", name) - } - } + short = "-" + string(flag.Short) + ", " + } else if haveShort { + short = " " + } + + if isBool && flag.Tag.Negatable == negatableDefault { + name = "[no-]" + name + } else if isBool && flag.Tag.Negatable != "" { + name += "/" + flag.Tag.Negatable } + + flagString += fmt.Sprintf("%s--%s", short, name) + if !isBool && !isCounter { flagString += fmt.Sprintf("=%s", flag.FormatPlaceHolder()) } diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/kong.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/kong.go index 76eaefe7011..10235d0ff66 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/kong.go +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/kong.go @@ -167,9 +167,42 @@ func New(grammar interface{}, options ...Option) (*Kong, error) { k.bindings.add(k.vars) + if err = checkOverlappingXorAnd(k); err != nil { + return nil, err + } + return k, nil } +func checkOverlappingXorAnd(k *Kong) error { + xorGroups := map[string][]string{} + andGroups := map[string][]string{} + for _, flag := range k.Model.Node.Flags { + for _, xor := range flag.Xor { + xorGroups[xor] = append(xorGroups[xor], flag.Name) + } + for _, and := range flag.And { + andGroups[and] = append(andGroups[and], flag.Name) + } + } + for xor, xorSet := range xorGroups { + for and, andSet := range andGroups { + overlappingEntries := []string{} + for _, xorTag := range xorSet { + for _, andTag := range andSet { + if xorTag == andTag { + overlappingEntries = append(overlappingEntries, xorTag) + } + } + } + if len(overlappingEntries) > 1 { + return fmt.Errorf("invalid xor and combination, %s and %s overlap with more than one: %s", xor, and, overlappingEntries) + } + } + } + return nil +} + type varStack []Vars func (v *varStack) head() Vars { return (*v)[len(*v)-1] } @@ -373,7 +406,7 @@ func (k *Kong) applyHookToDefaultFlags(ctx *Context, node *Node, name string) er } func formatMultilineMessage(w io.Writer, leaders []string, format string, args ...interface{}) { - lines := strings.Split(fmt.Sprintf(format, args...), "\n") + lines := strings.Split(strings.TrimRight(fmt.Sprintf(format, args...), "\n"), "\n") leader := "" for _, l := range leaders { if l == "" { diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/levenshtein.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/levenshtein.go index 1816f301153..6837d6c3097 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/levenshtein.go +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/levenshtein.go @@ -31,7 +31,7 @@ func levenshtein(a, b string) int { return f[len(f)-1] } -func min(a, b int) int { +func min(a, b int) int { //nolint:predeclared if a <= b { return a } diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/model.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/model.go index 8d1f82f9a0a..3190f3e8035 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/model.go +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/model.go @@ -405,6 +405,7 @@ type Flag struct { *Value Group *Group // Logical grouping when displaying. May also be used by configuration loaders to group options logically. Xor []string + And []string PlaceHolder string Envs []string Aliases []string diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/negatable.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/negatable.go new file mode 100644 index 00000000000..7d8902a53d4 --- /dev/null +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/negatable.go @@ -0,0 +1,19 @@ +package kong + +// negatableDefault is a placeholder value for the Negatable tag to indicate +// the negated flag is --no-. This is needed as at the time of +// parsing a tag, the field's flag name is not yet known. +const negatableDefault = "_" + +// negatableFlagName returns the name of the flag for a negatable field, or +// an empty string if the field is not negatable. +func negatableFlagName(name, negation string) string { + switch negation { + case "": + return "" + case negatableDefault: + return "--no-" + name + default: + return "--" + negation + } +} diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/options.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/options.go index d01aeec22c4..3ab383b5bf0 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/options.go +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/options.go @@ -89,6 +89,10 @@ type dynamicCommand struct { // "tags" is a list of extra tag strings to parse, in the form :"". func DynamicCommand(name, help, group string, cmd interface{}, tags ...string) Option { return OptionFunc(func(k *Kong) error { + if run := getMethod(reflect.Indirect(reflect.ValueOf(cmd)), "Run"); !run.IsValid() { + return fmt.Errorf("kong: DynamicCommand %q must be a type with a 'Run' method; got %T", name, cmd) + } + k.dynamicCommands = append(k.dynamicCommands, &dynamicCommand{ name: name, help: help, diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/resolver.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/resolver.go index 05be7f681aa..dca4309f7ff 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/resolver.go +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/resolver.go @@ -63,6 +63,6 @@ func JSON(r io.Reader) (Resolver, error) { } func snakeCase(name string) string { - name = strings.Join(strings.Split(strings.Title(name), "-"), "") //nolint: staticcheck + name = strings.Join(strings.Split(strings.Title(name), "-"), "") return strings.ToLower(name[:1]) + name[1:] } diff --git a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/tag.go b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/tag.go index 3e37c194908..456f7ae4f89 100644 --- a/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/tag.go +++ b/contrib/tetragon-rthooks/vendor/github.com/alecthomas/kong/tag.go @@ -32,12 +32,13 @@ type Tag struct { Enum string Group string Xor []string + And []string Vars Vars Prefix string // Optional prefix on anonymous structs. All sub-flags will have this prefix. EnvPrefix string Embed bool Aliases []string - Negatable bool + Negatable string Passthrough bool // Storage for all tag keys for arbitrary lookups. @@ -249,14 +250,22 @@ func hydrateTag(t *Tag, typ reflect.Type) error { //nolint: gocyclo for _, xor := range t.GetAll("xor") { t.Xor = append(t.Xor, strings.FieldsFunc(xor, tagSplitFn)...) } + for _, and := range t.GetAll("and") { + t.And = append(t.And, strings.FieldsFunc(and, tagSplitFn)...) + } t.Prefix = t.Get("prefix") t.EnvPrefix = t.Get("envprefix") t.Embed = t.Has("embed") - negatable := t.Has("negatable") - if negatable && !isBool && !isBoolPtr { - return fmt.Errorf("negatable can only be set on booleans") + if t.Has("negatable") { + if !isBool && !isBoolPtr { + return fmt.Errorf("negatable can only be set on booleans") + } + negatable := t.Get("negatable") + if negatable == "" { + negatable = negatableDefault // placeholder for default negation of --no- + } + t.Negatable = negatable } - t.Negatable = negatable aliases := t.Get("aliases") if len(aliases) > 0 { t.Aliases = append(t.Aliases, strings.FieldsFunc(aliases, tagSplitFn)...) diff --git a/contrib/tetragon-rthooks/vendor/modules.txt b/contrib/tetragon-rthooks/vendor/modules.txt index a1450c12a63..faaf604230c 100644 --- a/contrib/tetragon-rthooks/vendor/modules.txt +++ b/contrib/tetragon-rthooks/vendor/modules.txt @@ -1,7 +1,7 @@ # dario.cat/mergo v1.0.0 ## explicit; go 1.13 dario.cat/mergo -# github.com/alecthomas/kong v0.9.0 +# github.com/alecthomas/kong v1.2.1 ## explicit; go 1.18 github.com/alecthomas/kong # github.com/antlr4-go/antlr/v4 v4.13.0