commands

package
v2.15.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Overview

Package commands provides base commands and helpers.

Index

Constants

This section is empty.

Variables

View Source
var (
	Annotation  = new(annotationCommand)
	AnnotationC = kingpin.Command("annotate", "Add an annotation to Grafana charts")
)

register command

View Source
var (
	Config  = new(configCommand)
	ConfigC = kingpin.Command("config", "Configure local pmm-agent")
)

register command

View Source
var (
	List  = new(listCommand)
	ListC = kingpin.Command("list", "Show Services and Agents running on this Node")
)

register command

View Source
var (
	Status  = new(statusCommand)
	StatusC = kingpin.Command("status", "Show information about local pmm-agent")
)

register command

View Source
var (
	Summary  = new(summaryCommand)
	SummaryC = kingpin.Command("summary", "Fetch system data for diagnostics")
)

register command

Ctx is a shared context for all requests.

View Source
var GlobalFlags = new(globalFlagsValues)

GlobalFlags contains pmm-admin core flags values.

View Source
var UsageTemplate = `` /* 1396-byte string literal not displayed */

Default kingping's usage template with tweaks: * FormatAllCommands is a copy of FormatCommands that ignores hidden flag; * subcommands are shown with FormatAllCommands.

Functions

func ParseCustomLabels

func ParseCustomLabels(labels string) (map[string]string, error)

ParseCustomLabels parses --custom-labels flag value.

Note that quotes around value are parsed and removed by shell before this function is called. E.g. the value of [[--custom-labels='region=us-east1, mylabel=mylab-22']] will be received by this function as [[region=us-east1, mylabel=mylab-22]].

func ParseDisableCollectors

func ParseDisableCollectors(collectors string) []string

ParseDisableCollectors parses --disable-collectors flag value.

func ParseTemplate

func ParseTemplate(text string) *template.Template

func ReadFile

func ReadFile(filepath string) (string, error)

ReadFile reads file from filepath if filepath is not empty.

func RenderTemplate

func RenderTemplate(t *template.Template, data interface{}) string

RenderTemplate renders given template with given data and returns result as string.

func SetupClients

func SetupClients(ctx context.Context, serverURL string)

SetupClients configures local and PMM Server API clients.

Types

type Command

type Command interface {
	Run() (Result, error)
}

Command is a common interface for all commands.

Command should:

  • use logrus.Trace/Debug functions for debug logging;
  • return result on success;
  • return error on failure.

Command should not:

  • return both result and error;
  • exit with logrus.Fatal, os.Exit, etc;
  • use logrus.Print, logrus.Info and higher levels except:
  • summary command (for progress output).

type CommandWithContext

type CommandWithContext interface {
	// TODO rename to Run
	RunWithContext(ctx context.Context) (Result, error)
}

TODO remove Command above, rename CommandWithContext to Command

type Error

type Error struct {
	Code  int    `json:"code"`
	Error string `json:"error"`
}

func GetError

func GetError(err ErrorResponse) Error

type ErrorResponse

type ErrorResponse interface {
	error
	Code() int
}

type Result

type Result interface {
	Result()
	fmt.Stringer
}

Result is a common interface for all command results.

In addition to methods of this interface, result is expected to work with json.Marshal.

Directories

Path Synopsis
Package inventory provides inventory commands.
Package inventory provides inventory commands.
Package management provides management commands.
Package management provides management commands.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL