model

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StrategyExisting holds the name of the existing strategy
	StrategyExisting = "existing"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HostName added in v0.0.3

type HostName struct {
	Name      string
	Namespace string
}

HostName represents the Hostname of a service in a given namespace.

func (*HostName) Match added in v0.0.3

func (h *HostName) Match(name string) bool

Match returns true if this Hostname is equal to the short or long v of a dns name.

type LocatedResourceStatus added in v0.0.2

type LocatedResourceStatus struct {
	ResourceStatus

	Labels map[string]string
}

LocatedResourceStatus is a ResourceStatus with labels.

func NewLocatedResource added in v0.0.2

func NewLocatedResource(kind, name string, labels map[string]string) LocatedResourceStatus

NewLocatedResource is a simple helper to create LocatedResourceStatus.

type Locator

type Locator func(SessionContext, *Ref) bool

Locator should attempt to resolve a Ref.Name to a target Named kind, e.g. Deployment, DeploymentConfig. return false if nothing was found.

type Mutator

type Mutator func(SessionContext, *Ref) error

Mutator should create/modify a target Kind as required as needed * Add status to Ref for storage, failed or not.

type Predicate added in v0.0.4

type Predicate func(ResourceStatus) bool

Predicate base function to filter Resources.

func All added in v0.0.4

func All(predicates ...Predicate) Predicate

All Predicate returns true if all of the predicates match.

func Any added in v0.0.4

func Any(predicates ...Predicate) Predicate

Any Predicate returns true if any of the predicates match.

func AnyKind added in v0.0.4

func AnyKind(kinds ...string) Predicate

AnyKind is a shortcut Predicate for Any and Kind from strings.

func Kind added in v0.0.4

func Kind(kind string) Predicate

Kind Predicate returns true if kind matches resource.

func Name added in v0.0.4

func Name(name string) Predicate

Name Predicate returns true if name matches resource.

type Ref

type Ref struct {
	Name             string
	Namespace        string
	Strategy         string
	Args             map[string]string
	Targets          []LocatedResourceStatus
	ResourceStatuses []ResourceStatus
}

Ref references to a single Reference, e.g. Deployment, DeploymentConfig or GitRepo.

func (*Ref) AddResourceStatus

func (r *Ref) AddResourceStatus(ref ResourceStatus)

AddResourceStatus adds the status of an involved Resource to this ref.

func (*Ref) AddTargetResource added in v0.0.3

func (r *Ref) AddTargetResource(ref LocatedResourceStatus)

AddTargetResource adds the status of an involved Resource to this ref.

func (*Ref) GetNewVersion added in v0.0.3

func (r *Ref) GetNewVersion(sessionName string) string

GetNewVersion returns the new updated version name.

func (*Ref) GetResources added in v0.0.4

func (r *Ref) GetResources(predicate Predicate) []ResourceStatus

GetResources use a Predicate to filter the ResourceStatus.

func (*Ref) GetTargetHostNames added in v0.0.3

func (r *Ref) GetTargetHostNames() []HostName

GetTargetHostNames returns a list of Host names that the target Deployment can be reached under.

func (*Ref) GetTargets added in v0.0.4

func (r *Ref) GetTargets(predicate Predicate) []LocatedResourceStatus

GetTargets use a Predicate to filter the LocatedResourceStatus.

func (*Ref) GetVersion added in v0.0.3

func (r *Ref) GetVersion() string

GetVersion returns the existing version name.

func (*Ref) RemoveResourceStatus

func (r *Ref) RemoveResourceStatus(ref ResourceStatus)

RemoveResourceStatus removes the status of an involved Resource to this ref.

type ResourceAction

type ResourceAction string

ResourceAction describes which type of operation was done/attempted to the target resource. Used to determine how to undo it.

const (
	// ActionCreated imply the whole Named Kind was created and can be deleted
	ActionCreated ResourceAction = "created"
	// ActionModified imply the Named Kind has been modified and needs to be reverted to get back to original state
	ActionModified ResourceAction = "modified"
	// ActionFailed imply what ever was attempted failed. Assume current state is ok in clean up?
	ActionFailed ResourceAction = "failed"
	// ActionLocated imply the resource was found, but nothing was changed.
	ActionLocated ResourceAction = "located"
)

type ResourceStatus

type ResourceStatus struct {
	Kind string
	Name string
	// created, mutated, failed
	Action ResourceAction
	Prop   map[string]string
}

ResourceStatus holds information about the resources created/changed to fulfill a Ref.

type Revertor

type Revertor func(SessionContext, *Ref) error

Revertor should delete/modify a target Kind to return to the original state after a Mutator * Remove status from Ref unless there is a failure that requires retry.

type Route

type Route struct {
	Type  string
	Name  string
	Value string
}

Route references the strategy used to route to the target Refs.

type SessionContext

type SessionContext struct {
	context.Context

	Name      string
	Namespace string
	Route     Route
	Client    client.Client
	Log       logr.Logger
}

SessionContext holds the context for a single session object, giving access to key things like REST Client and target Namespace.

Jump to

Keyboard shortcuts

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