resource

package
v0.2.16-rc Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 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

func GenerateURN

func GenerateURN(kind, project, name string) string

GenerateURN generates an Entropy URN address for the given combination. Note: Changing this will invalidate all existing resource identifiers.

Types

type Filter

type Filter struct {
	Kind     string            `json:"kind"`
	Project  string            `json:"project"`
	Labels   map[string]string `json:"labels"`
	PageSize int32             `json:"page_size"`
	PageNum  int32             `json:"page_num"`
}

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 PagedResource added in v0.1.22

type PagedResource struct {
	Count     int32
	Resources []Resource
}

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"`
	UpdatedBy string            `json:"updated_by"`
	CreatedBy string            `json:"created_by"`
	Spec      Spec              `json:"spec"`
	State     State             `json:"state"`
}

func (*Resource) Validate

func (res *Resource) Validate(isCreate bool) error

type Revision

type Revision struct {
	ID        int64             `json:"id"`
	URN       string            `json:"urn"`
	Reason    string            `json:"reason"`
	Labels    map[string]string `json:"labels"`
	CreatedAt time.Time         `json:"created_at"`
	CreatedBy string            `json:"created_by"`

	Spec Spec `json:"spec"`
}

type RevisionsSelector

type RevisionsSelector struct {
	URN string `json:"urn"`
}

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"`

	NextSyncAt *time.Time `json:"next_sync_at,omitempty"`
	SyncResult SyncResult `json:"sync_result"`
}

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, withSpecConfigs bool) ([]Resource, error)

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

	Revisions(ctx context.Context, selector RevisionsSelector) ([]Revision, error)

	SyncOne(ctx context.Context, scope map[string][]string, syncFn SyncFn) error
}

type SyncFn

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

type SyncResult

type SyncResult struct {
	Retries   int    `json:"retries"`
	LastError string `json:"last_error"`
}

type UpdateRequest

type UpdateRequest struct {
	Spec   Spec              `json:"spec"`
	Labels map[string]string `json:"labels"`
	UserID string
}

Jump to

Keyboard shortcuts

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