Documentation ¶
Index ¶
- Constants
- Variables
- func AddCleanFlags(cmd *cobra.Command)
- func BehaviorOnFatal(f func(string, int))
- func CheckDiffErr(err error)
- func CheckErr(err error)
- func CombineRequestErr(resp gorequest.Response, body string, errs []error) error
- func DefaultBehaviorOnFatal()
- func DefaultSubCommandRun(out io.Writer) func(c *cobra.Command, args []string)
- func GetFlagBool(cmd *cobra.Command, flag string) bool
- func GetFlagDuration(cmd *cobra.Command, flag string) time.Duration
- func GetFlagInt(cmd *cobra.Command, flag string) int
- func GetFlagInt32(cmd *cobra.Command, flag string) int32
- func GetFlagInt64(cmd *cobra.Command, flag string) int64
- func GetFlagString(cmd *cobra.Command, flag string) string
- func GetFlagStringArray(cmd *cobra.Command, flag string) []string
- func GetFlagStringSlice(cmd *cobra.Command, flag string) []string
- func IsFilenameSliceEmpty(filenames []string, directory string) bool
- func IsSiblingCommandExists(cmd *cobra.Command, targetCmdName string) bool
- func ManualStrip(file []byte) []byte
- func MultilineError(prefix string, err error) string
- func MultipleErrors(prefix string, errs []error) string
- func NewForConfigOrDie() *marmotedu.Clientset
- func RequireNoArguments(c *cobra.Command, args []string)
- func StandardErrorMessage(err error) (string, bool)
- func TableWriterDefaultConfig(table *tablewriter.Table) *tablewriter.Table
- func UsageErrorf(cmd *cobra.Command, format string, args ...interface{}) error
- func Warning(cmdErr io.Writer, newGeneratorName, oldGeneratorName string)
- type Factory
- type MatchVersionFlags
- type ValidateOptions
Constants ¶
const (
// DefaultErrorExitCode defines the default exit code.
DefaultErrorExitCode = 1
)
Variables ¶
var ErrExit = fmt.Errorf("exit")
ErrExit may be passed to CheckError to instruct it to output nothing but exit with status code 1.
Functions ¶
func BehaviorOnFatal ¶
BehaviorOnFatal allows you to override the default behavior when a fatal error occurs, which is to call os.Exit(code). You can pass 'panic' as a function here if you prefer the panic() over os.Exit(1).
func CheckDiffErr ¶
func CheckDiffErr(err error)
CheckDiffErr prints a user-friendly error to STDERR and exits with a non-zero and non-one exit code. Unrecognized errors will be printed with an "error: " prefix.
This method is meant specifically for `iamctl diff` and may be used by other commands.
func CheckErr ¶
func CheckErr(err error)
CheckErr prints a user-friendly error to STDERR and exits with a non-zero exit code. Unrecognized errors will be printed with an "error: " prefix.
This method is generic to the command in use and may be used by non-IAM commands.
func CombineRequestErr ¶
CombineRequestErr combines the http response error and error in errs array.
func DefaultBehaviorOnFatal ¶
func DefaultBehaviorOnFatal()
DefaultBehaviorOnFatal allows you to undo any previous override. Useful in tests.
func DefaultSubCommandRun ¶
DefaultSubCommandRun prints a command's help string to the specified output if no arguments (sub-commands) are provided, or a usage error otherwise.
func GetFlagBool ¶
GetFlagBool returns the value of the given flag.
func GetFlagDuration ¶
GetFlagDuration return the value of the given flag.
func GetFlagInt ¶
GetFlagInt returns the value of the given flag.
func GetFlagInt32 ¶
GetFlagInt32 returns the value of the given flag.
func GetFlagInt64 ¶
GetFlagInt64 returns the value of the given flag.
func GetFlagString ¶
GetFlagString returns the value of the given flag.
func GetFlagStringArray ¶
GetFlagStringArray can be used to accept multiple argument with flag repetition (e.g. -f arg1 -f arg2 ...).
func GetFlagStringSlice ¶
GetFlagStringSlice can be used to accept multiple argument with flag repetition (e.g. -f arg1,arg2 -f arg3 ...).
func IsFilenameSliceEmpty ¶
IsFilenameSliceEmpty checkes where filenames and directory are both zero value.
func IsSiblingCommandExists ¶
IsSiblingCommandExists receives a pointer to a cobra command and a target string. Returns true if the target string is found in the list of sibling commands.
func ManualStrip ¶
ManualStrip is used for dropping comments from a YAML file.
func MultilineError ¶
MultilineError returns a string representing an error that splits sub errors into their own lines. The returned string will end with a newline.
func MultipleErrors ¶
MultipleErrors returns a newline delimited string containing the prefix and referenced errors in standard form.
func NewForConfigOrDie ¶
func RequireNoArguments ¶
RequireNoArguments exits with a usage error if extra arguments are provided.
func StandardErrorMessage ¶
StandardErrorMessage translates common errors into a human readable message, or returns false if the error is not one of the recognized types. It may also log extended information to klog.
This method is generic to the command in use and may be used by non-IAM commands.
func TableWriterDefaultConfig ¶
func TableWriterDefaultConfig(table *tablewriter.Table) *tablewriter.Table
func UsageErrorf ¶
UsageErrorf returns error with command path.
Types ¶
type Factory ¶
type Factory interface { genericclioptions.RESTClientGetter // IAMClient gives you back an external iamclient IAMClient() (*iam.IamClient, error) // Returns a RESTClient for accessing IAM resources or an error. RESTClient() (*restclient.RESTClient, error) }
Factory provides abstractions that allow the IAM command to be extended across multiple types of resources and different API sets. The rings are here for a reason. In order for composers to be able to provide alternative factory implementations they need to provide low level pieces of *certain* functions so that when the factory calls back into itself it uses the custom version of the function. Rather than try to enumerate everything that someone would want to override we split the factory into rings, where each ring can depend on methods in an earlier ring, but cannot depend upon peer methods in its own ring. TODO: make the functions interfaces TODO: pass the various interfaces on the factory directly into the command constructors (so the commands are decoupled from the factory).
func NewFactory ¶
func NewFactory(clientGetter genericclioptions.RESTClientGetter) Factory
type MatchVersionFlags ¶
type MatchVersionFlags struct { Delegate genericclioptions.RESTClientGetter RequireMatchedServerVersion bool // contains filtered or unexported fields }
MatchVersionFlags is for setting the "match server version" function.
func NewMatchVersionFlags ¶
func NewMatchVersionFlags(delegate genericclioptions.RESTClientGetter) *MatchVersionFlags
func (*MatchVersionFlags) AddFlags ¶
func (f *MatchVersionFlags) AddFlags(flags *pflag.FlagSet)
func (*MatchVersionFlags) ToRESTConfig ¶
func (f *MatchVersionFlags) ToRESTConfig() (*rest.Config, error)
ToRESTConfig implements RESTClientGetter. Returns a REST client configuration based on a provided path to a .iamconfig file, loading rules, and config flag overrides. Expects the AddFlags method to have been called.
func (*MatchVersionFlags) ToRawIAMConfigLoader ¶
func (f *MatchVersionFlags) ToRawIAMConfigLoader() clientcmd.ClientConfig
type ValidateOptions ¶
type ValidateOptions struct {
EnableValidation bool
}
ValidateOptions defines the validate options.