cmd

package
v0.0.0-...-c736ba3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONFIG_DIR = ".openstate"

	CONFIG_FILENAME = "config"
)

Variables

This section is empty.

Functions

func Banner(padding int) string

func FormatTable

func FormatTable(data [][]string) string

FormatTable returns a properly formatted string given some input. The first row of the data matrix must be the column headers.

func InstanceEventUsageTemplate

func InstanceEventUsageTemplate() string

func NewCmdInstance

func NewCmdInstance() *cobra.Command

func NewCmdInstanceEvent

func NewCmdInstanceEvent() *cobra.Command

func NewCmdOpenState

func NewCmdOpenState() *cobra.Command

func NewCmdServer

func NewCmdServer() *cobra.Command

NewCmdServer initializes ServerOptions, creates the new Cobra command, and adds the flags

func NewCmdTask

func NewCmdTask() *cobra.Command

func NewCmdTaskDefine

func NewCmdTaskDefine() *cobra.Command

func NewCmdTaskList

func NewCmdTaskList() *cobra.Command

func NewCmdTaskPs

func NewCmdTaskPs() *cobra.Command

func NewCmdTaskRun

func NewCmdTaskRun() *cobra.Command

func ServerUsageTemplate

func ServerUsageTemplate() string

func SharedUsageTemplate

func SharedUsageTemplate() string

SharedUsageTemplate retuns a formatted string enumerating each shared CLI flag. It should not be used as an argument to SetUsageTemplate, but instead factored into a command's own usage template.

func TableWriter

func TableWriter(writer io.Writer) *tablewriter.Table

TableWriter initializes and configures a tablewriter.Table object. This table should only be used by the FormatTable function.

func TaskDefineUsageTemplate

func TaskDefineUsageTemplate() string

func TaskListUsageTemplate

func TaskListUsageTemplate() string

func TaskPsUsageTemplate

func TaskPsUsageTemplate() string

func TaskRunUsageTemplate

func TaskRunUsageTemplate() string

Types

type AdvertiseAddrs

type AdvertiseAddrs struct {
	HTTP string `mapstructure:"http"`
	Serf string `mapstructure:"serf"`
	Raft string `mapstructure:"raft"`
}

AdvertiseAddrs are the addresses for Raft, Serf, and HTTP endpoints.

type Config

type Config struct {
	// NoBanner indicates if we should not print the ASCII OpenState banner
	NoBanner bool `mapstructure:"no_banner"`

	// DevMode indicates if the OpenState server should run in development mode.
	// This disables the log, stable, and snapshot stores, and uses a simple
	// in-memory store instead.
	DevMode bool `mapstructure:"dev_mode"`

	// DataDirectory is a path to directory where OpenState stores state related
	// objects; primarily snapshots, logs, and the stable store.
	DataDirectory string `mapstructure:data_directory`

	// LogLevel is the verbosity of OpenState's logger. Options include: DEBUG,
	// INFO, WARN, and ERROR. See hashicorp/hclog for more info.
	LogLevel string `mapstructure:"log_level"`

	// Addrs are the addresses for Raft, Serf, and HTTP endpoints.
	Addrs *AdvertiseAddrs `mapstructure:"advertise"`

	// Server contains server-specific configs.
	Server *ServerConfig `yaml:"server"`
}

Config is the umbrella struct with encompasses every configurable value in OpenState's config file.

type InstanceEventOptions

type InstanceEventOptions struct {
	Meta
	// contains filtered or unexported fields
}

func NewInstanceEventOptions

func NewInstanceEventOptions() *InstanceEventOptions

func (*InstanceEventOptions) Complete

func (o *InstanceEventOptions) Complete(cmd *cobra.Command, args []string) error

func (*InstanceEventOptions) Name

func (o *InstanceEventOptions) Name() string

func (*InstanceEventOptions) Run

func (o *InstanceEventOptions) Run()

type Meta

type Meta struct {
	UI      cli.Ui
	Address string
}

func (*Meta) Client

func (m *Meta) Client() (*api.Client, error)

Client is a wrapper around api.NewClient that merges in optional client configs from the shared CLI flags.

func (*Meta) FlagSet

func (m *Meta) FlagSet(n string) *pflag.FlagSet

FlagSet returns posix-style FlagSet for all shared CLI flags. This should be merged into a command's own FlagSet.

type ServerConfig

type ServerConfig struct {
	// NodeNameis the advertised name of the server. It's most commonly used in
	// Serf's gossip protocol.
	NodeName string `mapstructure:"node_name"`

	// Join is the initial list of peer serf addresses. This option is a hack
	// to bypass the need for service discovery (TODO). This list only needs to
	// contain ONE valid peer; the gossip layer will propogate the new peer
	// across all nodes.
	Join []string `mapstructure:"join"`

	// BootstrapExpect is the number of peers the new server should expect. If
	// 1, the new server will create a single node cluster and elect itself
	// leader.
	BootstrapExpect int `mapstructure:"bootstrap_expect"`
}

ServerConfig contains server-specific configs.

type ServerOptions

type ServerOptions struct {
	Meta
	// contains filtered or unexported fields
}

ServerOptions wraps the Config and any additional flags needed to run a new server.

func NewServerOptions

func NewServerOptions() *ServerOptions

func (*ServerOptions) Complete

func (o *ServerOptions) Complete(cmd *cobra.Command, args []string) error

func (*ServerOptions) Run

func (o *ServerOptions) Run()

Run reads in the config file, overwrites any values with flags, and starts the server.

type TaskDefineOptions

type TaskDefineOptions struct {
	Meta
	// contains filtered or unexported fields
}

func NewTaskDefineOptions

func NewTaskDefineOptions() *TaskDefineOptions

func (*TaskDefineOptions) Complete

func (o *TaskDefineOptions) Complete(cmd *cobra.Command, args []string) error

func (*TaskDefineOptions) Name

func (o *TaskDefineOptions) Name() string

func (*TaskDefineOptions) Run

func (o *TaskDefineOptions) Run()

type TaskListOptions

type TaskListOptions struct {
	Meta
}

func NewTaskListOptions

func NewTaskListOptions() *TaskListOptions

func (*TaskListOptions) Name

func (o *TaskListOptions) Name() string

func (*TaskListOptions) Run

func (o *TaskListOptions) Run()

type TaskPsOptions

type TaskPsOptions struct {
	Meta
	TaskName string
}

func NewTaskPsOptions

func NewTaskPsOptions() *TaskPsOptions

func (*TaskPsOptions) Complete

func (o *TaskPsOptions) Complete(cmd *cobra.Command, args []string) error

func (*TaskPsOptions) Name

func (o *TaskPsOptions) Name() string

func (*TaskPsOptions) Run

func (o *TaskPsOptions) Run()

type TaskRunOptions

type TaskRunOptions struct {
	Meta
	TaskName string
}

func NewTaskRunOptions

func NewTaskRunOptions() *TaskRunOptions

func (*TaskRunOptions) Complete

func (o *TaskRunOptions) Complete(cmd *cobra.Command, args []string) error

func (*TaskRunOptions) Name

func (o *TaskRunOptions) Name() string

func (*TaskRunOptions) Run

func (o *TaskRunOptions) Run()

Jump to

Keyboard shortcuts

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