resource

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	StatusUnspecified = "STATUS_UNSPECIFIED" // unknown
	StatusPending     = "STATUS_PENDING"     // intermediate
	StatusError       = "STATUS_ERROR"       // terminal
	StatusDeleted     = "STATUS_DELETED"     // terminal
	StatusCompleted   = "STATUS_COMPLETED"   // terminal
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Kind    string            `json:"kind"`
	Project string            `json:"project"`
	Labels  map[string]string `json:"labels"`
}

func (Filter) Apply

func (f Filter) Apply(arr []Resource) []Resource

type MutationHook

type MutationHook func(ctx context.Context) error

MutationHook values are passed to mutation operations of resource storage to handle any transactional requirements.

type Output

type Output map[string]interface{}

type PendingHandler

type PendingHandler func(ctx context.Context, res Resource) (*Resource, bool, error)

type Resource

type Resource struct {
	URN       string            `json:"urn"`
	Kind      string            `json:"kind"`
	Name      string            `json:"name"`
	Project   string            `json:"project"`
	Labels    map[string]string `json:"labels"`
	CreatedAt time.Time         `json:"created_at"`
	UpdatedAt time.Time         `json:"updated_at"`
	Spec      Spec              `json:"spec"`
	State     State             `json:"state"`
}

func (*Resource) Validate

func (res *Resource) Validate() error

type Spec

type Spec struct {
	Configs      json.RawMessage   `json:"configs"`
	Dependencies map[string]string `json:"dependencies"`
}

type State

type State struct {
	Status     string          `json:"status"`
	Output     json.RawMessage `json:"output"`
	ModuleData json.RawMessage `json:"module_data,omitempty"`
}

func (State) Clone

func (s State) Clone() State

func (State) InDeletion

func (s State) InDeletion() bool

InDeletion returns true if the state represents a resource that is scheduled for deletion.

func (State) IsTerminal

func (s State) IsTerminal() bool

IsTerminal returns true if state is terminal. A terminal state is one where resource needs no further sync.

type Store

type Store interface {
	GetByURN(ctx context.Context, urn string) (*Resource, error)
	List(ctx context.Context, filter Filter) ([]Resource, error)

	Create(ctx context.Context, r Resource, hooks ...MutationHook) error
	Update(ctx context.Context, r Resource, hooks ...MutationHook) error
	Delete(ctx context.Context, urn string, hooks ...MutationHook) error
}

Jump to

Keyboard shortcuts

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