model

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

func (*LocatedResourceStatus) GetHostName added in v0.0.2

func (l *LocatedResourceStatus) GetHostName() string

GetHostName returns the targets host name

func (*LocatedResourceStatus) GetNewVersion added in v0.0.2

func (l *LocatedResourceStatus) GetNewVersion(sessionName string) string

GetNewVersion returns the new updated version name

func (*LocatedResourceStatus) GetVersion added in v0.0.2

func (l *LocatedResourceStatus) GetVersion() string

GetVersion returns the existing version name

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 Ref

type Ref struct {
	Name             string
	Strategy         string
	Args             map[string]string
	Target           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) GetResourceStatus

func (r *Ref) GetResourceStatus(kind string) []ResourceStatus

GetResourceStatus returns a array of involved Resources based on a k8s Kind

func (*Ref) HasTarget added in v0.0.2

func (r *Ref) HasTarget(kind string) bool

HasTarget checks if current Target is of a given Kind

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
}

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
JackTT - Gopher 🇻🇳