resource

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// VariableReg is the regexp to match the variable reference in attributes.
	VariableReg = regexp.MustCompile(`\${var\.([a-zA-Z0-9_-]+)}`)
	// ResourceReg is the regexp to match the resource output reference in attributes.
	ResourceReg = regexp.MustCompile(`\${res\.([^.}]+)\.([^.}]+)}`)
)

Functions

func Apply

func Apply(
	ctx context.Context,
	mc model.ClientSet,
	entity *model.Resource,
	opts Options,
) (err error)

func CanBeStopped

func CanBeStopped(r *model.Resource) bool

CanBeStopped tells whether the given resource can be stopped.

func CheckDependencyStatus

func CheckDependencyStatus(
	ctx context.Context,
	mc model.ClientSet,
	dp deptypes.Deployer,
	entity *model.Resource,
) (bool, error)

CheckDependencyStatus check resource dependencies status is ready to apply.

func Create

func Create(
	ctx context.Context,
	mc model.ClientSet,
	entity *model.Resource,
	opts Options,
) (*model.ResourceOutput, error)

func CreateDraftResources

func CreateDraftResources(
	ctx context.Context,
	mc model.ClientSet,
	entities ...*model.Resource,
) (model.Resources, error)

CreateDraftResources creates un-deployed resources but do no deployment. TODO refactor and coordinate with CreateScheduledResources.

func CreateScheduledResources

func CreateScheduledResources(
	ctx context.Context,
	mc model.ClientSet,
	dp deptypes.Deployer,
	entities model.Resources,
) (model.Resources, error)

CreateScheduledResources creates scheduled resources.

func Destroy

func Destroy(
	ctx context.Context,
	mc model.ClientSet,
	entity *model.Resource,
	opts Options,
) (err error)

func GenComputedAttributes added in v0.5.0

func GenComputedAttributes(
	ctx context.Context,
	modelClient model.ClientSet,
	entity *model.Resource,
) (property.Values, error)

GenComputedAttributes generate computed attributes for resource. Required: entity.EnvironmentID, entity.Attributes entity.TemplateID/entity.ResourceDefinitionMatchingRuleID.

func GetDependencyOutputs added in v0.5.0

func GetDependencyOutputs(
	ctx context.Context,
	client model.ClientSet,
	dependencyResourceIDs []object.ID,
	dependOutputs map[string]string,
) (map[string]parser.OutputState, error)

GetDependencyOutputs gets the dependency outputs of the resource.

func GetSubjectID

func GetSubjectID(entity *model.Resource) (object.ID, error)

func IsInactive

func IsInactive(r *model.Resource) bool

IsInactive tells whether the given resource is inactive.

func IsStatusDeleted

func IsStatusDeleted(entity *model.Resource) bool

IsStatusDeleted returns true if the resource is deleted or to be deleted.

func IsStatusDeployed added in v0.5.0

func IsStatusDeployed(entity *model.Resource) bool

IsStatusDeployed returns true if the resource is deployed or to be deployed.

func IsStatusError added in v0.5.0

func IsStatusError(entity *model.Resource) bool

IsStatusError returns true if the resource is in error status.

func IsStatusReady

func IsStatusReady(entity *model.Resource) bool

IsStatusReady returns true if the resource is ready.

func IsStatusStopped added in v0.5.0

func IsStatusStopped(entity *model.Resource) bool

IsStatusStopped returns true if the resource is stopped or to be stopped.

func IsStoppable

func IsStoppable(r *model.Resource) bool

IsStoppable tells whether the given resource is stoppable.

func ReverseTopologicalSortResources added in v0.5.0

func ReverseTopologicalSortResources(resources model.Resources) (model.Resources, error)

ReverseTopologicalSortResources sorts the resource by dependencies in reverse order.

func SetDefaultLabels added in v0.5.0

func SetDefaultLabels(ctx context.Context, mc model.ClientSet, entities ...*model.Resource) error

SetDefaultLabels sets default labels for the provided resources.

func SetEnvResourceDefaultLabels added in v0.5.0

func SetEnvResourceDefaultLabels(env *model.Environment, r *model.Resource) error

func SetResourceStatusScheduled

func SetResourceStatusScheduled(
	ctx context.Context,
	mc model.ClientSet,
	dp deptypes.Deployer,
	entities ...*model.Resource,
) error

SetResourceStatusScheduled sets the status of the resources to scheduled.

func SetSubjectID

func SetSubjectID(ctx context.Context, resources ...*model.Resource) error

func Stop

func Stop(
	ctx context.Context,
	mc model.ClientSet,
	entity *model.Resource,
	opts Options,
) (err error)

Stop stops given resource.

func TopologicalSortResources

func TopologicalSortResources(resources model.Resources) (model.Resources, error)

TopologicalSortResources sorts the resources by dependencies.

func UpdateResourceSubjectID added in v0.5.0

func UpdateResourceSubjectID(ctx context.Context, mc model.ClientSet, resources ...*model.Resource) error

UpdateResourceSubjectID updates the subject ID of the resources.

func UpdateStatus

func UpdateStatus(
	ctx context.Context,
	mc model.ClientSet,
	entity *model.Resource,
) error

Types

type Options

type Options struct {
	Deployer deptypes.Deployer
}

Options for deploy or destroy.

type ResourceNode

type ResourceNode struct {
	ID       object.ID       `json:"id"`
	Name     string          `json:"name"`
	Resource *model.Resource `json:"resource"`
	Children []*ResourceNode `json:"children"`
}

func NewResourceNodes

func NewResourceNodes(resources model.Resources) ([]*ResourceNode, error)

NewResourceNodes returns a list of resource nodes from the given resources.

func TopologicalSortResourceNodes

func TopologicalSortResourceNodes(nodes []*ResourceNode) []*ResourceNode

TopologicalSortResourceNodes sorts the resource nodes by dependencies.

Jump to

Keyboard shortcuts

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