cmd

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 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("✗")
)

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 MarkHidden

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

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

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

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 LoadConfig

func LoadConfig(filename string) (Config, error)

LoadConfig loads the config file returns a empty config if it doesn't exist

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns a default configuration

type Factory

type Factory interface {
	// GetConfig returns the config for the cli if available
	GetConfig() (Config, bool, error)
	// GetConfigPath returns the path to the configuration file
	GetConfigPath() string
	// 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) error
	// Stdout returns the stdout io writer
	Stdout() io.Writer
}

Factory is the interface that wraps the CLI

func NewFactory

func NewFactory(streams genericclioptions.IOStreams) (Factory, error)

NewFactory creates and returns a factory for the cli

func NewFactoryWithClient

func NewFactoryWithClient(cc client.Client, streams genericclioptions.IOStreams) (Factory, error)

NewFactoryWithClient creates and returns a factory for the cli

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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