ark

package
v0.0.0-...-841f565 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	Execute(ctx context.Context) error
}

Action is an interface is implemented by a struct that should use a RawTarget to configure its execution and produce an Artifact

type Ancestor

type Ancestor struct {
	Key  string `json:"key" hash:"ignore"`
	Hash string `json:"hash" hash:"ignore"`
}

Ancestor represents the key and hash of a parent target

type Ancestors

type Ancestors []Ancestor

Ancestors an slice of ancestors used to define dependencies

func (Ancestors) GormDBDataType

func (Ancestors) GormDBDataType(db *gorm.DB, _ *schema.Field) string

GormDBDataType gorm db data type

func (Ancestors) GormDataType

func (m Ancestors) GormDataType() string

GormDataType gorm common data type

func (*Ancestors) Scan

func (m *Ancestors) Scan(val interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (Ancestors) Value

func (m Ancestors) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Artifact

type Artifact interface {
	Cacheable() bool
	RemotelyCached(ctx context.Context) (bool, error)
	LocallyCached(ctx context.Context) (bool, error)
	Push(ctx context.Context) error
	Pull(ctx context.Context) error
	MkCacheDir() (string, error)
	WriteState() error
}

Artifact is an interface that defines the behavior of a resource that can be stored and fetched from a content addressable store

type Derivation

type Derivation struct {
	Target   Target
	Artifact Artifact
}

type Derivative

type Derivative struct {
	RawTarget   RawTarget   `json:"Target"`
	RawArtifact RawArtifact `json:"Artifact"`
}

type ExcludeFromHash

type ExcludeFromHash struct {
	SourceFiles json_datatypes.StringSlice `json:"sourceFiles" mapstructure:"sourceFiles"`
}

func (ExcludeFromHash) GormDBDataType

func (ExcludeFromHash) GormDBDataType(db *gorm.DB, _ *schema.Field) string

GormDBDataType gorm db data type

func (ExcludeFromHash) GormDataType

func (m ExcludeFromHash) GormDataType() string

GormDataType gorm common data type

func (*ExcludeFromHash) Scan

func (m *ExcludeFromHash) Scan(val interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (ExcludeFromHash) Value

func (m ExcludeFromHash) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type GraphEdge

type GraphEdge struct {
	Src string `json:"src"`
	Dst string `json:"dst"`
}

GraphEdge represents the src key and dst key between two targets in a graph

func (GraphEdge) Key

func (g GraphEdge) Key() string

Key returns a key that can be used to index edges

func (*GraphEdge) Validate

func (g *GraphEdge) Validate() error

Validate ensure graph edge is valid

type Hashable

type Hashable interface {
	Hash() (hash.Hash, error)
}

Hashable is an interface implemented by structs that can produce a deterministic hash of their properties

type Key

type Key struct {
	Path string
	Name string
}

Key is a convenience struct to assist with directory creation

func ParseKey

func ParseKey(key string) (Key, error)

ParseKey takes an artifact key and marshals the contents into the Key struct

type Producer

type Producer interface {
	Produce(checksum hash.Hash) (Artifact, error)
}

Producer is an interface that is implemented by a struct that produces an Artifact

type RawArtifact

type RawArtifact struct {
	Key                string                 `json:"key" mapstructure:"key"`
	Hash               string                 `json:"hash" mapstructure:"hash"`
	Type               string                 `json:"type" mapstructure:"type"`
	Attributes         map[string]interface{} `json:"attributes" mapstructure:"attributes,remain"`
	DependsOn          Ancestors              `json:"dependsOn" mapstructure:"dependsOn" hash:"-"`
	RemoteCacheBaseURL string                 `json:"remote_cache_base_url" mapstructure:"remote_cache_base_url"`
}

RawArtifact represents the core representation of any artifact

func (RawArtifact) CacheDirPath

func (r RawArtifact) CacheDirPath() (string, error)

CacheDirPath returns the constructed name of the local filesystem path for local caching of an artifact

func (RawArtifact) Cacheable

func (r RawArtifact) Cacheable() bool

Cacheable always returns true as the default behavior should be to cache something

func (RawArtifact) LocallyCached

func (r RawArtifact) LocallyCached(_ context.Context) (bool, error)

LocallyCached checks for the presence of a local artifact.json file

func (RawArtifact) MkCacheDir

func (r RawArtifact) MkCacheDir() (string, error)

MkCacheDir creates a location on disk for storing an artifact locally

func (RawArtifact) Pull

func (r RawArtifact) Pull(ctx context.Context) error

Pull downloads an artifact from a remote blob store to an expected location on disk

func (RawArtifact) Push

func (r RawArtifact) Push(ctx context.Context) error

Push uploads an artifact to a remote blob store

func (RawArtifact) RemotelyCached

func (r RawArtifact) RemotelyCached(ctx context.Context) (bool, error)

RemotelyCached checks a remote blob store for the presence of an artifact

func (RawArtifact) ShortHash

func (r RawArtifact) ShortHash() string

ShortHash returns a 7 character version of the has returns an empty string if the hash is empty

func (*RawArtifact) UseWorkspaceConfig

func (r *RawArtifact) UseWorkspaceConfig(config workspace.Config)

UseWorkspaceConfig injects the blob storage base URL into the raw artifact struct

func (RawArtifact) WriteState

func (r RawArtifact) WriteState() error

WriteState writes a json representation of the raw artifact to the local cache directory

type RawTarget

type RawTarget struct {
	ID                       string                            `json:"id" mapstructure:"id" hash:"-"`
	Name                     string                            `json:"name" mapstructure:"name"`
	Type                     string                            `json:"type" mapstructure:"type"`
	File                     string                            `json:"file" mapstructure:"file" hash:"-"`
	Realm                    string                            `json:"realm" mapstructure:"realm" hash:"-"`
	Attributes               json_datatypes.MapStringInterface `json:"attributes" mapstructure:"attributes,remain"`
	SourceFiles              json_datatypes.StringSlice        `json:"sourceFiles" mapstructure:"sourceFiles" hash:"-"`
	Labels                   json_datatypes.StringSlice        `json:"labels" mapstructure:"labels" hash:"-"`
	DependsOn                Ancestors                         `json:"dependsOn" mapstructure:"dependsOn" hash:"-"`
	ExcludeFromHash          ExcludeFromHash                   `json:"excludeFromHash" mapstructure:"excludeFromHash" hash:"-"`
	IgnoreFileNotExistsError bool                              `json:"ignoreFileNotExistsError" mapstructure:"ignoreFileNotExistsError"`
}

RawTarget an object that represents the input of an action The RawTarget houses attributes that are easily serializable and must be cast or embedded in to other types

func (*RawTarget) Checksum

func (t *RawTarget) Checksum() (rootHash hash.Hash, err error)

Checksum executes the hash calculation algorithm on the provided target

func (RawTarget) Dir

func (t RawTarget) Dir() string

Dir returns the directory of the action file

func (RawTarget) Hashcode

func (t RawTarget) Hashcode() interface{}

Hashcode implementing the graph hashcode interface

func (RawTarget) Key

func (t RawTarget) Key() string

Key return the cache key for an action

func (RawTarget) KeyHash

func (t RawTarget) KeyHash() string

KeyHash return the cache key SHA-1 hash for an action

func (RawTarget) RelativeDir

func (t RawTarget) RelativeDir() string

RelativeDir return the directory for the target relative to the root

func (RawTarget) String

func (t RawTarget) String() string

func (*RawTarget) Validate

func (t *RawTarget) Validate() error

Validate validates specified structs by checking the specified struct fields against their corresponding validation rules

type Store

type Store interface {
	GetTargets() ([]RawTarget, error)
	GetTargetByKey(key string) (RawTarget, error)
	AddTarget(target RawTarget) (RawArtifact, error)
	ConnectTargets(edge GraphEdge) error
	GetGraph() (*dag.AcyclicGraph, error)
	GetGraphEdges() ([]GraphEdge, error)
	Open(connection string) error
	Migrate() error
}

Store ...

type Target

type Target interface {
	Producer
	Validatable
	Key() string
}

type Validatable

type Validatable interface {
	Validate() error
}

Validatable is an interface implemented by a struct who's fields may be validated

Jump to

Keyboard shortcuts

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