cli

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 18 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 (
	// ErrCantUseBothToURLAndToFlags will be raised if user use both --to and
	// --to-url flags.
	ErrCantUseBothToURLAndToFlags = errors.New("can't use both --to and --to-url flags")
	// ErrUseToURLOrToFlagIsRequired will be raised if user didn't used --to or
	// --to-url flags.
	ErrUseToURLOrToFlagIsRequired = errors.New("use --to or --to-url 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 valid
	// expected format.
	ErrInvalidToFormat = errors.New("--to flag needs to be in format " +
		"kind:apiVersion:name for named resources or " +
		"kind:apiVersion:labelKey1=value1,labelKey2=value2 for matching via " +
		"a label selector")
)

Functions

func ValidateTarget

func ValidateTarget(args *TargetArgs) error

ValidateTarget will perform validation on App element of target.

Types

type App

type App struct {
	event.Binding
	system.Environment
}

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(ce cloudevents.Event, target TargetArgs, options *Options) error

Send will send CloudEvent to target.

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 Options

type Options struct {
	event.KnPluginOptions

	// Output define type of output commands should be producing.
	Output OutputMode

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

Options holds a general args for all commands.

func (*Options) WithLogger

func (opts *Options) WithLogger(outputs system.Outputs) (*event.Properties, error)

WithLogger will create an event suitable Options from CLI ones.

type OutputMode

type OutputMode enumflag.Flag

OutputMode is type of output to produce.

const (
	HumanReadable OutputMode = iota
	JSON
	YAML
)

OutputMode enumeration values.

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 {
	URL             string
	Addressable     string
	Namespace       string
	SenderNamespace string
	AddressableURI  string
}

TargetArgs holds args specific for even sending.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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