model

package
v0.5.28 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Put the parameter value in the context
	ContextDisposition = ParameterDisposition("context")
	// Read a file and post its content as the body
	JSONFileBodyDisposition = ParameterDisposition("json_file_body")
	// Do nothing with the flag
	NOOPDisposition = ParameterDisposition("noop")
)
View Source
const (
	GetMethod    = "GET"
	PostMethod   = "POST"
	PatchMethod  = "PATCH"
	DeleteMethod = "DELETE"
)
View Source
const (
	XCPCI     = "xcp_ci"
	CIENVBODY = "ci_env_body"
)

Variables

View Source
var Models []*Model

Functions

func AddContextValueSupplier

func AddContextValueSupplier(name string, supplier ContextValueSupplier)

func Load

func Load(source Source) error

func RegisterAction

func RegisterAction(name string, action LocalAction)

func RegisterColumnFormatter added in v0.4.4

func RegisterColumnFormatter(name string, formatter print.Formatter)

func RegisterColumnFunction added in v0.4.17

func RegisterColumnFunction(name string, f print.ColumnFunction)

func RegisterCommandType added in v0.4.4

func RegisterCommandType(name string, creator CommandMaker)

func RegisterParameterizedColumnFunction added in v0.4.17

func RegisterParameterizedColumnFunction(name string, m ColumnFunctionMaker)

Types

type ColumnFormatterType added in v0.4.4

type ColumnFormatterType string

func (ColumnFormatterType) GetFormatter added in v0.4.4

func (t ColumnFormatterType) GetFormatter() print.Formatter

type ColumnFunctionMaker added in v0.4.17

type ColumnFunctionMaker func(name string, args []string) (print.ColumnFunction, error)

type ColumnFunctionType added in v0.4.17

type ColumnFunctionType string

func (ColumnFunctionType) GetColumnFunction added in v0.4.17

func (t ColumnFunctionType) GetColumnFunction() (print.ColumnFunction, error)

type Command added in v0.4.4

type Command interface {
	GetAPIClient() *api.Client
	GetUnauthenticatedAPIClient() *api.Client
	PrintResult(n *jnode.Node)
	GetCobraCommand() *cobra.Command
	SetContextValues(c map[string]string)
}

type CommandMaker added in v0.4.4

type CommandMaker func(c *cobra.Command, cm *CommandModel) Command

type CommandModel

type CommandModel struct {
	Type              string            `hcl:"type,label"`
	Name              string            `hcl:"name,label"`
	Use               *string           `hcl:"use"`
	Short             *string           `hcl:"short"`
	Example           *string           `hcl:"example"`
	Aliases           *[]string         `hcl:"aliases"`
	Path              *string           `hcl:"path"`
	Method            *string           `hcl:"method"`
	Options           *[]string         `hcl:"options"`
	Parameters        []*ParameterModel `hcl:"parameter,block"`
	ParameterNames    *[]string         `hcl:"parameters"`
	ClusterIDOptional *bool             `hcl:"cluster_id_optional"`
	Unauthenticated   *bool             `hcl:"unauthenticated"`
	DefaultTimeout    *int              `hcl:"default_timeout"`
	Result            *ResultModel      `hcl:"result,block"`
	Commands          []*CommandModel   `hcl:"command,block"`
	ParameterDefs     *ParameterDefs    `hcl:"parameter_defs,block"`
	// contains filtered or unexported fields
}

func (*CommandModel) GetCommand

func (cm *CommandModel) GetCommand() Command

func (*CommandModel) GetCommandType

func (cm *CommandModel) GetCommandType() CommandType

type CommandType

type CommandType string

func (CommandType) IsGroup

func (t CommandType) IsGroup() bool

type ContextValueSupplier

type ContextValueSupplier func(string) (string, error)

type ContextValues

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

func NewContextValues added in v0.4.4

func NewContextValues() *ContextValues

func (*ContextValues) Get

func (c *ContextValues) Get(name string) (string, error)

type FileSystemSource added in v0.4.4

type FileSystemSource struct {
	Filesystem fs.FS
	RootPath   string
	Embedded   bool
}

func (*FileSystemSource) GetFileSystem added in v0.4.4

func (s *FileSystemSource) GetFileSystem() fs.FS

func (*FileSystemSource) GetPath added in v0.4.4

func (s *FileSystemSource) GetPath(name string) string

func (*FileSystemSource) GetVersion added in v0.4.4

func (s *FileSystemSource) GetVersion(name string, content []byte) string

func (*FileSystemSource) IsEmbedded added in v0.4.8

func (s *FileSystemSource) IsEmbedded() bool

func (*FileSystemSource) String added in v0.4.4

func (s *FileSystemSource) String() string

type GitSource

type GitSource struct {
	FileSystemSource
	WasFetched bool
	// contains filtered or unexported fields
}

func (*GitSource) GetVersion

func (s *GitSource) GetVersion(name string, content []byte) string

type GroupCommand added in v0.4.4

type GroupCommand struct {
	CobraCommand *cobra.Command
	Commands     []Command
}

func (*GroupCommand) GetAPIClient added in v0.4.4

func (g *GroupCommand) GetAPIClient() *api.Client

func (*GroupCommand) GetCobraCommand added in v0.4.4

func (g *GroupCommand) GetCobraCommand() *cobra.Command

func (*GroupCommand) GetUnauthenticatedAPIClient added in v0.4.4

func (g *GroupCommand) GetUnauthenticatedAPIClient() *api.Client

func (*GroupCommand) PrintResult added in v0.4.4

func (g *GroupCommand) PrintResult(n *jnode.Node)

func (*GroupCommand) SetContextValues added in v0.4.4

func (g *GroupCommand) SetContextValues(m map[string]string)

type LocalAction

type LocalAction func(command Command, n *jnode.Node) (*jnode.Node, error)

type LocalActionType added in v0.4.4

type LocalActionType string

func (LocalActionType) Run added in v0.4.4

func (a LocalActionType) Run(command Command, n *jnode.Node) (*jnode.Node, error)

type Model

type Model struct {
	Command       CommandModel `hcl:"command,block"`
	APIPrefix     string       `hcl:"api_prefix"`
	MinCLIVersion *string      `hcl:"min_cli_version"`
	FileName      string
	Version       string
	Source        Source
	// contains filtered or unexported fields
}

type OptionsCommand added in v0.4.4

type OptionsCommand struct {
	options.Interface
	ClientOpts   *options.ClientOpts
	PrintOpts    *options.PrintOpts
	CobraCommand *cobra.Command
}

OptionsCommand is a command based on the options framework

func (*OptionsCommand) GetAPIClient added in v0.4.4

func (w *OptionsCommand) GetAPIClient() *api.Client

func (*OptionsCommand) GetCobraCommand added in v0.4.4

func (w *OptionsCommand) GetCobraCommand() *cobra.Command

func (*OptionsCommand) GetUnauthenticatedAPIClient added in v0.4.4

func (w *OptionsCommand) GetUnauthenticatedAPIClient() *api.Client

func (*OptionsCommand) Initialize added in v0.4.4

func (w *OptionsCommand) Initialize(c *cobra.Command, cm *CommandModel) Command

func (*OptionsCommand) PrintResult added in v0.4.4

func (w *OptionsCommand) PrintResult(n *jnode.Node)

func (*OptionsCommand) SetContextValues added in v0.4.39

func (w *OptionsCommand) SetContextValues(ctx map[string]string)

type ParameterDefs added in v0.4.17

type ParameterDefs struct {
	Parameters []*ParameterModel `hcl:"parameter,block"`
}

type ParameterDisposition

type ParameterDisposition string

What to do with a parameter. By default the parameter is put in the query string (for GET), or in the json body (everything else.)

type ParameterModel

type ParameterModel struct {
	Name         string  `hcl:"name,label"`
	Shorthand    *string `hcl:"shorthand"`
	Usage        *string `hcl:"usage"`
	Required     *bool   `hcl:"required"`
	RepeatedFlag *bool   `hcl:"repeated"`
	MapFlag      *bool   `hcl:"map"`
	BooleanFlag  *bool   `hcl:"boolean"`
	LiteralValue *string `hcl:"literal_value"`
	ContextValue *string `hcl:"context_value"`
	DefaultValue *string `hcl:"default_value"`
	Disposition  *string `hcl:"disposition"`
}

type ResultModel

type ResultModel struct {
	Path                    *[]string          `hcl:"path"`
	TruncationIndicatorPath *[]string          `hcl:"truncation_indicator"`
	Columns                 *[]string          `hcl:"columns"`
	WideColumns             *[]string          `hcl:"wide_columns"`
	Sort                    *[]string          `hcl:"sort_by"`
	Formatters              *map[string]string `hcl:"formatters"`
	ComputedColumns         *map[string]string `hcl:"computed_columns"`
	LocalAction             *string            `hcl:"local_action"`
	LocalActions            *[]string          `hcl:"local_actions"`
	DiffColumn              *string            `hcl:"diff_column"`
	VersionColumn           *string            `hcl:"version_column"`
	DefaultOutputFormat     *string            `hcl:"default_output_format"`
}

func (*ResultModel) GetColumnFunction added in v0.4.17

func (r *ResultModel) GetColumnFunction(column string) print.ColumnFunction

func (*ResultModel) GetFormatter added in v0.4.4

func (r *ResultModel) GetFormatter(column string) print.Formatter

func (*ResultModel) GetLocalActions added in v0.4.33

func (r *ResultModel) GetLocalActions() (result []LocalActionType)

type Source

type Source interface {
	GetFileSystem() fs.FS
	GetPath(file string) string
	GetVersion(file string, content []byte) string
	String() string
	IsEmbedded() bool
}

func GetGitSource

func GetGitSource(url string) (Source, error)

Jump to

Keyboard shortcuts

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