Documentation ¶
Overview ¶
Package session wraps ocm session parameters to be accessed during cli commands. For example both the active connection and logger can be retrieved from the current session.
Index ¶
- Constants
- Variables
- func LogLevel(verbosity int) log.Level
- func Normalize(s string) string
- func ParseOrder(maybeOrder string) ocm.Order
- func ParseTime(maybeTime string) (time.Time, error)
- func PromptYesOrNo(out io.Writer, in io.Reader, msg string) bool
- func UpperSnake(header string) string
- type CommonOptions
- type Config
- type FilterOptions
- func (f *FilterOptions) AddAfterFlag(flags *pflag.FlagSet)
- func (f *FilterOptions) AddBeforeFlag(flags *pflag.FlagSet)
- func (f *FilterOptions) AddOrderFlag(flags *pflag.FlagSet)
- func (f *FilterOptions) AfterUsage(usg string)
- func (f *FilterOptions) BeforeUsage(usg string)
- func (f *FilterOptions) OrderDefault(ord string)
- func (f *FilterOptions) OrderUsage(usg string)
- func (f *FilterOptions) ParseFilterOptions() error
- type HeaderFormatter
- type LatestPluginBinaryGetter
- type LatestVersionGetter
- type Pager
- type Row
- type RowDataProvider
- type RowModifier
- type SearchOptions
- type Session
- type Table
- type TableConfig
- type TableOption
- type VersionUpdater
- type WithColumns
- type WithHeaderFormatter
- type WithNoColor
- type WithNoHeaders
- type WithOutput
- type WithPager
Constants ¶
const ( LogLevelError = iota LogLevelWarn LogLevelInfo LogLevelDebug )
Variables ¶
var ErrNoConfigurationLoaded = errors.New("no configuration loaded")
Functions ¶
func ParseOrder ¶
func PromptYesOrNo ¶ added in v0.2.0
func UpperSnake ¶ added in v0.6.0
Types ¶
type CommonOptions ¶
func (*CommonOptions) AddColumnsFlag ¶
func (c *CommonOptions) AddColumnsFlag(flags *pflag.FlagSet)
func (*CommonOptions) AddNoColorFlag ¶ added in v0.2.2
func (c *CommonOptions) AddNoColorFlag(flags *pflag.FlagSet)
func (*CommonOptions) AddNoHeadersFlag ¶
func (c *CommonOptions) AddNoHeadersFlag(flags *pflag.FlagSet)
func (*CommonOptions) DefaultColumns ¶
func (c *CommonOptions) DefaultColumns(cols string)
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config wraps an 'ocm-cli' config object and it's fields/methods.
func LoadConfig ¶
LoadConfig loads an existing 'ocm.json' file and returns a Config object if possible.
func (Config) IsEmpty ¶
IsEmpty returns true if there is no configuration file or if no credentials are present with which to start a session.
type FilterOptions ¶
type FilterOptions struct { Order ocm.Order Before time.Time After time.Time // contains filtered or unexported fields }
func (*FilterOptions) AddAfterFlag ¶
func (f *FilterOptions) AddAfterFlag(flags *pflag.FlagSet)
func (*FilterOptions) AddBeforeFlag ¶
func (f *FilterOptions) AddBeforeFlag(flags *pflag.FlagSet)
func (*FilterOptions) AddOrderFlag ¶
func (f *FilterOptions) AddOrderFlag(flags *pflag.FlagSet)
func (*FilterOptions) AfterUsage ¶
func (f *FilterOptions) AfterUsage(usg string)
func (*FilterOptions) BeforeUsage ¶
func (f *FilterOptions) BeforeUsage(usg string)
func (*FilterOptions) OrderDefault ¶
func (f *FilterOptions) OrderDefault(ord string)
func (*FilterOptions) OrderUsage ¶
func (f *FilterOptions) OrderUsage(usg string)
func (*FilterOptions) ParseFilterOptions ¶
func (f *FilterOptions) ParseFilterOptions() error
type HeaderFormatter ¶ added in v0.6.0
type LatestPluginBinaryGetter ¶ added in v0.4.0
type LatestVersionGetter ¶ added in v0.4.0
type RowDataProvider ¶ added in v0.6.0
type RowDataProvider interface {
ProvideRowData() map[string]interface{}
}
type RowModifier ¶ added in v0.6.0
func WithAdditionalFields ¶ added in v0.6.0
func WithAdditionalFields(fields map[string]interface{}) RowModifier
type SearchOptions ¶
type SearchOptions struct { Search string // contains filtered or unexported fields }
func (*SearchOptions) AddSearchFlag ¶
func (s *SearchOptions) AddSearchFlag(flags *pflag.FlagSet)
func (*SearchOptions) SearchUsage ¶
func (s *SearchOptions) SearchUsage(usg string)
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session provides access to the session-bound parameters for an invocation of this plug-in.
func NewSession ¶
NewSession loads an ocm configuration created after the user runs 'ocm login' and starts a connection to ocm. A logger with session context is also made available to callers of NewSession. An error is returned if a configuration cannot be loaded or if a connection cannot be made to OCM. Otherwise a pointer to a session object is returned.
func (*Session) Conn ¶
func (s *Session) Conn() *sdk.Connection
Conn returns the OCM connection for the current session.
func (*Session) End ¶
func (s *Session) End()
End releases any open session resources and logs any errors that may occur during this process.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func NewTable ¶
func NewTable(opts ...TableOption) (*Table, error)
func (*Table) Write ¶ added in v0.6.0
func (t *Table) Write(r RowDataProvider, mods ...RowModifier) error
type TableConfig ¶ added in v0.6.0
type TableConfig struct { Out io.Writer Columns []string HFormatter HeaderFormatter NoColor bool NoHeaders bool PagerBin string }
func (*TableConfig) Default ¶ added in v0.6.0
func (c *TableConfig) Default()
func (*TableConfig) Option ¶ added in v0.6.0
func (c *TableConfig) Option(opts ...TableOption)
type TableOption ¶
type TableOption interface {
ConfigureTable(*TableConfig)
}
type VersionUpdater ¶ added in v0.4.0
type VersionUpdater interface { LatestVersionGetter LatestPluginBinaryGetter }
type WithColumns ¶ added in v0.6.0
type WithColumns string
func (WithColumns) ConfigureTable ¶ added in v0.6.0
func (wc WithColumns) ConfigureTable(c *TableConfig)
type WithHeaderFormatter ¶ added in v0.6.0
type WithHeaderFormatter HeaderFormatter
func (WithHeaderFormatter) ConfigureTable ¶ added in v0.6.0
func (wh WithHeaderFormatter) ConfigureTable(c *TableConfig)
type WithNoColor ¶ added in v0.6.0
type WithNoColor bool
func (WithNoColor) ConfigureTable ¶ added in v0.6.0
func (wn WithNoColor) ConfigureTable(c *TableConfig)
type WithNoHeaders ¶ added in v0.6.0
type WithNoHeaders bool
func (WithNoHeaders) ConfigureTable ¶ added in v0.6.0
func (wn WithNoHeaders) ConfigureTable(c *TableConfig)
type WithOutput ¶ added in v0.6.0
type WithOutput struct {
// contains filtered or unexported fields
}
func (WithOutput) ConfigureTable ¶ added in v0.6.0
func (wo WithOutput) ConfigureTable(c *TableConfig)
type WithPager ¶ added in v0.6.0
type WithPager string
func (WithPager) ConfigureTable ¶ added in v0.6.0
func (wp WithPager) ConfigureTable(c *TableConfig)