util

package
v3.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddField added in v3.12.0

func AddField(fs *pflag.FlagSet, name string, t reflect.Type, maskOnly bool)

AddField adds a field to the flag set.

func DeprecateFlag

func DeprecateFlag(flagSet *pflag.FlagSet, old string, new string)

DeprecateFlag deprecates a CLI flag.

func FieldFlags

func FieldFlags(v interface{}, prefix ...string) *pflag.FlagSet

func FieldMaskFlags

func FieldMaskFlags(v interface{}, prefix ...string) *pflag.FlagSet

func ForwardFlag

func ForwardFlag(flagSet *pflag.FlagSet, old string, new string)

ForwardFlag forwards the flag value of old to new if new is not set while old is.

func HideFlag added in v3.12.0

func HideFlag(flagSet *pflag.FlagSet, name string)

HideFlag hides the provided flag from the flag set.

func HideFlagSet added in v3.12.0

func HideFlagSet(flagSet *pflag.FlagSet) *pflag.FlagSet

HideFlagSet hides the flags from the provided flag set.

func NormalizeFlags

func NormalizeFlags(f *pflag.FlagSet, name string) pflag.NormalizedName

func NormalizePaths

func NormalizePaths(paths []string) []string

NormalizePaths converts arguments to field mask paths, replacing '-' with '_'

func SaveAuthCache

func SaveAuthCache(cache AuthCache) (err error)

SaveAuthCache saves the auth cache to the cache file.

func SelectAllFlagSet

func SelectAllFlagSet(what string) *pflag.FlagSet

SelectAllFlagSet returns a flagset with the --all flag

func SelectFieldMask

func SelectFieldMask(cmdFlags *pflag.FlagSet, fieldMaskFlags ...*pflag.FlagSet) (paths []string)

func SetFields

func SetFields(dst interface{}, flags *pflag.FlagSet, prefix ...string) error

func UnsetFlagSet

func UnsetFlagSet() *pflag.FlagSet

UnsetFlagSet returns a flagset with the --unset flag

func UpdateFieldMask

func UpdateFieldMask(cmdFlags *pflag.FlagSet, fieldMaskFlags ...*pflag.FlagSet) (paths []string)

Types

type AuthCache

type AuthCache struct {
	// contains filtered or unexported fields
}

AuthCache stores auth for the CLI.

func GetAuthCache

func GetAuthCache() (cache AuthCache, err error)

GetAuthCache gets the auth cache form the cache file.

func (AuthCache) ForID

func (c AuthCache) ForID(id string) AuthCache

ForID returns the auth cache for the given ID.

func (*AuthCache) Get

func (c *AuthCache) Get(key string) interface{}

Get gets a key from the auth cache.

func (*AuthCache) Set

func (c *AuthCache) Set(key string, value interface{})

Set sets keys in the auth cache.

func (*AuthCache) Unset

func (c *AuthCache) Unset(keys ...string)

Unset unsets keys in the auth cache.

type AuthData

type AuthData struct {
	OAuthToken *oauth2.Token          `json:"oauth_token,omitempty"`
	APIKey     string                 `json:"api_key,omitempty"`
	Hosts      []string               `json:"hosts,omitempty"`
	Other      map[string]interface{} `json:"other,omitempty"`
}

AuthData is the stored auth data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL