cmd

package
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: GPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigPathEnvName = "TNCTL_CONFIG"

ConfigPathEnvName is the name of the environment variable that holds the config path

Variables

View Source
var (
	// IconHelp is the help icon
	IconHelp = color.GreenString("?")
	// IconGood indicates a successful action
	IconGood = color.GreenString("✓")
	// IconBad indicates a failed action
	IconBad = color.RedString("✗")
)
View Source
var ErrNoConfigurationProvider = errors.New("no configuration provider defined")

ErrNoConfigurationProvider is returned when no configuration provider is defined

Functions

func ConfigPath

func ConfigPath() string

ConfigPath returns the path to the config file

func ErrMissingArgument

func ErrMissingArgument(argument string) error

ErrMissingArgument is returned when a required argument is missing error

func ListAvailableProviders added in v0.3.14

func ListAvailableProviders(ctx context.Context, factory Factory) ([]string, error)

ListAvailableProviders returns a list of available providers in the cluster

func MarkHidden

func MarkHidden(cmd *cobra.Command, name string)

MarkHidden marks a command as hidden and panics if an error is thrown

func NewTableWriter added in v0.3.14

func NewTableWriter(out io.Writer) *tablewriter.Table

NewTableWriter returns a default table writer

func RegisterFlagCompletionFunc

func RegisterFlagCompletionFunc(cmd *cobra.Command, name string, fn AutoCompletionFunc)

RegisterFlagCompletionFunc registers a completion function for a flag

Types

type AutoCompletionFunc

type AutoCompletionFunc func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

AutoCompletionFunc is a function that returns a list of completions

func AutoCompleteConfigurations

func AutoCompleteConfigurations(factory Factory) AutoCompletionFunc

AutoCompleteConfigurations registers a completion function for a flag

func AutoCompleteNamespaces

func AutoCompleteNamespaces(factory Factory) AutoCompletionFunc

AutoCompleteNamespaces registers a completion function for a flag

func AutoCompleteWithList

func AutoCompleteWithList(list []string) AutoCompletionFunc

AutoCompleteWithList registers a completion function for a flag

func AutoCompletionAvailableProviders added in v0.3.14

func AutoCompletionAvailableProviders(factory Factory) AutoCompletionFunc

AutoCompletionAvailableProviders returns a list of available providers in the cluster

type Config

type Config struct {
	// Workflow is the location of the workflow templates. This should point
	// the git repository that contains the templates. It is assumed the user
	// consuming these templates already has access the repository setup on
	// the machine and able to clone.
	// Example: https://github.com/appvia/terranetes-workflows. Note, if a
	// ref=TAG is not set, we will query the repository for the latest tag
	// (Github only)
	Workflow string `json:"workflow,omitempty"`
	// Sources defines a list of sources which the search command should
	// search terraform modules from. Currently we support the public
	// terraform registry and any Github user or organization.
	Sources []string `json:"sources,omitempty" yaml:"sources,omitempty"`
}

Config is the configuration for the tnctl command

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns a default configuration

type ConfigInterface added in v0.3.3

type ConfigInterface interface {
	// GetConfig returns the config for the cli if available
	GetConfig() (Config, error)
	// HasConfig return true if the config has been defined
	HasConfig() (bool, error)
	// SaveConfig saves the configuration to the file
	SaveConfig(Config) error
}

ConfigInterface is the interface that must be implemented by the config struct

func NewFileConfiguration added in v0.3.3

func NewFileConfiguration(filename string) ConfigInterface

NewFileConfiguration creates and returns a file configuration

type Factory

type Factory interface {
	// GetConfig returns the config for the cli if available
	GetConfig() (Config, bool, error)
	// GetClient returns the client for the kubernetes api
	GetClient() (client.Client, error)
	// GetKubeClient returns the kubernetes client
	GetKubeClient() (k8sclient.Interface, error)
	// GetStreams returns the input and output streams for the command
	GetStreams() genericclioptions.IOStreams
	// Printf prints a message to the output stream
	Printf(format string, a ...interface{})
	// Println prints a message to the output stream
	Println(format string, a ...interface{})
	// SaveConfig saves the configuration to the file
	SaveConfig(config Config) error
	// Stdout returns the stdout io writer
	Stdout() io.Writer
}

Factory is the interface that wraps the CLI

func NewFactory

func NewFactory(options ...OptionFunc) (Factory, error)

NewFactory creates and returns a factory for the cli

type OptionFunc added in v0.3.3

type OptionFunc func(f *factory)

OptionFunc is the function type for the option function

func WithClient added in v0.3.3

func WithClient(client client.Client) OptionFunc

WithClient sets the kubernetes client

func WithConfiguration added in v0.3.3

func WithConfiguration(config ConfigInterface) OptionFunc

WithConfiguration sets the configuration provider

func WithStreams added in v0.3.3

func WithStreams(stream genericclioptions.IOStreams) OptionFunc

WithStreams sets the stream

Jump to

Keyboard shortcuts

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