graph

package
v0.5.4-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ImplicitRefPrefix = "$kusion_path."
)

Variables

View Source
var ImplicitReplaceFun = func(resourceIndex map[string]*models.Resource, 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 NewBaseNode

func NewBaseNode(id string) (*baseNode, status.Status)

func ParseImplicitRef

func ParseImplicitRef(v reflect.Value, resourceIndex map[string]*models.Resource,
	replaceFun func(resourceIndex map[string]*models.Resource, refPath string) (reflect.Value, status.Status),
) ([]string, reflect.Value, status.Status)

Types

type ExecutableNode

type ExecutableNode interface {
	Execute(operation *models.Operation) status.Status
}

type ResourceNode

type ResourceNode struct {
	Action types.ActionType
	// contains filtered or unexported fields
}

func NewResourceNode

func NewResourceNode(key string, state *models.Resource, action types.ActionType) (*ResourceNode, status.Status)

func (*ResourceNode) Execute

func (rn *ResourceNode) Execute(operation *opsmodels.Operation) status.Status

func (ResourceNode) Hashcode

func (b ResourceNode) Hashcode() interface{}

func (ResourceNode) Name

func (b ResourceNode) Name() string

func (*ResourceNode) State

func (rn *ResourceNode) State() *models.Resource

type RootNode

type RootNode struct{}

func (*RootNode) Hashcode

func (r *RootNode) Hashcode() interface{}

func (*RootNode) Name

func (r *RootNode) Name() string

Jump to

Keyboard shortcuts

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