// DynStringSet creates a `Flag` that represents `map[string]struct{}` which is safe to change dynamically at runtime. // Unlike `pflag.StringSlice`, consecutive sets don't append to the slice, but override it. func DynStringSet(flagSet *flag.FlagSet, name string, value []string, usage string) *DynStringSetValue { set := buildStringSet(value) dynValue := &DynStringSetValue{ptr: unsafe.Pointer(&set)} flag := flagSet.VarPF(dynValue, name, "", usage) MarkFlagDynamic(flag) return dynValue }
func InstallDeprecatedSkipVerify(flagset *pflag.FlagSet, flags *SecFlags) { sv := &skipVerify{ flags: flags, } svFlag := flagset.VarPF(sv, "insecure-skip-verify", "", "DEPRECATED") svFlag.DefValue = "false" svFlag.NoOptDefVal = "true" svFlag.Hidden = true svFlag.Deprecated = "please use --insecure-options." }
// DynProto3 creates a `Flag` that is backed by an arbitrary Proto3-generated datastructure which is safe to change // dynamically at runtime either through JSONPB encoding or Proto encoding. // The `value` must be a pointer to a struct that is JSONPB/Proto (un)marshallable. // New values based on the default constructor of `value` type will be created on each update. func DynProto3(flagSet *flag.FlagSet, name string, value proto.Message, usage string) *DynProto3Value { reflectVal := reflect.ValueOf(value) if reflectVal.Kind() != reflect.Ptr || reflectVal.Elem().Kind() != reflect.Struct { panic("DynJSON value must be a pointer to a struct") } dynValue := &DynProto3Value{ptr: unsafe.Pointer(reflectVal.Pointer()), structType: reflectVal.Type().Elem()} flag := flagSet.VarPF(dynValue, name, "", usage) flagz.MarkFlagDynamic(flag) return dynValue }
// DynFloat64 creates a `Flag` that represents `float64` which is safe to change dynamically at runtime. func DynFloat64(flagSet *flag.FlagSet, name string, value float64, usage string) *DynFloat64Value { dynValue := &DynFloat64Value{ptr: unsafe.Pointer(&value)} flag := flagSet.VarPF(dynValue, name, "", usage) MarkFlagDynamic(flag) return dynValue }
// DynInt64 creates a `Flag` that represents `int64` which is safe to change dynamically at runtime. func DynInt64(flagSet *flag.FlagSet, name string, value int64, usage string) *DynInt64Value { dynValue := &DynInt64Value{ptr: &value} flag := flagSet.VarPF(dynValue, name, "", usage) MarkFlagDynamic(flag) return dynValue }
// DynDuration creates a `Flag` that represents `time.Duration` which is safe to change dynamically at runtime. func DynDuration(flagSet *flag.FlagSet, name string, value time.Duration, usage string) *DynDurationValue { dynValue := &DynDurationValue{ptr: (*int64)(&value)} flag := flagSet.VarPF(dynValue, name, "", usage) MarkFlagDynamic(flag) return dynValue }
// DynStringSlice creates a `Flag` that represents `[]string` which is safe to change dynamically at runtime. // Unlike `pflag.StringSlice`, consecutive sets don't append to the slice, but override it. func DynStringSlice(flagSet *flag.FlagSet, name string, value []string, usage string) *DynStringSliceValue { dynValue := &DynStringSliceValue{ptr: unsafe.Pointer(&value)} flag := flagSet.VarPF(dynValue, name, "", usage) MarkFlagDynamic(flag) return dynValue }