-
Notifications
You must be signed in to change notification settings - Fork 310
/
secrets_flags.pb.go
56 lines (50 loc) · 2.4 KB
/
secrets_flags.pb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Code generated by protoc-gen-go-flags. DO NOT EDIT.
// versions:
// - protoc-gen-go-flags v1.1.0
// - protoc v4.22.2
// source: lorawan-stack/api/secrets.proto
package ttnpb
import (
flagsplugin "github.com/TheThingsIndustries/protoc-gen-go-flags/flagsplugin"
pflag "github.com/spf13/pflag"
)
// AddSelectFlagsForSecret adds flags to select fields in Secret.
func AddSelectFlagsForSecret(flags *pflag.FlagSet, prefix string, hidden bool) {
flags.AddFlag(flagsplugin.NewBoolFlag(flagsplugin.Prefix("key-id", prefix), flagsplugin.SelectDesc(flagsplugin.Prefix("key-id", prefix), false), flagsplugin.WithHidden(hidden)))
flags.AddFlag(flagsplugin.NewBoolFlag(flagsplugin.Prefix("value", prefix), flagsplugin.SelectDesc(flagsplugin.Prefix("value", prefix), false), flagsplugin.WithHidden(hidden)))
}
// SelectFromFlags outputs the fieldmask paths forSecret message from select flags.
func PathsFromSelectFlagsForSecret(flags *pflag.FlagSet, prefix string) (paths []string, err error) {
if val, selected, err := flagsplugin.GetBool(flags, flagsplugin.Prefix("key_id", prefix)); err != nil {
return nil, err
} else if selected && val {
paths = append(paths, flagsplugin.Prefix("key_id", prefix))
}
if val, selected, err := flagsplugin.GetBool(flags, flagsplugin.Prefix("value", prefix)); err != nil {
return nil, err
} else if selected && val {
paths = append(paths, flagsplugin.Prefix("value", prefix))
}
return paths, nil
}
// AddSetFlagsForSecret adds flags to select fields in Secret.
func AddSetFlagsForSecret(flags *pflag.FlagSet, prefix string, hidden bool) {
flags.AddFlag(flagsplugin.NewStringFlag(flagsplugin.Prefix("key-id", prefix), "", flagsplugin.WithHidden(hidden)))
flags.AddFlag(flagsplugin.NewHexBytesFlag(flagsplugin.Prefix("value", prefix), "", flagsplugin.WithHidden(hidden)))
}
// SetFromFlags sets the Secret message from flags.
func (m *Secret) SetFromFlags(flags *pflag.FlagSet, prefix string) (paths []string, err error) {
if val, changed, err := flagsplugin.GetString(flags, flagsplugin.Prefix("key_id", prefix)); err != nil {
return nil, err
} else if changed {
m.KeyId = val
paths = append(paths, flagsplugin.Prefix("key_id", prefix))
}
if val, changed, err := flagsplugin.GetBytes(flags, flagsplugin.Prefix("value", prefix)); err != nil {
return nil, err
} else if changed {
m.Value = val
paths = append(paths, flagsplugin.Prefix("value", prefix))
}
return paths, nil
}