cmd

package
v0.0.0-...-9451de5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: BSD-3-Clause Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VerbosityHeader = "X-Tsuru-Verbosity"
)

Variables

View Source
var (
	ErrAbortCommand = errors.New("")

	// ErrLookup is the error that should be returned by lookup functions when it
	// cannot find a matching command for the given parameters.
	ErrLookup = errors.New("lookup error - command not found")
)
View Source
var GitHash = ""

Functions

func CheckIfTargetLabelExists

func CheckIfTargetLabelExists(label string) (bool, error)

func Colorfy

func Colorfy(msg string, fontcolor string, background string, effect string) string

func ExtractProgramName

func ExtractProgramName(path string) string

func GetTarget

func GetTarget() (string, error)

func GetTargetLabel

func GetTargetLabel() (string, error)

func GetURL

func GetURL(path string) (string, error)

func GetURLVersion

func GetURLVersion(version, path string) (string, error)

func JoinWithUserDir

func JoinWithUserDir(p ...string) string

func MergeFlagSet

func MergeFlagSet(fs1, fs2 *gnuflag.FlagSet) *gnuflag.FlagSet

func PasswordFromReader

func PasswordFromReader(reader io.Reader) (string, error)

func ReadTarget

func ReadTarget() (string, error)

ReadTarget returns the current target, as defined in the TSURU_TARGET environment variable or in the target file.

func ReadToken

func ReadToken() (string, error)

func RegisterExtraCmd

func RegisterExtraCmd(cmd Command)

func SamlCallbackFailureMessage

func SamlCallbackFailureMessage() string

func SamlCallbackSuccessMessage

func SamlCallbackSuccessMessage() string

func ShowServicesInstancesList

func ShowServicesInstancesList(b []byte) ([]byte, error)

func StreamJSONResponse

func StreamJSONResponse(w io.Writer, response *http.Response) error

StreamJSONResponse supports the JSON streaming format from the tsuru API.

func WriteOnTargetList

func WriteOnTargetList(label, target string) error

WriteOnTargetList writes the given target in the target list file.

func WriteTarget

func WriteTarget(t string) error

WriteTarget writes the given endpoint to the target file.

Types

type APIRolePermissionData

type APIRolePermissionData struct {
	Name         string
	ContextType  string
	ContextValue string
}

type APIUser

type APIUser struct {
	Email       string
	Roles       []APIRolePermissionData
	Permissions []APIRolePermissionData
}

APIUser is a user in the tsuru API.

func GetUser

func GetUser(client *Client) (*APIUser, error)

func (*APIUser) PermissionInstances

func (u *APIUser) PermissionInstances() []string

func (*APIUser) RoleInstances

func (u *APIUser) RoleInstances() []string

type AppGuesser

type AppGuesser interface {
	GuessName(path string) (string, error)
}

AppGuesser is used to guess the name of an app based in a file path.

type Cancelable

type Cancelable interface {
	// Cancel handles the command cancellation and is required to be thread safe as
	// this method is called by a different goroutine.
	// Cancel should return an error if the operation is not cancelable yet/anymore or there
	// was any error during the cancellation.
	// Cancel may be called multiple times.
	Cancel(context Context, client *Client) error
}

Cancelable are implemented by commands that support cancellation

type Client

type Client struct {
	HTTPClient *http.Client

	Verbosity int
	// contains filtered or unexported fields
}

func NewClient

func NewClient(client *http.Client, context *Context, manager *Manager) *Client

func (*Client) Do

func (c *Client) Do(request *http.Request) (*http.Response, error)

type Command

type Command interface {
	Info() *Info
	Run(context *Context, client *Client) error
}

func ExtraCmds

func ExtraCmds() []Command

type ConfirmationCommand

type ConfirmationCommand struct {
	// contains filtered or unexported fields
}

func (*ConfirmationCommand) Confirm

func (cmd *ConfirmationCommand) Confirm(context *Context, question string) bool

func (*ConfirmationCommand) Flags

func (cmd *ConfirmationCommand) Flags() *gnuflag.FlagSet

type Context

type Context struct {
	Args   []string
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader
}

func (*Context) RawOutput

func (c *Context) RawOutput()

type DeprecatedCommand

type DeprecatedCommand struct {
	Command
	// contains filtered or unexported fields
}

func (*DeprecatedCommand) Flags

func (c *DeprecatedCommand) Flags() *gnuflag.FlagSet

func (*DeprecatedCommand) Run

func (c *DeprecatedCommand) Run(context *Context, client *Client) error

type FlaggedCommand

type FlaggedCommand interface {
	Command
	Flags() *gnuflag.FlagSet
}

type GitGuesser

type GitGuesser struct{}

GitGuesser uses git to guess the name of the app.

It reads the "tsuru" remote from git config file. If the remote does not exist, or does not match the tsuru pattern (<user>@<somehost>:<app-name>.git), GuessName will return an error.

func (GitGuesser) GuessName

func (g GitGuesser) GuessName(path string) (string, error)

type GuessingCommand

type GuessingCommand struct {
	G AppGuesser
	// contains filtered or unexported fields
}

Embed this struct if you want your command to guess the name of the app.

func (*GuessingCommand) Flags

func (cmd *GuessingCommand) Flags() *gnuflag.FlagSet

func (*GuessingCommand) Guess

func (cmd *GuessingCommand) Guess() (string, error)

type Info

type Info struct {
	Name    string
	MinArgs int
	MaxArgs int
	Usage   string
	Desc    string
	// contains filtered or unexported fields
}

type Lookup

type Lookup func(context *Context) error

type Manager

type Manager struct {
	Commands map[string]Command
	// contains filtered or unexported fields
}

func BuildBaseManager

func BuildBaseManager(name, version, versionHeader string, lookup Lookup) *Manager

func NewManager

func NewManager(name, ver, verHeader string, stdout, stderr io.Writer, stdin io.Reader, lookup Lookup) *Manager

func (*Manager) Register

func (m *Manager) Register(command Command)

func (*Manager) RegisterDeprecated

func (m *Manager) RegisterDeprecated(command Command, oldName string)

func (*Manager) RegisterRemoved

func (m *Manager) RegisterRemoved(name string, help string)

func (*Manager) RegisterTopic

func (m *Manager) RegisterTopic(name, content string)

func (*Manager) Run

func (m *Manager) Run(args []string)

type MapFlag

type MapFlag map[string]string

func (*MapFlag) Set

func (f *MapFlag) Set(val string) error

func (*MapFlag) String

func (f *MapFlag) String() string

type MapFlagWrapper

type MapFlagWrapper struct {
	Dst *map[string]string
}

func (MapFlagWrapper) Set

func (f MapFlagWrapper) Set(val string) error

func (MapFlagWrapper) String

func (f MapFlagWrapper) String() string

type MultiGuesser

type MultiGuesser struct {
	Guessers []AppGuesser
}

MultiGuesser can use multiple guessers

func (MultiGuesser) GuessName

func (g MultiGuesser) GuessName(pathname string) (string, error)

type RemovedCommand

type RemovedCommand struct {
	Name string
	Help string
}

func (*RemovedCommand) Info

func (c *RemovedCommand) Info() *Info

func (*RemovedCommand) Run

func (c *RemovedCommand) Run(context *Context, client *Client) error

type ServiceModel

type ServiceModel struct {
	Service   string
	Instances []string
}

type ShellToContainerCmd

type ShellToContainerCmd struct {
	GuessingCommand
	// contains filtered or unexported fields
}

func (*ShellToContainerCmd) Flags

func (c *ShellToContainerCmd) Flags() *gnuflag.FlagSet

func (*ShellToContainerCmd) Info

func (c *ShellToContainerCmd) Info() *Info

func (*ShellToContainerCmd) Run

func (c *ShellToContainerCmd) Run(context *Context, client *Client) error

type StringSliceFlag

type StringSliceFlag []string

func (*StringSliceFlag) Set

func (f *StringSliceFlag) Set(val string) error

func (*StringSliceFlag) String

func (f *StringSliceFlag) String() string

type StringSliceFlagWrapper

type StringSliceFlagWrapper struct {
	Dst *[]string
}

func (StringSliceFlagWrapper) Set

func (f StringSliceFlagWrapper) Set(val string) error

func (StringSliceFlagWrapper) String

func (f StringSliceFlagWrapper) String() string

type VerboseRoundTripper

type VerboseRoundTripper struct {
	http.RoundTripper
	Verbosity *int
	Writer    io.Writer
}

VerboseRoundTripper is a RoundTripper that dumps request and response based on the Verbosity. Verbosity >= 1 --> Dumps request Verbosity >= 2 --> Dumps response

func (*VerboseRoundTripper) RoundTrip

func (v *VerboseRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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