cli

package
v2.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Author = "Ettore Di Giacinto"
View Source
var CreateConfigCMD = cli.Command{
	Name:      "create-config",
	Aliases:   []string{"c"},
	UsageText: "Create a config with a generated network token",

	Usage: "Creates a pristine config file",
	Description: `
		Prints a vanilla YAML configuration on screen which can be used to bootstrap a kairos network.
		`,
	ArgsUsage: "Optionally takes a token rotation interval (seconds)",

	Action: func(c *cli.Context) error {
		l := int(^uint(0) >> 1)
		if c.Args().Present() {
			if i, err := strconv.Atoi(c.Args().Get(0)); err == nil {
				l = i
			}
		}
		cc := &providerConfig.Config{P2P: &providerConfig.P2P{NetworkToken: node.GenerateNewConnectionData(l).Base64()}}
		y, _ := yaml.Marshal(cc)
		fmt.Printf("#cloud-config\n\n%s", string(y))
		return nil
	},
}
View Source
var GenerateTokenCMD = cli.Command{
	Name:      "generate-token",
	Aliases:   []string{"g"},
	UsageText: "Generate a network token",
	Usage:     "Creates a new token",
	Description: `
		Generates a new token which can be used to bootstrap a kairos network.
		`,
	ArgsUsage: "Optionally takes a token rotation interval (seconds)",

	Action: func(c *cli.Context) error {
		l := int(^uint(0) >> 1)
		if c.Args().Present() {
			if i, err := strconv.Atoi(c.Args().Get(0)); err == nil {
				l = i
			}
		}
		fmt.Println(node.GenerateNewConnectionData(l).Base64())
		return nil
	},
}
View Source
var GetKubeConfigCMD = cli.Command{
	Name:      "get-kubeconfig",
	Usage:     "Return a deployment kubeconfig",
	UsageText: "Retrieve a kairos network kubeconfig (only for automated deployments)",
	Description: `
		Retrieve a network kubeconfig and prints out to screen.
		
		If a deployment was bootstrapped with a network token, you can use this command to retrieve the master node kubeconfig of a network id.
		
		For example:
		
		$ kairos get-kubeconfig --network-id kairos
		`,
	Flags: networkAPI,
	Action: func(c *cli.Context) error {
		cc := service.NewClient(
			c.String("network-id"),
			edgeVPNClient.NewClient(edgeVPNClient.WithHost(c.String("api"))))
		str, _ := cc.Get("kubeconfig", "master")
		b, _ := base64.RawURLEncoding.DecodeString(str)
		masterIP, _ := cc.Get("master", "ip")
		fmt.Println(strings.ReplaceAll(string(b), "127.0.0.1", masterIP))
		return nil
	},
}
View Source
var RoleCMD = cli.Command{
	Name:  "role",
	Usage: "Set or list node roles",
	Subcommands: []*cli.Command{
		{
			Flags:     networkAPI,
			Name:      "set",
			Usage:     "Set a node role",
			UsageText: "kairos role set <UUID> master",
			Description: `
		Sets a node role propagating the setting to the network.

		A role must be set prior to the node joining a network. You can retrieve a node UUID by running "kairos uuid".

		Example:

		$ (node A) kairos uuid
		$ (node B) kairos role set <UUID of node A> master
		`,
			Action: func(c *cli.Context) error {
				cc := service.NewClient(
					c.String("network-id"),
					edgeVPNClient.NewClient(edgeVPNClient.WithHost(c.String("api"))))
				return cc.Set("role", c.Args().Get(0), c.Args().Get(1))
			},
		},
		{
			Flags:       networkAPI,
			Name:        "list",
			Description: "List node roles",
			Action: func(c *cli.Context) error {
				cc := service.NewClient(
					c.String("network-id"),
					edgeVPNClient.NewClient(edgeVPNClient.WithHost(c.String("api"))))
				advertizing, _ := cc.AdvertizingNodes()
				fmt.Println("Node\tRole")
				for _, a := range advertizing {
					role, _ := cc.Get("role", a)
					fmt.Printf("%s\t%s\n", a, role)
				}
				return nil
			},
		},
	},
}
View Source
var VERSION = "0.0.0"

do not edit version here, it is set by LDFLAGS -X 'github.com/kairos-io/provider-kairos/v2/internal/cli.VERSION=$VERSION' see Earthlfile.

View Source
var ValidateSchemaCMD = cli.Command{
	Name: "validate",
	Action: func(c *cli.Context) error {
		config := c.Args().First()
		return schema.Validate(config)
	},
	Usage: "Validates a cloud config file",
	Description: `
The validate command expects a configuration file as its only argument. Local files and URLs are accepted.
		`,
}
View Source
var VersionCMD = cli.Command{
	Name: "version",
	Action: func(c *cli.Context) error {
		printVersion()
		return nil
	},
	Description: "Prints version information of this binary",
}

Functions

func BridgeCMD

func BridgeCMD(toolName string) *cli.Command

func RegisterCMD

func RegisterCMD(toolName string) *cli.Command

RegisterCMD is only used temporarily to avoid duplication while the kairosctl sub-command is deprecated.

func Start

func Start() error

func StartRecoveryService

func StartRecoveryService(tk, serviceUUID, generatedPassword, listenAddr string) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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