split

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cli.Command{
	Name:      "split",
	Usage:     "split a kubeconfig into separated context pieces",
	ArgsUsage: "[PREFIX]",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "kubeconfig",
			Usage: "path to kubeconfig you wish to split",
		},
		&cli.StringFlag{
			Name:        "additional-suffix",
			Usage:       "append an additional SUFFIX to file names",
			DefaultText: "",
		},
		&cli.BoolFlag{
			Name:    "numeric-suffixes",
			Aliases: []string{"d"},
			Usage:   "Use 2 digit numeric as suffix, not a context name",
		},
	},

	Action: func(cCtx *cli.Context) error {
		kc, err := kconf.Open(cCtx.String("kubeconfig"))
		if err != nil {
			return err
		}

		splitted := kc.Split()

		for i := range splitted {
			fileName := createFileName(i, splitted[i], cCtx)
			splitted[i].SaveAs(fileName)
			fmt.Fprintf(os.Stdout, "%s\n", fileName)
			if err != nil {
				return err
			}
		}

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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