Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ListCmd = &cli.Command{ Name: "list", Usage: "List the available templates", Description: "Lists the available templates within the system.", MaxArgs: cli.NoArgs, Run: func(ctx context.Context, cmd *cli.Command) error { alias := cmd.GetString("alias") cfg := config.GetServerAddr(alias, cmd) client, err := apiclient.NewClient(cfg.HttpServer, cfg.ApiToken, cmd.GetBool("tls-skip-verify")) if err != nil { return fmt.Errorf("Failed to create API client: %w", err) } pingResponse, err := client.Ping(context.Background()) if err != nil { return fmt.Errorf("Error getting server info: %w", err) } zone := pingResponse.Zone templates, _, err := client.GetTemplates(context.Background()) if err != nil { return fmt.Errorf("Error getting templates: %w", err) } data := [][]string{{"Name", "Description"}} for _, template := range templates.Templates { if zone != "" && !isTemplateValidForZone(template.Zones, zone) { continue } desc := strings.ReplaceAll(template.Description, "\n", " ") data = append(data, []string{template.Name, desc}) } util.PrintTable(data) return nil }, }
View Source
var TemplatesCmd = &cli.Command{ Name: "template", Usage: "Manage templates", Description: "Manage templates from the command line.", Flags: []cli.Flag{ &cli.StringFlag{ Name: "server", Aliases: []string{"s"}, Usage: "The address of the remote server to manage spaces on.", EnvVars: []string{config.CONFIG_ENV_PREFIX + "_SERVER"}, Global: true, }, &cli.StringFlag{ Name: "token", Aliases: []string{"t"}, Usage: "The token to use for authentication.", EnvVars: []string{config.CONFIG_ENV_PREFIX + "_TOKEN"}, Global: true, }, &cli.BoolFlag{ Name: "tls-skip-verify", Usage: "Skip TLS verification when talking to server.", ConfigPath: []string{"tls.skip_verify"}, EnvVars: []string{config.CONFIG_ENV_PREFIX + "_TLS_SKIP_VERIFY"}, DefaultValue: true, Global: true, }, &cli.StringFlag{ Name: "alias", Aliases: []string{"a"}, Usage: "The server alias to use.", DefaultValue: "default", Global: true, }, }, Commands: []*cli.Command{ ListCmd, }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.