cli

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedOutputMode if user passed unsupported output mode.
	ErrUnsupportedOutputMode = errors.New("unsupported output mode")

	// ErrInvalidFormat if user pass an un-parsable format.
	ErrInvalidFormat = errors.New("invalid format")

	// ErrCantBuildEvent if event can't be built.
	ErrCantBuildEvent = errors.New("can't build event")

	// ErrCantMarshalEvent if event can't be marshalled to text.
	ErrCantMarshalEvent = errors.New("can't marshal event")
)
View Source
var (
	// ErrUseToFlagIsRequired will be raised if user hasn't used --to flag.
	ErrUseToFlagIsRequired = errors.New("use --to flag is required")
	// ErrInvalidURLFormat will be raised if given URL is invalid.
	ErrInvalidURLFormat = errors.New("invalid URL format")
	// ErrInvalidToFormat will be raised if given addressable doesn't have a valid
	// expected format.
	ErrInvalidToFormat = errors.New("--to flag has invalid format")
)

Functions

func DefaultLoggingSetup added in v0.43.0

func DefaultLoggingSetup(logLevel zapcore.Level) func(ctx context.Context) context.Context

DefaultLoggingSetup is the default logging setup.

func InitialContext added in v0.43.0

func InitialContext() context.Context

InitialContext returns the initial context object, so it could be set ahead of time the setup is called.

func SetupOutput added in v0.43.0

func SetupOutput(cbr Cobralike, loggingSetup LoggingSetup)

SetupOutput will set the output for all CLIs commonly.

func SimplifiedLoggingSetup added in v0.43.0

func SimplifiedLoggingSetup(logLevel zapcore.Level) func(ctx context.Context) context.Context

SimplifiedLoggingSetup is just a production logger to avoid creating additional log files.

 TODO: Remove this after simplified logging is supported in
	     knative.dev/client/pkg/output/logging package.

func ValidateTarget

func ValidateTarget(args *TargetArgs) error

ValidateTarget will perform validation on App element of target.

Types

type App

type App struct {
	event.Binding
}

App object.

func (*App) CreateWithArgs

func (a *App) CreateWithArgs(args *EventArgs) (*cloudevents.Event, error)

CreateWithArgs will create an event by parsing given args.

func (*App) PresentWith

func (a *App) PresentWith(e *cloudevents.Event, output OutputMode) (string, error)

PresentWith will present an event with specified output.

func (*App) Send

func (a *App) Send(ctx context.Context, ce cloudevents.Event, tArgs TargetArgs, params *Params) error

Send will send CloudEvent to target.

type Cobralike added in v0.43.0

type Cobralike interface {
	SetContext(ctx context.Context)
	Context() context.Context
	output.Printer

	SetOut(out io.Writer)
	OutOrStderr() io.Writer
	SetErrPrefix(prefix string)
	HasParent() bool
	Parent() *cobra.Command
}

Cobralike represents a cobra.Command-like entity.

type EventArgs

type EventArgs struct {
	Type      string
	ID        string
	Source    string
	Fields    []string
	RawFields []string
}

EventArgs holds args of event to be created with.

type LoggingSetup added in v0.43.0

type LoggingSetup func(ctx context.Context) context.Context

LoggingSetup is a func that sets the logging into the context.

type OutputMode

type OutputMode enumflag.Flag

OutputMode is type of output to produce.

const (
	HumanReadable OutputMode = iota
	JSON
	YAML
)

OutputMode enumeration values.

type Params added in v0.43.0

type Params struct {
	// OutputMode define the type of output commands should be producing.
	OutputMode

	// Verbose tells should commands display additional information about
	// what's happening? Verbose information is printed on stderr.
	Verbose bool

	// Kubernetes related parameters.
	k8s.Params
}

Params holds a general args for all commands.

type PluginVersionOutput

type PluginVersionOutput struct {
	Name    string `json:"name"    yaml:"name"`
	Version string `json:"version" yaml:"version"`
	Image   string `json:"image"   yaml:"image"`
}

PluginVersionOutput is a struct that is used to output project version in machine readable format.

type TargetArgs

type TargetArgs struct {
	Sink           string
	AddressableURI string
}

TargetArgs holds args specific for even sending.

Jump to

Keyboard shortcuts

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