list

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "list",
	Short: "List storage jobs according to query flag options.",
	Long:  `List storage jobs according to query flag options.`,
	Args:  cobra.NoArgs,
	PreRun: func(cmd *cobra.Command, args []string) {
		err := viper.BindPFlags(cmd.Flags())
		c.CheckErr(err)
	},
	Run: func(cmd *cobra.Command, args []string) {
		ctx, cancel := context.WithTimeout(context.Background(), c.CmdTimeout)
		defer cancel()

		var sel admin.ListSelect
		selIn := viper.GetString("select")
		switch selIn {
		case "all":
			sel = admin.All
		case "queued":
			sel = admin.Queued
		case "executing":
			sel = admin.Executing
		case "final":
			sel = admin.Final
		default:
			c.CheckErr(fmt.Errorf("invalid option for --select: %s", selIn))
		}

		conf := admin.ListConfig{
			UserIDFilter: viper.GetString("user"),
			CidFilter:    viper.GetString("cid"),
			Limit:        viper.GetUint64("limit"),
			Ascending:    viper.GetBool("ascending"),
			Select:       sel,
		}

		res, err := c.PowClient.Admin.StorageJobs.List(c.MustAuthCtx(ctx), conf)
		c.CheckErr(err)

		json, err := protojson.MarshalOptions{Multiline: true, Indent: "  ", EmitUnpopulated: true}.Marshal(res)
		c.CheckErr(err)

		fmt.Println(string(json))
	},
}

Cmd is the command.

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