module

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateAction = "create"
	UpdateAction = "update"
	DeleteAction = "delete"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionDesc

type ActionDesc struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	ParamSchema string `json:"param_schema"`
	// contains filtered or unexported fields
}

ActionDesc is a descriptor for an action supported by a module.

type ActionRequest

type ActionRequest struct {
	Name   string          `json:"name"`
	Params json.RawMessage `json:"params"`
}

ActionRequest describes an invocation of action on module.

type Descriptor

type Descriptor struct {
	Kind         string            `json:"kind"`
	Actions      []ActionDesc      `json:"actions"`
	Dependencies map[string]string `json:"dependencies"`
	Module       Module            `json:"-"`
}

Descriptor is a module descriptor that represents supported actions, resource-kind the module can operate on, etc.

type LogChunk

type LogChunk struct {
	Data   []byte            `json:"data"`
	Labels map[string]string `json:"labels"`
}

type Loggable

type Loggable interface {
	Module

	Log(ctx context.Context, spec Spec, filter map[string]string) (<-chan LogChunk, error)
}

Loggable extension of module allows streaming log data for a resource.

type Module

type Module interface {
	// Plan SHOULD validate the action on the current version of the resource,
	// return the resource with config/status/state changes (if any) applied.
	// Plan SHOULD NOT have side effects on anything other than the resource.
	Plan(ctx context.Context, spec Spec, act ActionRequest) (*resource.Resource, error)

	// Sync is called repeatedly by Entropy core until the returned state is
	// a terminal status. Module implementation is free to execute an action
	// in a single Sync() call or split into steps for better feedback to the
	// end-user about the progress.
	// Sync can return state in resource.StatusDeleted to indicate resource
	// should be removed from the Entropy storage.
	Sync(ctx context.Context, spec Spec) (*resource.State, error)
}

Module is responsible for achieving desired external system states based on a resource in Entropy.

type Registry

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

Registry maintains a list of supported/enabled modules.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Log

func (mr *Registry) Log(ctx context.Context, spec Spec, filter map[string]string) (<-chan LogChunk, error)

func (*Registry) Plan

func (mr *Registry) Plan(ctx context.Context, spec Spec, act ActionRequest) (*resource.Resource, error)

func (*Registry) Register

func (mr *Registry) Register(desc Descriptor) error

Register adds a module to the registry.

func (*Registry) Sync

func (mr *Registry) Sync(ctx context.Context, spec Spec) (*resource.State, error)

type ResolvedDependency

type ResolvedDependency struct {
	Kind   string          `json:"kind"`
	Output json.RawMessage `json:"output"`
}

type Spec

type Spec struct {
	Resource     resource.Resource             `json:"resource"`
	Dependencies map[string]ResolvedDependency `json:"dependencies"`
}

Spec represents the context for Plan() or Sync() invocations.

Jump to

Keyboard shortcuts

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