common

package
v0.0.0-...-2ab8be3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DEFAULT     = "default"
	TABLE       = "table"
	TABLE_LIGHT = "table-light"
	JSON        = "json"
	YAML        = "yaml"
)

Variables

View Source
var (
	CONF      ConfGroup
	CONF_FILE string
)
View Source
var (
	FORMAT_TABLE_LIGHT        = "table-light"
	FORMAT_TABLE              = "table"
	DEFAULT_TOKEN_EXPIRE_TIME = 60 * 30
)
View Source
var CONF_FILES = []string{
	"etc/skyman.yaml",
	"/etc/skyman/skyman.yaml",
}
View Source
var (
	STYLE_LIGHT = "light"
)

Functions

func GetOutputFormats

func GetOutputFormats() []string

func GetYaml

func GetYaml(v interface{}) (string, error)

func LoadConfig

func LoadConfig(configFile string) error

func MarshalModel

func MarshalModel(obj interface{}, indent bool) string

func PathExtSplit

func PathExtSplit(file string) (string, string)

func PrintPrettyItemTable

func PrintPrettyItemTable(table PrettyItemTable)

func PrintPrettyTable

func PrintPrettyTable(table PrettyTable, long bool)

func PrintPrettyTableFormat

func PrintPrettyTableFormat(table PrettyTable, long bool, format string)

func RegistryLongFlag

func RegistryLongFlag(cmd ...*cobra.Command)

func SplitKeyValue

func SplitKeyValue(kv string) ([]string, error)

Types

type Auth

type Auth struct {
	Url             string          `yaml:"url"`
	Region          keystone.Region `yaml:"region"`
	User            auth.User       `yaml:"user"`
	Project         auth.Project    `yaml:"project"`
	TokenExpireTime int             `yaml:"tokenExpireTime"`
}

type Column

type Column struct {
	Name string
	Text string
	// 只有 Table.Style 等于 light 是才会生效
	AutoColor  bool
	ForceColor bool
	Slot       func(item interface{}) interface{}
	SlotColumn func(item interface{}, column Column) interface{}
	Sort       bool
	SortMode   table.SortMode
	Filters    []string
	Marshal    bool
	WidthMax   int
	Align      text.Align
}

type ConfGroup

type ConfGroup struct {
	Debug       bool   `yaml:"debug"`
	Format      string `yaml:"format"`
	Language    string `yaml:"language"`
	HttpTimeout int    `yaml:"httpTimeout"`

	Auth  Auth  `yaml:"auth"`
	Iperf Iperf `yaml:"iperf"`
}

type Iperf

type Iperf struct {
	GuestPath     string `yaml:"guestPath"`
	LocalPath     string `yaml:"guestPath"`
	ClientOptions string `yaml:"clientOptions"`
	ServerOptions string `yaml:"serverOptions"`
}

type PrettyItemTable

type PrettyItemTable struct {
	ShortFields     []Column
	LongFields      []Column
	Item            interface{}
	Title           string
	Style           string
	Number2WidthMax int
}

func (PrettyItemTable) Print

func (pt PrettyItemTable) Print(long bool)

func (PrettyItemTable) PrintJson

func (dt PrettyItemTable) PrintJson()

func (PrettyItemTable) PrintYaml

func (dt PrettyItemTable) PrintYaml()

type PrettyTable

type PrettyTable struct {
	Title             string
	ShortColumns      []Column
	LongColumns       []Column
	Items             []interface{}
	ColumnConfigs     []table.ColumnConfig
	Style             string
	StyleSeparateRows bool
	HideTotalItems    bool

	Filters map[string]string
	Search  string
	// contains filtered or unexported fields
}

func (*PrettyTable) AddItems

func (pt *PrettyTable) AddItems(items interface{})

func (*PrettyTable) CleanItems

func (pt *PrettyTable) CleanItems()

func (PrettyTable) GetLongColumnIndex

func (pt PrettyTable) GetLongColumnIndex(column string) int

func (PrettyTable) GetShortColumnIndex

func (pt PrettyTable) GetShortColumnIndex(column string) int

func (PrettyTable) Print

func (pt PrettyTable) Print(long bool)

func (PrettyTable) PrintJson

func (pt PrettyTable) PrintJson()

func (PrettyTable) PrintYaml

func (pt PrettyTable) PrintYaml()

func (*PrettyTable) ReInit

func (pt *PrettyTable) ReInit()

func (*PrettyTable) SetStyleLight

func (pt *PrettyTable) SetStyleLight()

type Server

type Server struct {
	Flavor           string `yaml:"flavor"`
	Image            string `yaml:"image"`
	Network          string `yaml:"network"`
	VolumeBoot       bool   `yaml:"volumeBoot"`
	VolumeType       string `yaml:"volumeType"`
	VolumeSize       uint16 `yaml:"volumeSize"`
	AvailabilityZone string `yaml:"availabilityZone"`
	NamePrefix       string `yaml:"namePrefix"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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