resources

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionDelete = "delete"
	ActionStop   = "stop"
)

Variables

This section is empty.

Functions

func CanBeStopped

func CanBeStopped(r *model.Resource) bool

CanBeStopped tells whether the given resource can be stopped.

func CollectionCreate

func CollectionCreate(
	ctx context.Context,
	mc model.ClientSet,
	entities model.Resources,
	opts Options,
) (model.Resources, error)

CollectionCreate creates the resources.

func CollectionDelete

func CollectionDelete(ctx context.Context, mc model.ClientSet, entities model.Resources, opts DeleteOptions) error

CollectionDelete deletes the resources.

func CollectionStart

func CollectionStart(ctx context.Context, mc model.ClientSet, entities model.Resources, opts Options) error

CollectionStart starts the resources.

func CollectionStop

func CollectionStop(ctx context.Context, mc model.ClientSet, entities model.Resources, opts Options) error

CollectionStop stops the resources.

func CollectionUpgrade

func CollectionUpgrade(ctx context.Context, mc model.ClientSet, entities model.Resources, opts Options) error

CollectionUpgrade upgrades the resources.

func Create

func Create(
	ctx context.Context,
	mc model.ClientSet,
	entity *model.Resource,
	opts Options,
) (res *model.Resource, run *model.ResourceRun, err error)

func Delete

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

func GenComputedAttributes

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 GetSubjectID

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

func GroupByEnvironment

func GroupByEnvironment(
	ctx context.Context,
	mc model.ClientSet,
	entities model.Resources,
) (map[object.ID]model.Resources, error)

GroupByEnvironment groups the resources by environment.

func IsStoppable

func IsStoppable(r *model.Resource) bool

IsStoppable tells whether the given resource is stoppable.

func PerformResource

func PerformResource(ctx context.Context, mc model.ClientSet, dp deptypes.Deployer, resourceID object.ID) error

PerformResource get resource latest run and perform run job.

func PopulateEnvironmentID

func PopulateEnvironmentID(ctx context.Context, mc model.ClientSet, entities model.Resources) error

PopulateEnvironmentID populate the environment id of the resources. As the environment id may not be included in the resource list returned by the query, we need to refill the environment id of the resources in some cases.

func ReverseTopologicalSortResources

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

ReverseTopologicalSortResources sorts the resource by dependencies in reverse order.

func Rollback

func Rollback(ctx context.Context, mc model.ClientSet, resourceID, runID object.ID, opts Options) error

func SetDefaultLabels

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

SetDefaultLabels sets default labels for the provided resources.

func SetEnvResourceDefaultLabels

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

func SetSubjectID

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

func Start

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

Start starts the resource.

func Stop

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

func TopologicalSortResources

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

TopologicalSortResources sorts the resources by dependencies.

func UpdateResourceSubjectID

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

UpdateResourceSubjectID updates the subject ID of the resources.

func Upgrade

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

Upgrade upgrades the resource.

Types

type DeleteOptions

type DeleteOptions struct {
	Options

	WithoutCleanup bool
}

type Options

type Options struct {
	// Deployer The deployer type to perform the resource run.
	Deployer deptypes.Deployer
	// StorageManager is the storage manager.
	StorageManager *storage.Manager

	// Draft if resource is in draft status.
	Draft bool

	// RunType The type of the resource run.
	RunType types.RunType
	// Preview if the resource run requires preview.
	Preview bool
	// ChangeComment of the resource run.
	ChangeComment string
	// RunLabels of the resource run.
	RunLabels map[string]string
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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