Documentation
¶
Index ¶
- Constants
- type ActionDesc
- type ActionRequest
- type Descriptor
- type Driver
- type ExpandedResource
- type LogChunk
- type Loggable
- type Module
- type Registry
- type ResolvedDependency
- type Service
- func (mr *Service) CreateModule(ctx context.Context, mod Module) (*Module, error)
- func (mr *Service) DeleteModule(ctx context.Context, urn string) error
- func (mr *Service) GetModule(ctx context.Context, urn string) (*Module, error)
- func (mr *Service) GetOutput(ctx context.Context, res ExpandedResource) (json.RawMessage, error)
- func (mr *Service) ListModules(ctx context.Context, project string) ([]Module, error)
- func (mr *Service) PlanAction(ctx context.Context, res ExpandedResource, act ActionRequest) (*resource.Resource, error)
- func (mr *Service) StreamLogs(ctx context.Context, res ExpandedResource, filter map[string]string) (<-chan LogChunk, error)
- func (mr *Service) SyncState(ctx context.Context, res ExpandedResource) (*resource.State, error)
- func (mr *Service) UpdateModule(ctx context.Context, urn string, newConfigs json.RawMessage) (*Module, error)
- type Store
Constants ¶
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.
func (*ActionDesc) Sanitise ¶
func (ad *ActionDesc) Sanitise() error
Sanitise cleans action description by removing whitespaces, checking parameter-schema etc.
type ActionRequest ¶
type ActionRequest struct {
Name string `json:"name"`
Params json.RawMessage `json:"params"`
Labels map[string]string `json:"labels"`
UserID string
}
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"`
DriverFactory func(conf json.RawMessage) (Driver, error) `json:"-"`
}
Descriptor is a module descriptor that represents supported actions, resource-kind the module can operate on, etc.
type Driver ¶
type Driver 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, res ExpandedResource, act ActionRequest) (*resource.Resource, error)
// Sync is called repeatedly by Entropy core until the returned state is
// a terminal status. Driver 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, res ExpandedResource) (*resource.State, error)
// Output returns the current external state of the resource
// Output should not have any side effects on any external resource
Output(ctx context.Context, res ExpandedResource) (json.RawMessage, error)
}
Driver is responsible for achieving desired external system states based on a resource in Entropy.
type ExpandedResource ¶
type ExpandedResource struct {
resource.Resource `json:"resource"`
Dependencies map[string]ResolvedDependency `json:"dependencies"`
}
ExpandedResource represents the context for Plan() or Sync() invocations.
type Loggable ¶
type Loggable interface {
Driver
Log(ctx context.Context, res ExpandedResource, filter map[string]string) (<-chan LogChunk, error)
}
Loggable extension of driver allows streaming log data for a resource.
type Module ¶
type Module struct {
URN string `json:"urn"`
Name string `json:"name"`
Project string `json:"project"`
Configs json.RawMessage `json:"configs"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Module represents all the data needed to initialize a particular module.
type Registry ¶
Registry is responsible for installing and managing module-drivers as per module definitions provided.
type ResolvedDependency ¶
type ResolvedDependency struct {
Kind string `json:"kind"`
Output json.RawMessage `json:"output"`
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) CreateModule ¶
func (*Service) DeleteModule ¶
func (*Service) GetOutput ¶
func (mr *Service) GetOutput(ctx context.Context, res ExpandedResource) (json.RawMessage, error)
func (*Service) ListModules ¶
func (*Service) PlanAction ¶
func (mr *Service) PlanAction(ctx context.Context, res ExpandedResource, act ActionRequest) (*resource.Resource, error)
func (*Service) StreamLogs ¶
func (*Service) UpdateModule ¶
type Store ¶
type Store interface {
GetModule(ctx context.Context, urn string) (*Module, error)
ListModules(ctx context.Context, project string) ([]Module, error)
CreateModule(ctx context.Context, m Module) error
UpdateModule(ctx context.Context, m Module) error
DeleteModule(ctx context.Context, urn string) error
}
Store is responsible for persisting modules defined for each project.