commands

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package commands provides base commands and helpers.

Index

Constants

This section is empty.

Variables

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 = `` /* 1380-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 ParseTemplate

func ParseTemplate(text string) *template.Template

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.

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