kuberc

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RecommendedKubeRCFileName       = "kuberc"
	KubeRCOriginalCommandAnnotation = "kubectl.kubernetes.io/original-command"
)

Variables

Functions

func CreateDefaultPreference added in v0.35.0

func CreateDefaultPreference() *v1beta1.Preference

CreateDefaultPreference returns Preference object with some default configurations.

func DefaultGetPreferences

func DefaultGetPreferences(kuberc string, errOut io.Writer) (*config.Preference, error)

DefaultGetPreferences returns KubeRCConfiguration. If users sets kuberc file explicitly in --kuberc flag, it has the highest priority. If not specified, it looks for in KUBERC environment variable. If KUBERC is also not set, it falls back to default .kuberc file at the same location where kubeconfig's defaults are residing in. If KUBERC is set to "off", kuberc will be turned off and original behaviors in kubectl will be applied.

func LoadKuberc added in v0.35.0

func LoadKuberc(kuberc string) (string, bool, error)

LoadKuberc returns the correct kuberc file. Explicitly specified is always highest priority. If it isn't set, KUBERC environment variable is the next choice. If none of them is set, default kuberc location will be used.

func SavePreference added in v0.35.0

func SavePreference(pref *v1beta1.Preference, file string, out io.Writer) error

SavePreference saves the preference to the kuberc file

Types

type Preferences

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

Preferences stores the kuberc file coming either from environment variable or file from set in flag or the default kuberc path.

func (*Preferences) AddFlags

func (p *Preferences) AddFlags(flags *pflag.FlagSet)

AddFlags adds kuberc related flags into the command.

func (*Preferences) Apply

func (p *Preferences) Apply(rootCmd *cobra.Command, kubeConfigFlags *genericclioptions.ConfigFlags, args []string, errOut io.Writer) ([]string, error)

Apply firstly applies the aliases in the preferences file and secondly overrides the default values of flags.

type PreferencesHandler

type PreferencesHandler interface {
	AddFlags(flags *pflag.FlagSet)
	Apply(rootCmd *cobra.Command, kubeConfigFlags *genericclioptions.ConfigFlags, args []string, errOut io.Writer) ([]string, error)
}

PreferencesHandler is responsible for setting default flags arguments based on user's kuberc configuration.

func NewPreferences

func NewPreferences() PreferencesHandler

NewPreferences returns initialized Prefrences object.

Jump to

Keyboard shortcuts

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