list

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NameKey         = "name"
	NameShorthand   = "n"
	LabelsKey       = "labels"
	LabelsShorthand = "l"
)

Variables

View Source
var ListEnvsCmd = &cobra.Command{
	Use:          "list",
	Short:        "List Environments",
	Args:         cobra.NoArgs,
	SilenceUsage: true,
	RunE: func(_ *cobra.Command, args []string) error {
		ctxTimeout, cancel := context.WithTimeout(context.Background(), config.DefaultTimeout)
		defer cancel()

		c, err := cloudclient.NewClient(ctxTimeout)
		if err != nil {
			return err
		}

		labels := viper.GetStringMapString(LabelsKey)
		labelsInput := lo.Ternary(len(labels) == 0, nil, lo.ToPtr(cloudclient.LabelsToLabelInput(labels)))

		r, err := c.EnvironmentsQueryWithResponse(ctxTimeout,
			&cloudapi.EnvironmentsQueryParams{
				Name:   lo.Ternary(viper.IsSet(NameKey), lo.ToPtr(NameKey), nil),
				Labels: labelsInput,
			},
		)
		if err != nil {
			return err
		}

		output.FormatEnvs(lo.FromPtr(r.JSON200))
		return nil
	},
}

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