criocli

package
v1.29.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigCommand = &cli.Command{
	Name: "config",
	Usage: `Outputs a commented version of the configuration file that could be used
by CRI-O. This allows you to save you current configuration setup and then load
it later with **--config**. Global options will modify the output.`,
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:  "default",
			Usage: "Output the default configuration (without taking into account any configuration options).",
		},
		&cli.StringFlag{
			Name:        "migrate-defaults",
			Aliases:     []string{"m"},
			Destination: &from,
			Usage: fmt.Sprintf(`Migrate the default config from a specified version.

    The migrate-defaults command has been deprecated and will be removed in the future.

    To run a config migration, just select the input config via the global
    '--config,-c' command line argument, for example:
    `+mdSep+`
    crio -c /etc/crio/crio.conf.d/00-default.conf config -m 1.17
    `+mdSep+`
    The migration will print converted configuration options to stderr and will
    output the resulting configuration to stdout.
    Please note that the migration will overwrite any fields that have changed
    defaults between versions. To save a custom configuration change, it should
    be in a drop-in configuration file instead.
    Possible values: %q`, migrate.From1_17),
			Value: migrate.FromPrevious,
		},
	},
	Action: func(c *cli.Context) error {
		logrus.SetFormatter(&logrus.TextFormatter{
			DisableTimestamp: true,
		})
		logrus.SetLevel(logrus.InfoLevel)

		conf, err := GetConfigFromContext(c)
		if err != nil {
			return err
		}

		if c.Bool("default") {
			conf, err = config.DefaultConfig()
			if err != nil {
				return err
			}
		}

		if c.IsSet("migrate-defaults") {
			logrus.Infof("Migrating config from %s", from)
			logrus.Warn("Config migration has been deprecated and will be removed in the future.")
			if err := migrate.Config(conf, from); err != nil {
				return fmt.Errorf("migrate config: %w", err)
			}
		}

		if err = conf.Validate(false); err != nil {
			return err
		}

		return conf.WriteTemplate(c.Bool("default"), os.Stdout)
	},
}
View Source
var DefaultCommands = []*cli.Command{
	completion(),
	man(),
	markdown(),
}

DefaultCommands are the flags commands can be added to every binary

View Source
var PublishCommand = &cli.Command{
	Name:  "publish",
	Usage: "receive shimv2 events",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:   "topic",
			Hidden: true,
		},
		&cli.StringFlag{
			Name:   "namespace",
			Hidden: true,
		},
	},
	HideHelp: true,
	Hidden:   true,
	Action: func(c *cli.Context) error {
		return nil
	},
}
View Source
var StatusCommand = &cli.Command{
	Name:  "status",
	Usage: "Display status information",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:      socketArg,
			Aliases:   []string{"s"},
			Usage:     "absolute path to the unix socket",
			Value:     defaultSocket,
			TakesFile: true,
		},
	},
	OnUsageError: func(c *cli.Context, e error, b bool) error { return e },
	Subcommands: []*cli.Command{{
		Action:  configSubCommand,
		Aliases: []string{"c"},
		Name:    "config",
		Usage:   "Show the configuration of CRI-O as a TOML string.",
	}, {
		Action:  containers,
		Aliases: []string{"container", "cs", "s"},
		Flags: []cli.Flag{&cli.StringFlag{
			Name:    idArg,
			Aliases: []string{"i"},
			Usage:   "the container ID",
		}},
		Name:  "containers",
		Usage: "Display detailed information about the provided container ID.",
	}, {
		Action:  info,
		Aliases: []string{"i"},
		Name:    "info",
		Usage:   "Retrieve generic information about CRI-O, such as the cgroup and storage driver.",
	}},
}
View Source
var VersionCommand = &cli.Command{
	Name:  "version",
	Usage: "display detailed version information",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    jsonFlag,
			Aliases: []string{"j"},
			Usage:   "print JSON instead of text",
		},
		&cli.BoolFlag{
			Name:    verboseFlag,
			Aliases: []string{"v"},
			Usage:   "print verbose information (for example all golang dependencies)",
		},
	},
	Action: func(c *cli.Context) error {
		verbose := c.Bool(verboseFlag)
		v, err := version.Get(verbose)
		if err != nil {
			logrus.Fatal(err)
		}
		res := v.String()
		if c.Bool(jsonFlag) {
			j, err := v.JSONString()
			if err != nil {
				return fmt.Errorf("unable to generate JSON from version info: %w", err)
			}
			res = j

		}
		fmt.Println(res)
		return nil
	},
}
View Source
var WipeCommand = &cli.Command{
	Name:   "wipe",
	Usage:  "wipe CRI-O's container and image storage",
	Action: crioWipe,
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "force",
			Aliases: []string{"f"},
			Usage:   "force wipe by skipping the version check",
		},
	},
}

Functions

func GetAndMergeConfigFromContext added in v1.18.2

func GetAndMergeConfigFromContext(c *cli.Context) (*libconfig.Config, error)

func GetConfigFromContext

func GetConfigFromContext(c *cli.Context) (*libconfig.Config, error)

func GetFlagsAndMetadata

func GetFlagsAndMetadata() ([]cli.Flag, map[string]interface{}, error)

func StringSliceTrySplit added in v1.18.1

func StringSliceTrySplit(ctx *cli.Context, name string) []string

StringSliceTrySplit parses the string slice from the CLI context. If the parsing returns just a single item, then we try to parse them by `,` to allow users to provide their flags comma separated.

Types

type ContainerStore added in v1.28.0

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

Jump to

Keyboard shortcuts

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