event

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultKubeconfig = "~/.kube/config"

DefaultKubeconfig is a default location of kubeconfig.

View Source
const (
	// DefaultType holds a default type for a event.
	DefaultType = "dev.knative.cli.plugin.event.generic"
)

Variables

View Source
var ErrNotYetImplemented = errors.New("not yet implemented")

ErrNotYetImplemented is an error for not yet implemented code.

Functions

func CreateFromSpec

func CreateFromSpec(spec *Spec) (*cloudevents.Event, error)

CreateFromSpec will create an event by parsing given args.

func DefaultSource

func DefaultSource() string

DefaultSource holds a default source of an event.

func NewDefault

func NewDefault() *cloudevents.Event

NewDefault creates a default CloudEvent.

func NewID

func NewID() string

NewID creates a new ID for an event.

func UnmarshalData

func UnmarshalData(bytes []byte) (map[string]interface{}, error)

UnmarshalData will take bytes and unmarshall it as JSON to map structure.

Types

type AddressableSpec added in v0.2.0

type AddressableSpec struct {
	*tracker.Reference
	URI             *apis.URL
	SenderNamespace string
}

AddressableSpec specify destination of a event to be sent, as well as sender namespace that should be used to create a sender Job in.

type Binding added in v0.3.0

type Binding struct {
	CreateSender
}

Binding holds injectable dependencies.

func (Binding) NewSender added in v0.3.0

func (b Binding) NewSender(target *Target) (Sender, error)

NewSender will create a sender that can send event to cluster.

type CreateSender added in v0.3.0

type CreateSender func(target *Target) (Sender, error)

CreateSender creates a Sender.

type FieldSpec

type FieldSpec struct {
	Path  string
	Value interface{}
}

FieldSpec holds a specification of a event's data field.

type KnPluginOptions added in v0.2.0

type KnPluginOptions struct {
	// KnConfig holds kn configuration file (default: ~/.config/kn/config.yaml)
	KnConfig string

	// Kubeconfig holds kubectl configuration file (default: ~/.kube/config)
	Kubeconfig string

	// LogHTTP tells if kn-event plugin should log HTTP requests it makes
	LogHTTP bool
}

KnPluginOptions holds options inherited to every Kn plugin.

type Properties added in v0.2.0

type Properties struct {
	KnPluginOptions
	Log *zap.SugaredLogger
}

Properties holds a general properties.

type Sender added in v0.2.0

type Sender interface {
	// Send will send cloudevents.Event to configured target, or return an error
	// if one occur.
	Send(ce cloudevents.Event) error
}

Sender will send event to specified target.

type Spec

type Spec struct {
	Type   string
	ID     string
	Source string
	Fields []FieldSpec
}

Spec holds specification of event to be created.

func (*Spec) AddField

func (s *Spec) AddField(path string, val interface{})

AddField will add a field to the spec.

type Target added in v0.2.0

type Target struct {
	Type           TargetType
	URLVal         *url.URL
	AddressableVal *AddressableSpec
	*Properties
}

Target is a target to send event to.

type TargetType added in v0.2.0

type TargetType int

TargetType specify a type of a event target.

const (
	// TargetTypeReachable specify a type of event target that is network
	// reachable, and direct HTTP communication can be performed.
	TargetTypeReachable TargetType = iota

	// TargetTypeAddressable represent a type of event target that is cluster
	// private, and direct communication can't be performed. In this case in
	// cluster sender Job will be created to send the event.
	TargetTypeAddressable
)

Jump to

Keyboard shortcuts

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