model

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCreatedVersion added in v0.4.0

func GetCreatedVersion(store LocatorStatusStore, sessionName string) string

GetCreatedVersion returns the new calculated version for the created resources if any. Returns unknown if not found.

func GetDeletedVersion added in v0.4.0

func GetDeletedVersion(store LocatorStatusStore) string

GetDeletedVersion returns the version for the deleted resources if any. Returns unknown if not found.

func GetSha added in v0.0.9

func GetSha(version string) string

GetSha computes a hash of the version and returns 8 characters substring of it.

func GetVersion added in v0.4.0

func GetVersion(store LocatorStatusStore) string

GetVersion returns the version for the created resources if any. Returns unknown if not found.

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 GetTargetHostNames added in v0.4.0

func GetTargetHostNames(store LocatorStatusStore) []HostName

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

func NewHostName added in v0.4.0

func NewHostName(host string) HostName

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.

func (*HostName) String added in v0.3.0

func (h *HostName) String() string

String returns the String representation of a HostName.

type LocatedReporter added in v0.4.0

type LocatedReporter func(LocatorStatusStore)

type Locator

type Locator func(context SessionContext, ref Ref, store LocatorStatusStore, reporter LocatorStatusReporter) error

Locator should report on Resources that need some Action performed on them to satisfy the Ref.

type LocatorStatus added in v0.4.0

type LocatorStatus struct {
	Resource
	TimeStamp time.Time
	Labels    map[string]string
	Action    StatusAction
}

LocatorStatus is the action to perform an a given Resource as calculated by the Locators.

type LocatorStatusReporter added in v0.4.0

type LocatorStatusReporter func(LocatorStatus)

type LocatorStatusStore added in v0.4.0

type LocatorStatusStore func(kind ...string) []LocatorStatus

type LocatorStore added in v0.4.0

type LocatorStore struct {
	// contains filtered or unexported fields
}

func (*LocatorStore) Clear added in v0.4.0

func (l *LocatorStore) Clear()

func (*LocatorStore) Report added in v0.4.0

func (l *LocatorStore) Report(status LocatorStatus)

func (*LocatorStore) Store added in v0.4.0

func (l *LocatorStore) Store(kind ...string) []LocatorStatus

type Modificator added in v0.4.0

type Modificator func(context SessionContext, ref Ref, store LocatorStatusStore, reporter ModificatorStatusReporter)

Modificator should perform the provided action on the given Resources provided by the Locator, e.g. Modify or Revert.

type ModificatorController added in v0.4.0

type ModificatorController func(LocatorStatusStore) bool

type ModificatorRegistrar added in v0.4.0

type ModificatorRegistrar func() (targetResourceType client.Object, modificator Modificator)

type ModificatorStatus added in v0.4.0

type ModificatorStatus struct {
	LocatorStatus
	Error   error
	Success bool
	Prop    map[string]string
	Target  *Resource
}

ModificatorStatus is the status of the given Locator action after it's been attempted performed.

type ModificatorStatusReporter added in v0.4.0

type ModificatorStatusReporter func(ModificatorStatus)

type ModificatorStore added in v0.4.0

type ModificatorStore struct {
	Stored []ModificatorStatus
}

ModificatorStore Dummy impl for testing purposes.

func (*ModificatorStore) Report added in v0.4.0

func (m *ModificatorStore) Report(status ModificatorStatus)

type Ref

type Ref struct {
	KindName  RefKindName
	Remove    bool
	Namespace string
	Strategy  string
	Args      map[string]string
}

Ref references the user specified Resource target and configuration.

func (*Ref) Hash added in v0.4.0

func (r *Ref) Hash() string

Hash returns a predictable hash version for this object.

type RefKindName added in v0.1.0

type RefKindName struct {
	Kind string
	Name string
}

RefKindName is the target Resource and optional Resource Kind.

func ParseRefKindName added in v0.1.0

func ParseRefKindName(exp string) RefKindName

ParseRefKindName parses a String() representation into a Object.

func (RefKindName) String added in v0.1.0

func (r RefKindName) String() string

String returns the string formatted kind/name.

func (RefKindName) SupportsKind added in v0.1.0

func (r RefKindName) SupportsKind(kind string) bool

SupportsKind returns true if kind match or the kind is empty.

type Resource added in v0.4.0

type Resource struct {
	Namespace string
	Kind      string
	Name      string
}

func (*Resource) GetNamespaceName added in v0.5.3

func (r *Resource) GetNamespaceName() string

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 //nolint:containedctx //reason needs refactoring https://github.com/maistra/istio-workspace/issues/1100

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

func (*SessionContext) ToNamespacedName added in v0.0.8

func (s *SessionContext) ToNamespacedName() types.NamespacedName

ToNamespacedName returns a types.NamespaceName object that represents this Session.

type StatusAction added in v0.4.0

type StatusAction string

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

const (
	// ActionCreate imply the whole Named Kind should be created.
	ActionCreate StatusAction = "create"
	// ActionDelete imply the whole Named Kind was created and should be deleted.
	ActionDelete StatusAction = "delete"
	// ActionModify imply the Named Kind should be modified.
	ActionModify StatusAction = "modify"
	// ActionRevert imply the Named Kind was modified and should be reverted to original state.
	ActionRevert StatusAction = "revert"
	// ActionLocated imply the resource was found, but nothing was changed.
	ActionLocated StatusAction = "located"

	// StrategyExisting holds the name of the existing strategy.
	StrategyExisting = "existing"
)

func Flip added in v0.4.0

func Flip(action StatusAction) StatusAction

type Sync added in v0.4.0

Sync is the entry point for ensuring the desired state for the given Ref is up-to-date.

func NewSync added in v0.4.0

func NewSync(locators []Locator, modificators []Modificator) Sync

Jump to

Keyboard shortcuts

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