Documentation
¶
Index ¶
- func ClientAndNamespaceFromContext(ctx context.Context) (client kubeclient.Client, namespace string, overridden bool, err error)
- func ForwardedFlags(cmd *cobra.Command, quote func(string) string) []string
- func GetRESTConfig(ctx context.Context) (*rest.Config, error)
- func NamespaceFromContext(ctx context.Context) (string, error)
- func NewContext(ctx context.Context, clientConfig clientcmd.ClientConfig) context.Context
- func ShellEscape(s string) string
- func ShellQuote(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForwardedFlags ¶ added in v1.11.1
ForwardedFlags returns the `--name=value` tokens for the cluster-selection flags the user set on cmd. Each value goes through quote, so the caller picks the escaping its embedding needs.
func NamespaceFromContext ¶ added in v1.11.1
NamespaceFromContext returns the namespace from the active kubeconfig context.
func NewContext ¶
NewContext returns a new Context that stores a clientConfig as value.
func ShellEscape ¶ added in v1.11.1
ShellEscape backslash-escapes every character /bin/sh would otherwise interpret. Use it instead of ShellQuote where single quotes are already taken by an enclosing layer, as in the ansible_ssh_common_args value.
That value is re-parsed twice: ansible splits it with shlex, then ssh hands the ProxyCommand to /bin/sh. shlex keeps a backslash literal inside single quotes, which is what makes the plain escaping work for every other character. A single quote is the exception: it closes the quoted run no matter what precedes it, so it has to leave the run, arrive at /bin/sh as \' and reopen the run afterwards.
func ShellQuote ¶ added in v1.11.1
ShellQuote single-quotes s so it survives being re-parsed by /bin/sh, which runs the ProxyCommand.
Types ¶
This section is empty.