registry

package
v0.0.0-...-c26f926 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 13 Imported by: 7

Documentation

Index

Constants

View Source
const (
	SourceApp        = "app"
	SourceDependency = "dependency"
	SourcePlugin     = "plugin"
)

Variables

This section is empty.

Functions

func PlanActionFromDiff

func PlanActionFromDiff(diff []*Diff) []*apiv1.PlanAction

Types

type Diff

type Diff struct {
	Object   *ResourceWrapper
	Type     DiffType
	Fields   []string
	Critical bool
	// contains filtered or unexported fields
}

func NewDiff

func NewDiff(o *ResourceWrapper, t DiffType, fieldList []string) *Diff

func (*Diff) Applied

func (d *Diff) Applied() bool

func (*Diff) AppliedSteps

func (d *Diff) AppliedSteps() int

func (*Diff) IsApplied

func (d *Diff) IsApplied(steps int) bool

func (*Diff) MarkStepAsApplied

func (d *Diff) MarkStepAsApplied()

func (*Diff) ObjectType

func (d *Diff) ObjectType() string

func (*Diff) RequiredSteps

func (d *Diff) RequiredSteps() int

func (*Diff) SetApplied

func (d *Diff) SetApplied(step int)

func (*Diff) ToApplyAction

func (d *Diff) ToApplyAction(step, total int) *apiv1.ApplyAction

func (*Diff) ToPlanAction

func (d *Diff) ToPlanAction() *apiv1.PlanAction

func (*Diff) Wait

func (d *Diff) Wait(steps int)

func (*Diff) WaitContext

func (d *Diff) WaitContext(ctx context.Context, steps int) error

type DiffType

type DiffType int
const (
	DiffTypeNone DiffType = iota + 1
	DiffTypeCreate
	DiffTypeUpdate
	DiffTypeRecreate
	DiffTypeDelete
	DiffTypeProcess
)

type FieldInfo

type FieldInfo struct {
	Type  *FieldTypeInfo
	Value reflect.Value
}

type FieldProperties

type FieldProperties struct {
	Ignored  bool // ignore from state
	ForceNew bool // any change of this field forces new resource
	Computed bool // computed field disallows user input and is created by resource itself
	HardLink bool // dependencies of this field cannot be removed (propagates recreate)
}

type FieldTypeInfo

type FieldTypeInfo struct {
	ReflectType reflect.StructField
	Properties  *FieldProperties
	Default     string
	DefaultSet  bool
}

type Options

type Options struct {
	Read            bool
	Destroy         bool
	AllowDuplicates bool
}

type Registry

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

func NewRegistry

func NewRegistry(opts *Options) *Registry

func (*Registry) Apply

func (r *Registry) Apply(ctx context.Context, meta interface{}, diff []*Diff, callback func(*apiv1.ApplyAction)) error

func (*Registry) DeregisterAppResource

func (r *Registry) DeregisterAppResource(app *apiv1.App, id string, o Resource) error

func (*Registry) DeregisterDependencyResource

func (r *Registry) DeregisterDependencyResource(dep *apiv1.Dependency, id string, o Resource) error

func (*Registry) DeregisterPluginResource

func (r *Registry) DeregisterPluginResource(scope, id string, o Resource) error

func (*Registry) Diff

func (r *Registry) Diff(ctx context.Context, meta interface{}) ([]*Diff, error)

func (*Registry) Dump

func (r *Registry) Dump() ([]byte, error)

func (*Registry) GetAppResource

func (r *Registry) GetAppResource(app *apiv1.App, id string, o Resource) (ok bool)

func (*Registry) GetDependencyResource

func (r *Registry) GetDependencyResource(dep *apiv1.Dependency, id string, o Resource) (ok bool)

func (*Registry) GetFieldDependencies

func (r *Registry) GetFieldDependencies(f fields.Field) []*ResourceWrapper

func (*Registry) GetPluginResource

func (r *Registry) GetPluginResource(scope, id string, o Resource) (ok bool)

func (*Registry) Load

func (r *Registry) Load(state []byte) error

func (*Registry) Partition

func (r *Registry) Partition(p string) *Registry

func (*Registry) Process

func (r *Registry) Process(ctx context.Context, meta interface{}) error

func (*Registry) ProcessAndDiff

func (r *Registry) ProcessAndDiff(ctx context.Context, meta interface{}) ([]*Diff, error)

func (*Registry) RegisterAppResource

func (r *Registry) RegisterAppResource(app *apiv1.App, id string, o Resource) (added bool, err error)

func (*Registry) RegisterDependencyResource

func (r *Registry) RegisterDependencyResource(dep *apiv1.Dependency, id string, o Resource) (added bool, err error)

func (*Registry) RegisterPluginResource

func (r *Registry) RegisterPluginResource(scope, id string, o Resource) (added bool, err error)

func (*Registry) RegisterType

func (r *Registry) RegisterType(o Resource)

func (*Registry) SkipAppResources

func (r *Registry) SkipAppResources(app *apiv1.App)

type Resource

type Resource interface {
	GetName() string
	Registry() *Registry
	Diff() *Diff
	Wrapper() *ResourceWrapper
	SetState(ResourceState)
	State() ResourceState

	IsRegistered() bool

	IsNew() bool
	MarkAsNew()
	IsExisting() bool
	MarkAsExisting()
	IsDeleted() bool
	MarkAsDeleted()

	SkipState() bool
	// contains filtered or unexported methods
}

type ResourceBase

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

func (*ResourceBase) Diff

func (b *ResourceBase) Diff() *Diff

func (*ResourceBase) IsDeleted

func (b *ResourceBase) IsDeleted() bool

func (*ResourceBase) IsExisting

func (b *ResourceBase) IsExisting() bool

func (*ResourceBase) IsNew

func (b *ResourceBase) IsNew() bool

func (*ResourceBase) IsRegistered

func (b *ResourceBase) IsRegistered() bool

func (*ResourceBase) Lock

func (b *ResourceBase) Lock(k string)

func (*ResourceBase) MarkAsDeleted

func (b *ResourceBase) MarkAsDeleted()

func (*ResourceBase) MarkAsExisting

func (b *ResourceBase) MarkAsExisting()

func (*ResourceBase) MarkAsNew

func (b *ResourceBase) MarkAsNew()

func (*ResourceBase) Registry

func (b *ResourceBase) Registry() *Registry

func (*ResourceBase) SetState

func (b *ResourceBase) SetState(v ResourceState)

func (*ResourceBase) SkipState

func (b *ResourceBase) SkipState() bool

func (*ResourceBase) State

func (b *ResourceBase) State() ResourceState

func (*ResourceBase) Unlock

func (b *ResourceBase) Unlock(k string)

func (*ResourceBase) Wrapper

func (b *ResourceBase) Wrapper() *ResourceWrapper

type ResourceBeforeDiffHook

type ResourceBeforeDiffHook interface {
	BeforeDiff(ctx context.Context, meta interface{}) error
}

type ResourceCUD

type ResourceCUD interface {
	Create(ctx context.Context, meta interface{}) error
	Update(ctx context.Context, meta interface{}) error
	Delete(ctx context.Context, meta interface{}) error
}

type ResourceCriticalChecker

type ResourceCriticalChecker interface {
	IsCritical(t DiffType, fieldList []string) bool
}

type ResourceDiffCalculator

type ResourceDiffCalculator interface {
	CalculateDiff(ctx context.Context, meta interface{}) (DiffType, error)
}

type ResourceID

type ResourceID struct {
	ID        string `json:"id"`
	Namespace string `json:"namespace"`
	Type      string `json:"type"`
	Source    string `json:"source"`
	Partition string `json:"partition,omitempty"`
}

func (*ResourceID) Less

func (rid *ResourceID) Less(rid2 *ResourceID) bool

type ResourceIniter

type ResourceIniter interface {
	Init(ctx context.Context, meta interface{}, opts *Options) error
}

type ResourceProcessor

type ResourceProcessor interface {
	Process(ctx context.Context, meta interface{}) error
}

type ResourceReader

type ResourceReader interface {
	Read(ctx context.Context, meta interface{}) error
}

type ResourceReference

type ResourceReference interface {
	ReferenceID() string
}

type ResourceSerialized

type ResourceSerialized struct {
	ResourceID
	IsNew        bool                   `json:"is_new,omitempty"`
	ReferenceID  string                 `json:"ref_id,omitempty"`
	Properties   map[string]interface{} `json:"properties,omitempty"`
	Dependencies []ResourceID           `json:"dependencies,omitempty"`
	DependedBy   []ResourceID           `json:"depended_by,omitempty"`
}

type ResourceState

type ResourceState int
const (
	ResourceStateNew ResourceState = iota + 1
	ResourceStateExisting
	ResourceStateDeleted
)

type ResourceTypeInfo

type ResourceTypeInfo struct {
	Type   reflect.Type
	Fields map[string]*FieldTypeInfo
}

type ResourceTypeVerbose

type ResourceTypeVerbose interface {
	GetType() string
}

type ResourceWrapper

type ResourceWrapper struct {
	ResourceID

	Fields       map[string]*FieldInfo
	DependedBy   map[*ResourceWrapper]struct{}
	Dependencies map[*ResourceWrapper]struct{}
	Resource     Resource
	IsSkipped    bool
}

func (*ResourceWrapper) FieldList

func (w *ResourceWrapper) FieldList() []string

func (*ResourceWrapper) MarkAllWantedAsCurrent

func (w *ResourceWrapper) MarkAllWantedAsCurrent()

func (*ResourceWrapper) MarshalJSON

func (w *ResourceWrapper) MarshalJSON() ([]byte, error)

func (*ResourceWrapper) SetFieldValues

func (w *ResourceWrapper) SetFieldValues(props map[string]interface{}) error

func (*ResourceWrapper) String

func (w *ResourceWrapper) String() string

func (*ResourceWrapper) UnsetAllCurrent

func (w *ResourceWrapper) UnsetAllCurrent()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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