core

package
v0.0.0-...-102b616 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultStack

func NewDefaultStack(stackID StackID) *defaultStack

NewDefaultStack constructs new stack.

Types

type FakeResource

type FakeResource struct {
	ResourceMeta `json:"-"`

	Spec   FakeResourceSpec    `json:"spec"`
	Status *FakeResourceStatus `json:"status,omitempty"`
}

func NewFakeResource

func NewFakeResource(stack Stack, resType string, id string, spec FakeResourceSpec, status *FakeResourceStatus) *FakeResource

func (*FakeResource) FieldB

func (r *FakeResource) FieldB() StringToken

type FakeResourceSpec

type FakeResourceSpec struct {
	FieldA []StringToken `json:"fieldA"`
}

type FakeResourceStatus

type FakeResourceStatus struct {
	FieldB string `json:"fieldB"`
}

type LiteralStringToken

type LiteralStringToken string

LiteralStringToken represents a literal string value.

func (LiteralStringToken) Dependencies

func (t LiteralStringToken) Dependencies() []Resource

func (LiteralStringToken) Resolve

func (t LiteralStringToken) Resolve(ctx context.Context) (string, error)

type Resource

type Resource interface {
	// resource's stack.
	Stack() Stack

	// resource's Type.
	Type() string

	// resource's ID within stack.
	ID() string
}

Resource represents a deployment unit.

type ResourceFieldStringToken

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

func NewResourceFieldStringToken

func NewResourceFieldStringToken(res Resource, fieldPath string,
	resolverFunc func(ctx context.Context, res Resource, fieldPath string) (string, error)) *ResourceFieldStringToken

NewResourceFieldStringToken constructs new ResourceFieldStringToken. @TODO: ideally the resolverFunc can be a shared implementation which dump Resource as json and obtain the fieldPath.

func (*ResourceFieldStringToken) Dependencies

func (t *ResourceFieldStringToken) Dependencies() []Resource

func (*ResourceFieldStringToken) MarshalJSON

func (t *ResourceFieldStringToken) MarshalJSON() ([]byte, error)

func (*ResourceFieldStringToken) Resolve

type ResourceMeta

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

Metadata for all resources.

func NewResourceMeta

func NewResourceMeta(stack Stack, resType string, id string) ResourceMeta

NewResourceMeta constructs new resource metadata.

func (*ResourceMeta) ID

func (m *ResourceMeta) ID() string

func (*ResourceMeta) Stack

func (m *ResourceMeta) Stack() Stack

func (*ResourceMeta) Type

func (m *ResourceMeta) Type() string

type ResourceVisitor

type ResourceVisitor interface {
	Visit(res Resource) error
}

ResourceVisitor represents a functor that can operate on a resource.

type Stack

type Stack interface {
	// stackID returns a unique ID for stack.
	StackID() StackID

	// Add a resource into stack.
	AddResource(res Resource) error

	// Add a dependency relationship between resources.
	AddDependency(dependee Resource, depender Resource) error

	// ListResources list all resources for specific type.
	// pResourceSlice must be a pointer to a slice of resources, which will be filled.
	ListResources(pResourceSlice interface{}) error

	// TopologicalTraversal visits resources in stack in topological order.
	TopologicalTraversal(visitor ResourceVisitor) error
}

Stack presents a resource graph, where resources can depend on each other.

type StackID

type StackID types.NamespacedName

stackID is the identifier of a stack, it must be compatible with Kubernetes namespaced name.

func (StackID) String

func (stackID StackID) String() string

String returns the string representation of a StackID. It will be used as AWS resource tags for resources provisioned for this stack.

type StringToken

type StringToken interface {
	Token
	Resolve(ctx context.Context) (string, error)
}

StringToken represent a string value that can be resolved at resolution time.

type Token

type Token interface {
	// token's value resolution may depends on 0 or more Resources.
	Dependencies() []Resource
}

Token represent a value that can be resolved at resolution time.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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