cmd

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Human Format = "human" // Headers, indentation, justification etc.
	Plain        = "plain" // Suitable for cli automation via sed/awk etc.
	JSON         = "json"  // Technically a ⊆ yaml, but no one likes yaml.
	YAML         = "yaml"
	URL          = "url"
)
View Source
const DefaultNamespace = "default"

DefaultNamespace is the global static default namespace, and is equivalent to the Kubernetes default namespace.

View Source
const DefaultVersion = "v0.0.0+source"

DefaultVersion when building source directly (bypassing the Makefile)

Variables

View Source
var ErrNameAndPathConflict = errors.New("cannot specify both name and path")
View Source
var ErrTemplateRepoDoesNotExist = errors.New("template repo does not exist")

ErrTemplateRepoDoesNotExist is a sentinel error if a template repository responds with 404 status code

Functions

func CompleteBuilderImageList

func CompleteBuilderImageList(cmd *cobra.Command, args []string, complete string) (builderImages []string, directive cobra.ShellCompDirective)

func CompleteBuilderList

func CompleteBuilderList(cmd *cobra.Command, args []string, complete string) (matches []string, d cobra.ShellCompDirective)

func CompleteDeployerList added in v0.48.0

func CompleteDeployerList(cmd *cobra.Command, args []string, complete string) (matches []string, d cobra.ShellCompDirective)

func CompleteFunctionList

func CompleteFunctionList(cmd *cobra.Command, args []string, toComplete string) (strings []string, directive cobra.ShellCompDirective)

func CompleteOutputFormatList

func CompleteOutputFormatList(cmd *cobra.Command, args []string, toComplete string) (strings []string, directive cobra.ShellCompDirective)

func CompleteRegistryList

func CompleteRegistryList(cmd *cobra.Command, args []string, toComplete string) (strings []string, directive cobra.ShellCompDirective)

func CompleteRuntimeList

func CompleteRuntimeList(cmd *cobra.Command, args []string, toComplete string, client *fn.Client) (matches []string, directive cobra.ShellCompDirective)

func CompleteTemplateList

func CompleteTemplateList(cmd *cobra.Command, args []string, toComplete string, client *fn.Client) (matches []string, directive cobra.ShellCompDirective)

func KnownBuilders

func KnownBuilders() builders.Known

KnownBuilders are a typed string slice of builder short names which this CLI understands. Includes a customized String() representation intended for use in flags and help text.

func NewBuildCmd

func NewBuildCmd(newClient ClientFactory) *cobra.Command

func NewClient

func NewClient(cfg ClientConfig, options ...fn.Option) (*fn.Client, func())

NewClient constructs an fn.Client with the majority of the concrete implementations set. Provide additional Options to this constructor to override or augment as needed, or override the ClientFactory passed to commands entirely to mock for testing. Note the returned cleanup function. 'Namespace' is optional. If not provided (see DefaultNamespace commentary), the currently configured is used. 'Verbose' indicates the system should write out a higher amount of logging.

func NewCompletionCmd

func NewCompletionCmd() *cobra.Command

func NewConfigCICmd added in v0.48.0

func NewConfigCICmd(
	loaderSaver common.FunctionLoaderSaver,
	writer ci.WorkflowWriter,
	currentBranch common.CurrentBranchFunc,
	workingDir common.WorkDirFunc,
) *cobra.Command

func NewConfigCmd

func NewConfigCmd(
	loaderSaver common.FunctionLoaderSaver,
	writer ci.WorkflowWriter,
	currentBranch common.CurrentBranchFunc,
	workingDir common.WorkDirFunc,
	newClient ClientFactory,
) *cobra.Command

func NewConfigEnvsAddCmd

func NewConfigEnvsAddCmd(loadSaver common.FunctionLoaderSaver) *cobra.Command

func NewConfigEnvsCmd

func NewConfigEnvsCmd(loadSaver common.FunctionLoaderSaver) *cobra.Command

func NewConfigEnvsRemoveCmd

func NewConfigEnvsRemoveCmd(loadSaver common.FunctionLoaderSaver) *cobra.Command

func NewConfigGitCmd added in v0.37.0

func NewConfigGitCmd(newClient ClientFactory) *cobra.Command

func NewConfigGitRemoveCmd added in v0.37.0

func NewConfigGitRemoveCmd(newClient ClientFactory) *cobra.Command

func NewConfigGitSetCmd added in v0.37.0

func NewConfigGitSetCmd(newClient ClientFactory) *cobra.Command

func NewConfigLabelsCmd

func NewConfigLabelsCmd(loaderSaver common.FunctionLoaderSaver) *cobra.Command

func NewConfigVolumesAddCmd

func NewConfigVolumesAddCmd() *cobra.Command

func NewConfigVolumesCmd

func NewConfigVolumesCmd() *cobra.Command

func NewConfigVolumesRemoveCmd

func NewConfigVolumesRemoveCmd() *cobra.Command

func NewCreateCmd

func NewCreateCmd(newClient ClientFactory) *cobra.Command

NewCreateCmd creates a create command using the given client creator.

func NewDeleteCmd

func NewDeleteCmd(newClient ClientFactory) *cobra.Command

func NewDeployCmd

func NewDeployCmd(newClient ClientFactory) *cobra.Command

func NewDescribeCmd added in v0.36.0

func NewDescribeCmd(newClient ClientFactory) *cobra.Command

func NewEnvironmentCmd added in v0.37.1

func NewEnvironmentCmd(newClient ClientFactory, version *Version) *cobra.Command

func NewErrClusterNotAccessible added in v0.48.0

func NewErrClusterNotAccessible(err error) error

func NewErrConflictImageRegistry added in v0.48.0

func NewErrConflictImageRegistry(err error, cmd string) error

func NewErrInvalidAddress added in v0.48.0

func NewErrInvalidAddress(err error, address string) error

func NewErrInvalidDomain added in v0.48.0

func NewErrInvalidDomain(err error, cmd string) error

func NewErrInvalidKubeconfig added in v0.48.0

func NewErrInvalidKubeconfig(err error) error

func NewErrInvalidNamespace added in v0.48.0

func NewErrInvalidNamespace(err error, cmd string) error

func NewErrInvalidPort added in v0.48.0

func NewErrInvalidPort(err error, port string) error

func NewErrListClusterConnection added in v0.48.0

func NewErrListClusterConnection(err error) error

func NewErrNotInitialized added in v0.48.0

func NewErrNotInitialized(err error, cmd string) error

NewErrNotInitialized wraps an existing error (e.g., caught from a bubbled-up call)

func NewErrNotInitializedFromPath added in v0.48.0

func NewErrNotInitializedFromPath(path, cmd string) error

NewErrNotInitializedFromPath creates the error directly when detecting uninitialized state

func NewErrPlatformNotSupported added in v0.48.0

func NewErrPlatformNotSupported(err error, cmd string) error

func NewErrPortPermissionDenied added in v0.48.0

func NewErrPortPermissionDenied(port, address string) error

func NewErrPortUnavailable added in v0.48.0

func NewErrPortUnavailable(err error, port string) error

func NewErrRegistryRequired added in v0.48.0

func NewErrRegistryRequired(err error, cmd string) error

func NewInvokeCmd

func NewInvokeCmd(newClient ClientFactory) *cobra.Command

func NewLanguagesCmd

func NewLanguagesCmd(newClient ClientFactory) *cobra.Command

func NewListCmd

func NewListCmd(newClient ClientFactory) *cobra.Command

func NewMCPCmd added in v0.48.0

func NewMCPCmd(newClient ClientFactory) *cobra.Command

func NewMCPStartCmd added in v0.48.0

func NewMCPStartCmd(newClient ClientFactory) *cobra.Command

func NewRegistryValidator

func NewRegistryValidator(path string) survey.Validator

func NewRepositoryAddCmd

func NewRepositoryAddCmd(newClient ClientFactory) *cobra.Command

func NewRepositoryCmd

func NewRepositoryCmd(newClient ClientFactory) *cobra.Command

func NewRepositoryListCmd

func NewRepositoryListCmd(newClient ClientFactory) *cobra.Command

func NewRepositoryRemoveCmd

func NewRepositoryRemoveCmd(newClient ClientFactory) *cobra.Command

func NewRepositoryRenameCmd

func NewRepositoryRenameCmd(newClient ClientFactory) *cobra.Command

func NewRootCmd

func NewRootCmd(cfg RootCommandConfig) *cobra.Command

NewRootCmd creates the root of the command tree defines the command name, description, globally available flags, etc. It has no action of its own, such that running the resultant binary with no arguments prints the help/usage text.

func NewRunCmd

func NewRunCmd(newClient ClientFactory) *cobra.Command

func NewSubscribeCmd added in v0.40.0

func NewSubscribeCmd() *cobra.Command

func NewTektonClusterTasksCmd added in v0.42.0

func NewTektonClusterTasksCmd() *cobra.Command

func NewTemplatesCmd

func NewTemplatesCmd(newClient ClientFactory) *cobra.Command

func NewVersionCmd

func NewVersionCmd(version Version) *cobra.Command

func RuntimeTemplateOptions

func RuntimeTemplateOptions(client *fn.Client) (string, error)

RuntimeTemplateOptions is a human-friendly table of valid Language Runtime to Template combinations. Exported for use in docs.

func ValidateBuilder

func ValidateBuilder(name string) (err error)

ValidateBuilder ensures that the given builder is one that the CLI knows how to instantiate, returning a builkder.ErrUnknownBuilder otherwise.

Types

type ClientConfig

type ClientConfig struct {
	// Verbose logging.  By default, logging output is kept to the bare minimum.
	// Use this flag to configure verbose logging throughout.
	Verbose bool

	// Allow insecure server connections when using SSL
	InsecureSkipVerify bool
}

ClientConfig settings for use with NewClient These are the minimum settings necessary to create the default client instance which has most subsystems initialized.

type ClientFactory

type ClientFactory func(ClientConfig, ...fn.Option) (*fn.Client, func())

ClientFactory defines a constructor which assists in the creation of a Client for use by commands. See the NewClient constructor which is the fully populated ClientFactory used by commands by default. See NewClientFactory which constructs a minimal ClientFactory for use during testing.

func NewTestClient added in v0.36.0

func NewTestClient(options ...fn.Option) ClientFactory

NewTestClient returns a client factory which will ignore options used, instead using those provided when creating the factory. This allows for tests to create an entirely default client but with N mocks.

type Environment added in v0.37.1

type Environment struct {
	Version              string
	GitRevision          string
	SpecVersion          string
	SocatImage           string
	TarImage             string
	FuncUtilsImage       string
	DeployerImage        string
	ScaffoldImage        string
	S2IImage             string
	Languages            []string
	DefaultImageBuilders map[string]map[string]string
	Templates            map[string][]string
	Environment          []string
	Cluster              string
	Defaults             config.Global
	Function             *functions.Function `json:",omitempty" yaml:",omitempty"`
	Instance             *functions.Instance `json:",omitempty" yaml:",omitempty"`
}

type ErrClusterNotAccessible added in v0.48.0

type ErrClusterNotAccessible struct {
	Err error
}

func (*ErrClusterNotAccessible) Error added in v0.48.0

func (e *ErrClusterNotAccessible) Error() string

func (*ErrClusterNotAccessible) Unwrap added in v0.48.0

func (e *ErrClusterNotAccessible) Unwrap() error

type ErrConflictImageRegistry added in v0.48.0

type ErrConflictImageRegistry struct {
	Err error
	Cmd string
}

-------------------------------------------------------------------------- //

func (*ErrConflictImageRegistry) Error added in v0.48.0

func (e *ErrConflictImageRegistry) Error() string

func (*ErrConflictImageRegistry) Unwrap added in v0.48.0

func (e *ErrConflictImageRegistry) Unwrap() error

type ErrDeleteNameRequired added in v0.47.0

type ErrDeleteNameRequired struct {
	// Underlying error from the core library (e.g., fn.ErrNameRequired)
	Err error
}

ErrDeleteNameRequired wraps core library errors with CLI-specific context for delete operations that require a function name or path.

func NewErrDeleteNameRequired added in v0.47.0

func NewErrDeleteNameRequired(err error) ErrDeleteNameRequired

NewErrDeleteNameRequired creates a new ErrDeleteNameRequired wrapping the given error

func (ErrDeleteNameRequired) Error added in v0.47.0

func (e ErrDeleteNameRequired) Error() string

Error implements the error interface with CLI-specific help text

type ErrInvalidAddress added in v0.48.0

type ErrInvalidAddress struct {
	Err     error
	Address string
}

func (*ErrInvalidAddress) Error added in v0.48.0

func (e *ErrInvalidAddress) Error() string

func (*ErrInvalidAddress) Unwrap added in v0.48.0

func (e *ErrInvalidAddress) Unwrap() error

type ErrInvalidDomain added in v0.48.0

type ErrInvalidDomain struct {
	Err error
	Cmd string
}

func (*ErrInvalidDomain) Error added in v0.48.0

func (e *ErrInvalidDomain) Error() string

func (*ErrInvalidDomain) Unwrap added in v0.48.0

func (e *ErrInvalidDomain) Unwrap() error

type ErrInvalidKubeconfig added in v0.48.0

type ErrInvalidKubeconfig struct {
	Err error
}

func (*ErrInvalidKubeconfig) Error added in v0.48.0

func (e *ErrInvalidKubeconfig) Error() string

func (*ErrInvalidKubeconfig) Unwrap added in v0.48.0

func (e *ErrInvalidKubeconfig) Unwrap() error

type ErrInvalidNamespace added in v0.48.0

type ErrInvalidNamespace struct {
	Err error
	Cmd string
}

-------------------------------------------------------------------------- //

func (*ErrInvalidNamespace) Error added in v0.48.0

func (e *ErrInvalidNamespace) Error() string

func (*ErrInvalidNamespace) Unwrap added in v0.48.0

func (e *ErrInvalidNamespace) Unwrap() error

type ErrInvalidPort added in v0.48.0

type ErrInvalidPort struct {
	Err  error
	Port string
}

func (*ErrInvalidPort) Error added in v0.48.0

func (e *ErrInvalidPort) Error() string

func (*ErrInvalidPort) Unwrap added in v0.48.0

func (e *ErrInvalidPort) Unwrap() error

type ErrInvalidRuntime

type ErrInvalidRuntime error

ErrInvalidRuntime indicates that the passed language runtime was invalid.

type ErrInvalidTemplate

type ErrInvalidTemplate error

ErrInvalidTemplate indicates that the passed template was invalid.

type ErrListClusterConnection added in v0.48.0

type ErrListClusterConnection struct {
	Err error
}

func (*ErrListClusterConnection) Error added in v0.48.0

func (e *ErrListClusterConnection) Error() string

func (*ErrListClusterConnection) Unwrap added in v0.48.0

func (e *ErrListClusterConnection) Unwrap() error

type ErrNoRuntime

type ErrNoRuntime error

ErrNoRuntime indicates that the language runtime flag was not passed.

type ErrNotInitialized added in v0.48.0

type ErrNotInitialized struct {
	Err error
	Cmd string
}

func (*ErrNotInitialized) Error added in v0.48.0

func (e *ErrNotInitialized) Error() string

func (*ErrNotInitialized) Unwrap added in v0.48.0

func (e *ErrNotInitialized) Unwrap() error

type ErrPlatformNotSupported added in v0.48.0

type ErrPlatformNotSupported struct {
	Err error
	Cmd string
}

func (*ErrPlatformNotSupported) Error added in v0.48.0

func (e *ErrPlatformNotSupported) Error() string

func (*ErrPlatformNotSupported) Unwrap added in v0.48.0

func (e *ErrPlatformNotSupported) Unwrap() error

type ErrPortPermissionDenied added in v0.48.0

type ErrPortPermissionDenied struct {
	Err     error
	Port    string
	Address string
}

func (*ErrPortPermissionDenied) Error added in v0.48.0

func (e *ErrPortPermissionDenied) Error() string

func (*ErrPortPermissionDenied) Unwrap added in v0.48.0

func (e *ErrPortPermissionDenied) Unwrap() error

type ErrPortUnavailable added in v0.48.0

type ErrPortUnavailable struct {
	Err  error
	Port string
}

func (*ErrPortUnavailable) Error added in v0.48.0

func (e *ErrPortUnavailable) Error() string

func (*ErrPortUnavailable) Unwrap added in v0.48.0

func (e *ErrPortUnavailable) Unwrap() error

type ErrRegistryRequired

type ErrRegistryRequired struct {
	Err error
	Cmd string
}

func (*ErrRegistryRequired) Error added in v0.48.0

func (e *ErrRegistryRequired) Error() string

func (*ErrRegistryRequired) Unwrap added in v0.48.0

func (e *ErrRegistryRequired) Unwrap() error

type Format

type Format string

type Formatter

type Formatter interface {
	Human(io.Writer) error
	Plain(io.Writer) error
	JSON(io.Writer) error
	YAML(io.Writer) error
	URL(io.Writer) error
}

formatter is any structure which has methods for serialization.

type MiddlewareVersions added in v0.48.0

type MiddlewareVersions map[string]map[string]string

func (MiddlewareVersions) String added in v0.48.0

func (mv MiddlewareVersions) String() string

type RootCommandConfig

type RootCommandConfig struct {
	Name string // usually `func` or `kn func`
	Version
	NewClient ClientFactory
}

type Version

type Version struct {
	// Version tag of the git commit, or 'tip' if no tag.
	Vers string `json:"version,omitempty" yaml:"version,omitempty"`
	// Kver is the version of knative in which func was most recently
	// If the build is not tagged as being released with a specific Knative
	// build, this is the most recent version of knative along with a suffix
	// consisting of the number of commits which have been added since it was
	// included in Knative.
	Kver string `json:"knative,omitempty" yaml:"knative,omitempty"`
	// Hash of the currently active git commit on build.
	Hash string `json:"commit,omitempty" yaml:"commit,omitempty"`
	// SocatImage is the socat image used by the function.
	SocatImage string `json:"socatImage,omitempty" yaml:"socatImage,omitempty"`
	// TarImage is the tar image used by the function.
	TarImage string `json:"tarImage,omitempty" yaml:"tarImage,omitempty"`
	// MiddlewareVersions provides information about the latest middleware version
	// for a given platform and invokeType
	MiddlewareVersions MiddlewareVersions `json:"middlewareVersions,omitempty" yaml:"middlewareVersions,omitempty"`

	// Verbose printing enabled for the string representation.
	Verbose bool `json:"-" yaml:"-"`
}

Version information populated on build.

func (Version) Human added in v0.48.0

func (v Version) Human(w io.Writer) error

Human prints version information in human-readable format.

func (Version) JSON added in v0.48.0

func (v Version) JSON(w io.Writer) error

JSON prints version information in JSON format.

func (Version) Plain added in v0.48.0

func (v Version) Plain(w io.Writer) error

Plain prints version information in plain format (same as human for version).

func (Version) String

func (v Version) String() string

Return the stringification of the Version struct.

func (Version) StringVerbose

func (v Version) StringVerbose() string

StringVerbose returns the version along with extended version metadata.

func (Version) URL added in v0.48.0

func (v Version) URL(w io.Writer) error

URL is not supported for version command.

func (Version) YAML added in v0.48.0

func (v Version) YAML(w io.Writer) error

YAML prints version information in YAML format.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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