autoscale

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AutoScaleCmd = &cobra.Command{
	Use:               "auto-scale",
	Short:             "AutoScale integrations",
	Long:              `Use this command to query information about active AutoScale integrations`,
	SilenceErrors:     true,
	PersistentPreRunE: controller.PreRunE,
	PersistentPostRun: controller.PostRun,
}

AutoScaleCmd is the command to observe AutoScale control points.

View Source
var ControlPointsCmd = &cobra.Command{
	Use:           "control-points",
	Short:         "List AutoScale control points",
	Long:          `List AutoScale control points`,
	SilenceErrors: true,
	Example:       `aperturectl auto-scale control-points --kube`,
	RunE: func(_ *cobra.Command, _ []string) error {
		client, err := controller.Client()
		if err != nil {
			return err
		}

		resp, err := client.ListAutoScaleControlPoints(context.Background(), &cmdv1.ListAutoScaleControlPointsRequest{})
		if err != nil {
			return err
		}

		if resp.ErrorsCount != 0 {
			fmt.Fprintf(os.Stderr, "Could not get answer from %d agents", resp.ErrorsCount)
		}

		slices.SortFunc(resp.GlobalAutoScaleControlPoints, func(a, b *cmdv1.GlobalAutoScaleControlPoint) bool {
			if a.AgentGroup != b.AgentGroup {
				return a.AgentGroup < b.AgentGroup
			}
			if a.AutoScaleControlPoint.Name != b.AutoScaleControlPoint.Name {
				return a.AutoScaleControlPoint.Name < b.AutoScaleControlPoint.Name
			}
			if a.AutoScaleControlPoint.Namespace != b.AutoScaleControlPoint.Namespace {
				return a.AutoScaleControlPoint.Namespace < b.AutoScaleControlPoint.Namespace
			}
			return a.AutoScaleControlPoint.Kind < b.AutoScaleControlPoint.Kind
		})

		tabwriter := tabwriter.NewWriter(os.Stdout, 5, 0, 3, ' ', 0)
		fmt.Fprintln(tabwriter, "AGENT GROUP\tNAME\tNAMESPACE\tKIND")
		for _, cp := range resp.GlobalAutoScaleControlPoints {
			fmt.Fprintf(tabwriter, "%s\t%s\t%s\t%s\n",
				cp.AgentGroup,
				cp.AutoScaleControlPoint.Name,
				cp.AutoScaleControlPoint.Namespace,
				cp.AutoScaleControlPoint.Kind)
		}
		tabwriter.Flush()

		return nil
	},
}

ControlPointsCmd is the command to list control points.

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