Documentation
¶
Index ¶
- Constants
- Variables
- func Deduplicate(refNodeKeys []string) []string
- func DiffReport(prior, plan, mode string) (string, error)
- func DiffWithRequestResourceAndState(plan *manifest.Manifest, latest *states.State) (string, error)
- func GetVertex(g *dag.AcyclicGraph, nv dag.NamedVertex) interface{}
- func LinkRefNodes(graph *dag.AcyclicGraph, refNodeKeys []string, ...) status.Status
- func LoadFile(yaml, location string) (ytbx.InputFile, error)
- func NewApplyGraph(m *manifest.Manifest, priorState *states.State) (*dag.AcyclicGraph, status.Status)
- func NewDestroyGraph(resource states.Resources) (*dag.AcyclicGraph, status.Status)
- func ParseImplicitRef(v reflect.Value, resourceIndex map[string]*states.ResourceState, ...) ([]string, reflect.Value, status.Status)
- type ActionType
- type ApplyOperation
- type ApplyRequest
- type ApplyResponse
- type BaseNode
- type ChangeStep
- type ChangeStepFilterFunc
- type Changes
- func (p *Changes) Diffs() string
- func (p *Changes) Get(key string) *ChangeStep
- func (p *Changes) OutputDiff(target string)
- func (p *Changes) Project() *projectstack.Project
- func (p *Changes) PromptDetails() (string, error)
- func (p *Changes) Stack() *projectstack.Stack
- func (p *Changes) Summary()
- func (p *Changes) Values(filters ...ChangeStepFilterFunc) []*ChangeStep
- type DeleteResourceParser
- type DestroyOperation
- type DestroyRequest
- type Diff
- type DiffRequest
- type ExecutableNode
- type ManifestParser
- type Message
- type OpResult
- type Operation
- func (o *Operation) Apply(request *ApplyRequest) (rsp *ApplyResponse, st status.Status)
- func (o *Operation) Destroy(request *DestroyRequest) (st status.Status)
- func (o *Operation) Preview(request *PreviewRequest, operation Type) (rsp *PreviewResponse, s status.Status)
- func (o *Operation) RefreshResourceIndex(resourceKey string, resource *states.ResourceState, actionType ActionType) error
- func (o *Operation) UpdateState(resourceIndex map[string]*states.ResourceState) error
- type Parser
- type PreviewOperation
- type PreviewRequest
- type PreviewResponse
- type Request
- type ResourceNode
- type RootNode
- type Type
Constants ¶
View Source
const (
ImplicitRefPrefix = "$kusion_path."
)
Variables ¶
View Source
var ( CreateChangeStepFilter = func(c *ChangeStep) bool { return c.Action == Create } UpdateChangeStepFilter = func(c *ChangeStep) bool { return c.Action == Update } DeleteChangeStepFilter = func(c *ChangeStep) bool { return c.Action == Delete } UnChangeChangeStepFilter = func(c *ChangeStep) bool { return c.Action == UnChange } )
View Source
var ImplicitReplaceFun = func(resourceIndex map[string]*states.ResourceState, refPath string) (reflect.Value, status.Status) { const Sep = "." split := strings.Split(refPath, Sep) key := split[0] priorState := resourceIndex[key] if priorState == nil { msg := fmt.Sprintf("can't find state by key:%s when replacing %s", key, refPath) return reflect.Value{}, status.NewErrorStatusWithMsg(status.IllegalManifest, msg) } attributes := priorState.Attributes if attributes == nil { msg := fmt.Sprintf("attributes is nil in resource:%s", key) return reflect.Value{}, status.NewErrorStatusWithMsg(status.IllegalManifest, msg) } var valueMap interface{} valueMap = attributes if len(split) > 1 { split := split[1:] for _, k := range split { if valueMap.(map[string]interface{})[k] == nil { msg := fmt.Sprintf("can't find specified value in resource:%s by ref:%s", key, refPath) return reflect.Value{}, status.NewErrorStatusWithMsg(status.IllegalManifest, msg) } valueMap = valueMap.(map[string]interface{})[k] } } return reflect.ValueOf(valueMap), nil }
Functions ¶
func Deduplicate ¶
func DiffReport ¶
func GetVertex ¶
func GetVertex(g *dag.AcyclicGraph, nv dag.NamedVertex) interface{}
func LinkRefNodes ¶
func LinkRefNodes(graph *dag.AcyclicGraph, refNodeKeys []string, resourceIndex map[string]*states.ResourceState, rn dag.Vertex, defaultAction ActionType, manifestGraphMap map[string]interface{}) status.Status
func LoadFile ¶
LoadFile processes the provided input location to load it as one of the supported document formats, or plain text if nothing else works.
func NewApplyGraph ¶
func NewDestroyGraph ¶
Types ¶
type ActionType ¶
type ActionType int64
ActionType represents the kind of operation performed by a plan. It evaluates to its string label.
const ( Undefined ActionType = iota // invalidate value UnChange // nothing to do. Create // creating a new resource. Update // updating an existing resource. Delete // deleting an existing resource. )
ActionType values
func (ActionType) Ing ¶
func (t ActionType) Ing() string
func (ActionType) PrettyString ¶
func (t ActionType) PrettyString() string
func (ActionType) String ¶
func (t ActionType) String() string
type ApplyOperation ¶
type ApplyOperation struct {
Operation
}
type ApplyRequest ¶
type ApplyRequest struct {
Request `json:",inline" yaml:",inline"`
}
type ApplyResponse ¶
type ChangeStep ¶
type ChangeStep struct { ID string // the resource id Action ActionType // the operation performed by this step. Old interface{} // the state of the resource before performing this step. New interface{} // the state of the resource after performing this step. }
func NewChangeStep ¶
func NewChangeStep(id string, op ActionType, oldData, newData interface{}) *ChangeStep
func (*ChangeStep) Diff ¶
func (cs *ChangeStep) Diff() (string, error)
type ChangeStepFilterFunc ¶
type ChangeStepFilterFunc func(*ChangeStep) bool
type Changes ¶
type Changes struct { ChangeSteps map[string]*ChangeStep // contains filtered or unexported fields }
func NewChanges ¶
func NewChanges(p *projectstack.Project, s *projectstack.Stack, steps map[string]*ChangeStep) *Changes
func (*Changes) Get ¶
func (p *Changes) Get(key string) *ChangeStep
func (*Changes) OutputDiff ¶
func (*Changes) Project ¶
func (p *Changes) Project() *projectstack.Project
func (*Changes) PromptDetails ¶
func (*Changes) Stack ¶
func (p *Changes) Stack() *projectstack.Stack
func (*Changes) Values ¶
func (p *Changes) Values(filters ...ChangeStepFilterFunc) []*ChangeStep
type DeleteResourceParser ¶
type DeleteResourceParser struct {
// contains filtered or unexported fields
}
func NewDeleteResourceParser ¶
func NewDeleteResourceParser(resources states.Resources) *DeleteResourceParser
func (*DeleteResourceParser) Parse ¶
func (d *DeleteResourceParser) Parse(graph *dag.AcyclicGraph) (s status.Status)
type DestroyOperation ¶
type DestroyOperation struct {
Operation
}
type DestroyRequest ¶
type DestroyRequest struct {
Request `json:",inline" yaml:",inline"`
}
type Diff ¶
type Diff struct {
StateStorage states.StateStorage
}
type DiffRequest ¶
type DiffRequest struct {
Request
}
type ExecutableNode ¶
type ManifestParser ¶
type ManifestParser struct {
// contains filtered or unexported fields
}
func NewManifestParser ¶
func NewManifestParser(manifest *manifest.Manifest) *ManifestParser
func (*ManifestParser) Parse ¶
func (m *ManifestParser) Parse(graph *dag.AcyclicGraph) (s status.Status)
type Operation ¶
type Operation struct { OperationType Type StateStorage states.StateStorage // CtxResourceIndex represents resources updated by func apply CtxResourceIndex map[string]*states.ResourceState // PriorStateResourceIndex represents prior states.StateStorage state PriorStateResourceIndex map[string]*states.ResourceState // StateResourceIndex represents resources that will be saved in states.StateStorage StateResourceIndex map[string]*states.ResourceState ChangeStepMap map[string]*ChangeStep Runtime runtime.Runtime MsgCh chan Message // contains filtered or unexported fields }
func (*Operation) Apply ¶
func (o *Operation) Apply(request *ApplyRequest) (rsp *ApplyResponse, st status.Status)
func (*Operation) Preview ¶
func (o *Operation) Preview(request *PreviewRequest, operation Type) (rsp *PreviewResponse, s status.Status)
func (*Operation) RefreshResourceIndex ¶
func (o *Operation) RefreshResourceIndex(resourceKey string, resource *states.ResourceState, actionType ActionType) error
RefreshResourceIndex refresh resources in CtxResourceIndex & StateResourceIndex
func (*Operation) UpdateState ¶
func (o *Operation) UpdateState(resourceIndex map[string]*states.ResourceState) error
type PreviewOperation ¶
type PreviewOperation struct {
Operation
}
type PreviewRequest ¶
type PreviewRequest struct {
Request `json:",inline" yaml:",inline"`
}
type PreviewResponse ¶
type PreviewResponse struct {
ChangeSteps map[string]*ChangeStep
}
type ResourceNode ¶
type ResourceNode struct { BaseNode Action ActionType // contains filtered or unexported fields }
func NewResourceNode ¶
func NewResourceNode(key string, state *states.ResourceState, action ActionType) *ResourceNode
func (*ResourceNode) State ¶
func (rn *ResourceNode) State() *states.ResourceState
Click to show internal directories.
Click to hide internal directories.