Documentation ¶
Index ¶
- Constants
- Variables
- func AddApplyAnnotationFlags(cmd *cobra.Command)
- func AddApplyAnnotationVarFlags(cmd *cobra.Command, applyAnnotation *bool)
- func AddDryRunFlag(cmd *cobra.Command)
- func AddFilenameOptionFlags(cmd *cobra.Command, options *resource.FilenameOptions, usage string)
- func AddGeneratorFlags(cmd *cobra.Command, defaultGenerator string)
- func AddIncludeUninitializedFlag(cmd *cobra.Command)
- func AddJsonFilenameFlag(flags *pflag.FlagSet, value *[]string, usage string)
- func AddKustomizeFlag(flags *pflag.FlagSet, value *string)
- func AddPodRunningTimeoutFlag(cmd *cobra.Command, defaultTimeout time.Duration)
- func AddServerSideApplyFlags(cmd *cobra.Command)
- func AddSourceToErr(verb string, source string, err error) error
- func AddValidateFlags(cmd *cobra.Command)
- func AddValidateOptionFlags(cmd *cobra.Command, options *ValidateOptions)
- func BehaviorOnFatal(f func(string, int))
- func BytesToString(bytes []byte) (s string)
- func CheckErr(err error)
- func DefaultBehaviorOnFatal()
- func DefaultSubCommandRun(out io.Writer) func(c *cobra.Command, args []string)
- func DumpReaderToFile(reader io.Reader, filename string) error
- func GetCurrentCluster() (string, error)
- func GetDryRunFlag(cmd *cobra.Command) bool
- func GetFieldManagerFlag(cmd *cobra.Command) 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 GetForceConflictsFlag(cmd *cobra.Command) bool
- func GetPodRunningTimeoutFlag(cmd *cobra.Command) (time.Duration, error)
- func GetResourcesAndPairs(args []string, pairType string) (resources []string, pairArgs []string, err error)
- func GetServerSideApplyFlag(cmd *cobra.Command) bool
- func IsFilenameSliceEmpty(filenames []string, directory string) bool
- func IsSiblingCommandExists(cmd *cobra.Command, targetCmdName string) bool
- func ManualStrip(file []byte) []byte
- func Merge(codec runtime.Codec, dst runtime.Object, fragment string) (runtime.Object, error)
- func MultilineError(prefix string, err error) string
- func MultipleErrors(prefix string, errs []error) string
- func NewCmdCluster() *cobra.Command
- func NewCmdCompletion() *cobra.Command
- func NewCmdConfig() *cobra.Command
- func NewCmdConfigDelete() *cobra.Command
- func NewCmdConfigInit() *cobra.Command
- func NewCmdConfigUpdate() *cobra.Command
- func NewCmdContext() *cobra.Command
- func NewCmdGet() *cobra.Command
- func NewCmdGetCluster() *cobra.Command
- func NewCmdGetClusterRole() *cobra.Command
- func NewCmdGetClusterRoleBinding() *cobra.Command
- func NewCmdGetConfigMap() *cobra.Command
- func NewCmdGetDeployment() *cobra.Command
- func NewCmdGetIngress() *cobra.Command
- func NewCmdGetNode() *cobra.Command
- func NewCmdGetPod() *cobra.Command
- func NewCmdGetRole() *cobra.Command
- func NewCmdGetRolebinding() *cobra.Command
- func NewCmdGetSecret() *cobra.Command
- func NewCmdGetService() *cobra.Command
- func NewCmdGetServiceAccount() *cobra.Command
- func NewCmdInitCluster() *cobra.Command
- func NewCmdInspect() *cobra.Command
- func NewCmdInspectNode() *cobra.Command
- func NewCmdNamespace() *cobra.Command
- func NewCmdPortForward() *cobra.Command
- func NewCmdSearch() *cobra.Command
- func NewCmdSearchLabel() *cobra.Command
- func NewCmdVersion() *cobra.Command
- func NewKubenxCommand(out, err io.Writer) *cobra.Command
- func ParsePairs(pairArgs []string, pairType string, supportRemove bool) (newPairs map[string]string, removePairs []string, err error)
- func PrintErrorWithCauses(err error, errOut io.Writer) bool
- func RequireNoArguments(c *cobra.Command, args []string)
- func RunCompletion(out io.Writer, boilerPlate string, cmd *cobra.Command, args []string) error
- func SetCommandFlags(cmd *cobra.Command)
- func StandardErrorMessage(err error) (string, bool)
- func StringToBytes(str string) []byte
- func StripComments(file []byte) []byte
- func UsageErrorf(cmd *cobra.Command, format string, args ...interface{}) error
- func Warning(cmdErr io.Writer, newGeneratorName, oldGeneratorName string)
- type Bastion
- type Builder
- type Executor
- type Flag
- type PortForwardAPodRequest
- type SSHClient
- type SSHConfig
- type ScaleClientFunc
- type Server
- type TerminalConfig
- type ValidateOptions
Constants ¶
const ( ApplyAnnotationsFlag = "save-config" DefaultErrorExitCode = 1 )
Variables ¶
var ( ALL_NAMESPACE = "" NO_STRING = "" DEFAULT_NODE_LABEL_FILTERS = []string{"app", "env"} //STATIS VALUE KUBENX_HOMEDIR = ".kubenx" SSH_DEFAULT_PATH = "ssh" TARGET_DEFAULT_PORT = "22" AWS_IAM_ANNOTATION = "eks.amazonaws.com/role-arn" AUTH_API_VERSION = "client.authentication.k8s.io/v1alpha1" AUTH_COMMAND = "aws" //Color Definition Red = color.New(color.FgRed).PrintlnFunc() Blue = color.New(color.FgBlue).PrintlnFunc() Green = color.New(color.FgGreen).PrintlnFunc() Yellow = color.New(color.FgYellow).PrintlnFunc() Cyan = color.New(color.FgCyan).PrintlnFunc() //OPEN_ID_CA_FINGERPRINT CA_FINGERPRINT = "9e99a48a9960b14926bb7f3b02e22da2b0ab7280" //Error Message NO_FILE_EXCEPTION = "No file exists... Please check the file path" )
var ErrExit = fmt.Errorf("exit")
ErrExit may be passed to CheckError to instruct it to output nothing but exit with status code 1.
var FlagRegistry = []Flag{ { Name: "namespace", Shorthand: "n", Usage: "Run deployments in the specified namespace", Value: aws.String(NO_STRING), DefValue: "", FlagAddMethod: "StringVar", DefinedOn: []string{"pod", "deployment", "service", "serviceaccount", "configmap", "ingress", "role", "rolebinding", "secret"}, }, { Name: "region", Shorthand: "r", Usage: "Run command to specific region", Value: aws.String(NO_STRING), DefValue: "ap-northeast-2", FlagAddMethod: "StringVar", DefinedOn: []string{"cluster", "init", "update"}, }, { Name: "all", Shorthand: "A", Usage: "All namespace flag", Value: aws.Bool(false), DefValue: false, FlagAddMethod: "BoolVar", DefinedOn: []string{"pod", "deployment", "service", "serviceaccount", "configmap", "ingress", "role", "clusterrole", "rolebinding", "clusterrolebinding", "secret"}, }, }
FlagRegistry is a list of all Skaffold CLI flags. When adding a new flag to the registry, please specify the command/commands to which the flag belongs in `DefinedOn` field. If the flag is a global flag, or belongs to all the subcommands, / specify "all" FlagAddMethod is method which defines a flag value with specified name, default value, and usage string. e.g. `StringVar`, `BoolVar`
var (
TAG_PREFIX = "kubernetes"
)
Functions ¶
func AddApplyAnnotationFlags ¶
func AddDryRunFlag ¶
AddDryRunFlag adds dry-run flag to a command. Usually used by mutations.
func AddFilenameOptionFlags ¶
func AddFilenameOptionFlags(cmd *cobra.Command, options *resource.FilenameOptions, usage string)
func AddGeneratorFlags ¶
AddGeneratorFlags adds flags common to resource generation commands TODO: need to take a pass at other generator commands to use this set of flags
func AddJsonFilenameFlag ¶
func AddKustomizeFlag ¶
AddKustomizeFlag adds kustomize flag to a command
func AddServerSideApplyFlags ¶
func AddSourceToErr ¶
AddSourceToErr adds handleResourcePrefix and source string to error message. verb is the string like "creating", "deleting" etc. source is the filename or URL to the template file(*.json or *.yaml), or stdin to use to handle the resource.
func AddValidateFlags ¶
func AddValidateOptionFlags ¶
func AddValidateOptionFlags(cmd *cobra.Command, options *ValidateOptions)
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 BytesToString ¶
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-Kubectl commands.
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 DumpReaderToFile ¶
DumpReaderToFile writes all data from the given io.Reader to the specified file (usually for temporary use).
func GetDryRunFlag ¶
func GetFieldManagerFlag ¶
func GetFlagInt ¶
Assumes the flag has a default value.
func GetFlagInt32 ¶
Assumes the flag has a default value.
func GetFlagInt64 ¶
Assumes the flag has a default value.
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 GetForceConflictsFlag ¶
func GetResourcesAndPairs ¶
func GetResourcesAndPairs(args []string, pairType string) (resources []string, pairArgs []string, err error)
GetResourcesAndPairs retrieves resources and "KEY=VALUE or KEY-" pair args from given args
func GetServerSideApplyFlag ¶
func IsFilenameSliceEmpty ¶
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 Merge ¶
Merge requires JSON serialization TODO: merge assumes JSON serialization, and does not properly abstract API retrieval
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 NewCmdGetClusterRole ¶
Create Command for get cluster role
func NewCmdGetClusterRoleBinding ¶
Create Command for get cluster role
func NewCmdGetServiceAccount ¶
Create Command for get pod
func NewKubenxCommand ¶
Get New Kubenx Command
func ParsePairs ¶
func ParsePairs(pairArgs []string, pairType string, supportRemove bool) (newPairs map[string]string, removePairs []string, err error)
ParsePairs retrieves new and remove pairs (if supportRemove is true) from "KEY=VALUE or KEY-" pair args
func PrintErrorWithCauses ¶
PrintErrorWithCauses prints an error's kind, name, and each of the error's causes in a new line. The returned string will end with a newline. Returns true if a case exists to handle the error type, or false otherwise.
func RequireNoArguments ¶
RequireNoArguments exits with a usage error if extra arguments are provided.
func RunCompletion ¶
RunCompletion checks given arguments and executes command
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-Kubectl commands.
func StringToBytes ¶
func StripComments ¶
StripComments will transform a YAML file into JSON, thus dropping any comments in it. Note that if the given file has a syntax error, the transformation will fail and we will manually drop all comments from the file.
Types ¶
type Builder ¶
type Builder interface { WithDescription(description string) Builder WithLongDescription(description string) Builder SetAliases(alias []string) Builder AddCommand(cmd *cobra.Command) Builder AddGetGroups() Builder AddSearchGroups() Builder AddInspectGroups() Builder AddConfigGroups() Builder SetFlags() Builder RunWithNoArgs(action func(context.Context, io.Writer) error) *cobra.Command RunWithArgs(action func(context.Context, io.Writer, []string) error) *cobra.Command RunWithArgsAndCmd(action func(context.Context, io.Writer, *cobra.Command, []string) error) *cobra.Command }
type Flag ¶
type Flag struct { Name string Shorthand string Usage string Value interface{} DefValue interface{} DefValuePerCommand map[string]interface{} FlagAddMethod string DefinedOn []string Hidden bool // contains filtered or unexported fields }
This part of code comes from skaffold opensource. https://github.com/GoogleContainerTools/skaffold Flag defines a Skaffold CLI flag which contains a list of subcommands the flag belongs to in `DefinedOn` field.
type PortForwardAPodRequest ¶
type PortForwardAPodRequest struct { // RestConfig is the kubernetes config RestConfig *rest.Config // Pod is the selected pod for this port forwarding Pod corev1.Pod // LocalPort is the local port that will be selected to expose the PodPort LocalPort int // PodPort is the target port for the pod PodPort int // Steams configures where to write or read input from Streams genericclioptions.IOStreams // StopCh is the channel used to manage the port forward lifecycle StopCh <-chan struct{} // ReadyCh communicates when the tunnel is ready to receive traffic ReadyCh chan struct{} }
Port Forward Request
type SSHClient ¶
type SSHClient struct {
// contains filtered or unexported fields
}
SSH Client Configuration
func (*SSHClient) Terminal ¶
func (c *SSHClient) Terminal(config *TerminalConfig) *remoteShell
Terminal create a interactive shell on client.
type SSHConfig ¶
type SSHConfig struct {
// contains filtered or unexported fields
}
SSH Configuration
type ScaleClientFunc ¶
type ScaleClientFunc func(genericclioptions.RESTClientGetter) (scale.ScalesGetter, error)
ScaleClientFunc provides a ScalesGetter
var ScaleClientFn ScaleClientFunc = scaleClient
ScaleClientFn gives a way to easily override the function for unit testing if needed.
type Server ¶
type Server struct { Key string `json:"key"` Addr string `json:"addr"` Port string `json:"port"` User string `json:"user"` KeyFile string `json:"keyfile"` }
Server Configuration
type TerminalConfig ¶
type TerminalConfig struct { Term string Height int Weight int Modes ssh.TerminalModes }
Terminal Configuration
type ValidateOptions ¶
type ValidateOptions struct {
EnableValidation bool
}
Source Files ¶
- builder.go
- cluster.go
- clusterrole.go
- clusterrolebinding.go
- cmd.go
- common.go
- completion.go
- config.go
- configmaps.go
- context.go
- deployment.go
- executor.go
- flags.go
- get.go
- helper.go
- ingress.go
- inspect.go
- internal_autoscaling.go
- internal_ec2.go
- internal_eks.go
- internal_k8s.go
- list.go
- namespace.go
- node.go
- nodegroup.go
- pod.go
- role.go
- rolebinding.go
- search.go
- secrets.go
- service.go
- serviceaccount.go
- ssh.go
- version.go