Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Create = &cli.Command{ Name: "deployment", Aliases: aliases, Flags: []cli.Flag{ &cli.StringFlag{ Name: "file", Aliases: []string{"f"}, Usage: "file with deployment data", }, }, Action: func(ctx *cli.Context) error { client := util.GetClient(ctx) namespace := util.GetNamespace(ctx) deplConfig := deplactive.Config{} if ctx.IsSet("file") { deploymentFile := ctx.String("file") depl, err := deplactive.FromFile(deploymentFile) if err != nil { logrus.WithError(err). Errorf("unable to read deployment data from %q", deploymentFile) fmt.Printf("Unable to read data from %q: %v\n", deploymentFile, err) return err } deplConfig.Deployment = &depl } depl, err := deplactive.ConstructDeployment(deplConfig) if err != nil { logrus.WithError(err).Error("error while creating deployment") fmt.Printf("%v\n", err) return err } fmt.Println(depl.RenderTable()) for { _, option, _ := activeToolkit.Options("What do you want to do with deployment?", false, "Push to server", "Print to terminal", "Dump to file", "Exit") switch option { case 0: anime := &animation.Animation{ Framerate: 0.3, ClearLastFrame: true, Source: trasher.NewSilly(), } go func() { time.Sleep(time.Second) anime.Run() }() go anime.Run() err = client.CreateDeployment(namespace, depl) anime.Stop() if err != nil { logrus.WithError(err).Error("unable to create deployment") fmt.Printf("\n%v\n", err) } case 1: data, _ := depl.RenderYAML() w := textWidth(data) fmt.Println(strings.Repeat("-", w)) fmt.Println(data) fmt.Println(strings.Repeat("-", w)) case 2: filename, _ := activeToolkit.AskLine("Print filename > ") if strings.TrimSpace(filename) == "" { return nil } depl.ToKube() data, _ := depl.MarshalJSON() err := ioutil.WriteFile(filename, data, os.ModePerm) if err != nil { logrus.WithError(err).Error("unable to write deployment to file") fmt.Println(err) } default: return nil } } }, }
View Source
var DeleteDeployment = &cli.Command{ Name: "deployment", Usage: "call to delete deployment in specific namespace", UsageText: "chkit delete deployment deployment_label [-n namespace]", Description: "deletes deployment. Aliases: " + strings.Join(aliases, ", "), Aliases: aliases, Flags: util.DeleteFlags, Action: func(ctx *cli.Context) error { logrus.Debugf("running command delete deployment") client := util.GetClient(ctx) namespace := util.GetNamespace(ctx) if ctx.NArg() == 0 { logrus.Debugf("show help") return cli.ShowSubcommandHelp(ctx) } depl := ctx.Args().First() logrus.Debugf("deleting deployment %q from %q", depl, namespace) err := client.DeleteDeployment(namespace, depl) logrus.WithError(err).Debugf("error while deleting deployment") return err }, }
View Source
var (
ErrNoNamespaceSpecified chkitErrors.Err = "no namespace specified"
)
View Source
var GetDeployment = &cli.Command{ Name: "deployment", Aliases: aliases, Usage: "shows deployment data", Description: "shows deployment data. Aliases: " + strings.Join(aliases, ", "), UsageText: "namespace deployment_names... [-n namespace_label]", Action: func(ctx *cli.Context) error { if ctx.Bool("help") { return cli.ShowSubcommandHelp(ctx) } client := util.GetClient(ctx) defer util.StoreClient(ctx, client) var show model.Renderer switch ctx.NArg() { case 0: namespace := util.GetNamespace(ctx) logrus.Debugf("getting deployment from %q", namespace) list, err := client.GetDeploymentList(namespace) if err != nil { return err } show = list default: namespace := util.GetNamespace(ctx) deplNames := util.NewSet(ctx.Args().Slice()) var showList deployment.DeploymentList = make([]deployment.Deployment, 0) // prevents panic list, err := client.GetDeploymentList(namespace) if err != nil { return err } for _, depl := range list { if deplNames.Have(depl.Name) { showList = append(showList, depl) } } show = showList } return util.ExportDataCommand(ctx, show) }, Flags: util.GetFlags, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.