clinamespace

package
v3.0.2+incompatible Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Delete = &cobra.Command{
	Use:     "namespace",
	Short:   "call to delete namespace",
	Long:    "delete namespace deletes namespace with name, provided by first arg. Aliases: " + strings.Join(aliases, ", "),
	Example: "chkit delete namespace _label_",
	Aliases: aliases,
	Run: func(command *cobra.Command, args []string) {
		logrus.WithFields(logrus.Fields{
			"command": "delete namespace",
		}).Debugf("getting namespace data")
		if len(args) == 0 {
			logrus.Debugf("showing help")
			command.Help()
			return
		}
		ns := args[0]
		err := func() error {
			if !deleteNamespaceConfig.Force {
				yes, _ := activekit.Yes(fmt.Sprintf("Do you want to delete namespace %q?", ns))
				if !yes {
					return nil
				}
			}
			logrus.Debugf("deleting namespace %q", ns)
			return context.GlobalContext.Client.DeleteNamespace(ns)
		}()
		if err != nil {
			logrus.WithError(err).Errorf("unable to delete namespace %q", ns)
			fmt.Printf("Unable to delete namespace :(\n%v", err)
			return
		}
		fmt.Printf("Namespace %q deleted\n", ns)
	},
}
View Source
var Get = &cobra.Command{
	Use:     "namespace",
	Aliases: aliases,
	Short:   `shows namespace data or namespace list`,
	Long:    `shows namespace data or namespace list. Aliases: ` + strings.Join(aliases, ", "),
	Example: "chkit get namespace_name... [-o yaml/json] [-f output_file]",
	Run: func(command *cobra.Command, args []string) {
		logrus.WithFields(logrus.Fields{
			"command": "get namespace",
		}).Debug("getting namespace data")
		nsData, err := func() (model.Renderer, error) {
			switch len(args) {
			case 1:
				namespaceLabel := args[0]
				logrus.Debugf("getting namespace %q", namespaceLabel)
				ns, err := context.GlobalContext.Client.GetNamespace(namespaceLabel)
				if err != nil {
					logrus.WithError(err).Errorf("unable to get namespace %q", namespaceLabel)
					return nil, err
				}
				return ns, nil
			default:
				var list namespace.NamespaceList
				logrus.Debugf("getting namespace list")
				list, err := context.GlobalContext.Client.GetNamespaceList()
				if err != nil {
					logrus.WithError(err).Errorf("unable to get namespace list")
					return nil, err
				}
				return list, nil
			}
		}()
		if err != nil {
			fmt.Printf("%v\n", err)
			return
		}
		err = configuration.ExportData(nsData, getNamespaceDataConfig.ExportConfig)
		if err != nil {
			logrus.Debugf("fatal error: %v", err)
			return
		}
		logrus.Debugf("OK")
	},
}

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