clinamespace

package
v3.0.1-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Delete = &cli.Command{
	Name:        "namespace",
	Usage:       "call to delete namespace",
	Description: "delete namespace deletes namespace with name, provided by first arg. Aliases: " + strings.Join(aliases, ", "),
	UsageText:   "chkit delete namespace",
	Aliases:     aliases,
	Flags:       cmdutil.DeleteFlags,
	Action: func(ctx *cli.Context) error {
		logrus.Debugf("running command delete namespace")
		client := cmdutil.GetClient(ctx)
		if ctx.NArg() == 0 {
			logrus.Debugf("show help")
			return cli.ShowSubcommandHelp(ctx)
		}
		namespace := ctx.Args().First()
		logrus.Debugf("deleting namespace %q", namespace)
		err := client.DeleteNamespace(namespace)
		return err
	},
}
View Source
var GetNamespace = &cli.Command{
	Name:        "namespace",
	Aliases:     aliases,
	Description: `shows namespace data or namespace list. Aliases: ` + strings.Join(aliases, ", "),
	Usage:       `shows namespace data or namespace list`,
	UsageText:   "chkit get namespace_name... [-o yaml/json] [-f output_file]",
	Action: func(ctx *cli.Context) error {
		client := cmdutil.GetClient(ctx)
		defer cmdutil.StoreClient(ctx, client)
		var showItem model.Renderer
		var err error

		anime := &animation.Animation{
			Framerate:      0.5,
			ClearLastFrame: true,
			Source:         trasher.NewSilly(),
		}
		go func() {
			time.Sleep(4 * time.Second)
			anime.Run()
		}()

		err = func() error {
			defer anime.Stop()
			switch ctx.NArg() {
			case 1:
				namespaceLabel := ctx.Args().First()
				logrus.Debugf("getting namespace %q", namespaceLabel)
				showItem, err = client.GetNamespace(namespaceLabel)
				if err != nil {
					logrus.WithError(err).Errorf("unable to get namespace %q", namespaceLabel)
					fmt.Printf("Error hile getting namespace %q: %v\n", namespaceLabel, err)
					return err
				}
			default:
				var list namespace.NamespaceList
				logrus.Debugf("getting namespace list")
				list, err := client.GetNamespaceList()
				if err != nil {
					logrus.WithError(err).Errorf("unable to get namespace list")
					return err
				}
				defaultNamespace := cmdutil.GetNamespace(ctx)
				fmt.Printf("Using %q as default namespace\n", defaultNamespace)
				showItem = list
			}
			return nil
		}()
		if err != nil {
			return err
		}
		logrus.Debugf("List recieved")
		err = cmdutil.ExportDataCommand(ctx, showItem)
		if err != nil {
			logrus.Debugf("fatal error: %v", err)
		}
		return err
	},
	Flags: cmdutil.GetFlags,
}

GetNamespace -- commmand 'get' entity data

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