claim

package
v0.12.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: MIT Imports: 12 Imported by: 5

Documentation

Index

Constants

View Source
const (
	StatusSucceeded = "succeeded"
	StatusCanceled  = "canceled"
	StatusFailed    = "failed"
	StatusRunning   = "running"
	StatusPending   = "pending"
	StatusUnknown   = "unknown"

	// Deprecated: StatusSuccess has been replaced by StatusSucceeded.
	StatusSuccess = StatusSucceeded

	// Deprecated: StatusFailure has been replaced by StatusFailed.
	StatusFailure = StatusFailed
)

Status constants define the CNAB status fields on a Result.

View Source
const (
	ActionInstall   = "install"
	ActionUpgrade   = "upgrade"
	ActionUninstall = "uninstall"
	ActionUnknown   = "unknown"
)

Action constants define the CNAB action to be taken

View Source
const ItemType = "claims"

ItemType is the location in the backing store where claims are persisted.

Variables

View Source
var CNABSpecVersion string = "cnab-claim-1.0.0-DRAFT+d7ffba8"

CNABSpecVersion represents the CNAB Spec version of the Claim that this library implements This value is prefixed with e.g. `cnab-claim-` so isn't itself valid semver.

View Source
var ErrClaimNotFound = errors.New("Claim does not exist")

ErrClaimNotFound represents a claim not found in claim storage

View Source
var ValidName = regexp.MustCompile("^[a-zA-Z0-9._-]+$")

ValidName is a regular expression that indicates whether a name is a valid claim name.

Functions

func GetDefaultSchemaVersion

func GetDefaultSchemaVersion() (schema.Version, error)

GetDefaultSchemaVersion returns the default semver CNAB schema version of the Claim that this library implements

func ULID

func ULID() string

ULID generates a string representation of a ULID.

Types

type Claim

type Claim struct {
	SchemaVersion   schema.Version         `json:"schemaVersion"`
	Installation    string                 `json:"installation"`
	Revision        string                 `json:"revision"`
	Created         time.Time              `json:"created"`
	Modified        time.Time              `json:"modified"`
	Bundle          *bundle.Bundle         `json:"bundle"`
	BundleReference string                 `json:"bundleReference,omitempty"`
	Result          Result                 `json:"result,omitempty"`
	Parameters      map[string]interface{} `json:"parameters,omitempty"`
	Outputs         map[string]interface{} `json:"outputs,omitempty"`
	Custom          interface{}            `json:"custom,omitempty"`
}

Claim is an installation claim receipt.

Claims represent information about a particular installation, and provide the necessary data to upgrade and uninstall a CNAB package.

func New

func New(name string) (*Claim, error)

New creates a new Claim initialized for an installation operation.

func (*Claim) Update

func (c *Claim) Update(action, status string)

Update is a convenience for modifying the necessary fields on a Claim.

Per spec, when a claim is updated, the action, status, revision, and modified fields all change. All but status and action can be computed.

func (Claim) Validate

func (c Claim) Validate() error

Validate the Claim

type Result

type Result struct {
	Message string `json:"message,omitempty"`
	Action  string `json:"action"`
	Status  string `json:"status"`
}

Result tracks the result of an operation on a CNAB installation

func (Result) Validate

func (r Result) Validate() error

Validate the Result

type Store

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

Store is a persistent store for claims.

func NewClaimStore

func NewClaimStore(store crud.Store) Store

NewClaimStore creates a persistent store for claims using the specified backing key-blob store.

func (Store) Delete

func (s Store) Delete(name string) error

Delete deletes a claim from the store.

func (Store) List

func (s Store) List() ([]string, error)

List lists the names of the stored claims.

func (Store) Read

func (s Store) Read(name string) (Claim, error)

Read loads the claim with the given name from the store.

func (Store) ReadAll

func (s Store) ReadAll() ([]Claim, error)

ReadAll retrieves all of the claims.

func (Store) Save

func (s Store) Save(claim Claim) error

Save a claim. Any previous version of the claim (that is, with the same name) is overwritten.

Jump to

Keyboard shortcuts

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