base

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: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAddress

func BuildAddress(packageName, targetType, targetName string) string

BuildAddress constructs the target address string from a directory, type, and name

func CreateEvalContext

func CreateEvalContext(opts EvalContextOptions) *hcl.EvalContext

CreateEvalContext creates a new evaluation context intended for use during Buildable.PreBuild

func DockerRunFunc

func DockerRunFunc(ctx context.Context, plugin Plugin) function.Function

DockerRunFunc executes a docker exec using a specifically provided image

func FilterChangeNotificationsByTarget

func FilterChangeNotificationsByTarget(graph *Graph, root dag.Vertex) rxgo.Predicate

FilterChangeNotificationsByTarget is an rxgo.Predicate to filter a stream by workspace target dependencies

func KVGet

func KVGet(kvStorage kv.Storage) function.Function

KVGet pulls data from a local secret store and returns an object

func LoadConfigFunc

func LoadConfigFunc(baseDir string) function.Function

LoadConfigFunc loads environment-specific configuration into the HCL context

func ReRunOnChange

func ReRunOnChange(callback func() error) rxgo.Func

ReRunOnChange returns an rxgo.Func that lists the changes made against targets and then executes the provided callback

Types

type Addressable

type Addressable interface {
	// Address is the string representation of the targets address in the build graph (root.go_binary.tool)
	Address() string

	// Describe returns the description of the target defined in the BUILD.hcl file (this is optional, so it can be empty)
	Describe() string

	// String is an alias for Address
	String() string

	// Hashcode is an alias for Address used to satisfy the hashable interface
	Hashcode() interface{}

	// ListLabels returns a string slice of labels on a target
	ListLabels() []string
}

Addressable an interface describing objects which can be addressed

type ArtifactsConfig

type ArtifactsConfig struct {
	StorageBaseURL string `hcl:"storage_base_url,attr"`
}

ArtifactsConfig holds data for the storage of artifacts

type BuildCacheState

type BuildCacheState struct {
	Name string
	Type string
	Hash string
}

BuildCacheState provides the structure for the state.json file

type BuildFile

type BuildFile struct {
	HCL  *hcl.File
	Path string
}

BuildFile the parsed hcl file and location on the file system

type Buildable

type Buildable interface {
	Target
	Hashable

	// PreBuild a lifecycle hook that should ALWAYS be called before Build
	// This is a stateful function that causes target state to be updated prior to a build execution
	PreBuild() error

	// Build a function that executes a build for a given target.
	// If this function succeeds then the build was successful and should have resulted in an artifact.
	Build() error

	// Artifacts is a list of declared artifacts names
	Artifacts() map[string]string

	// ArtifactsDir is the absolute path to the /ark/artifacts directory of this target
	ArtifactsDir() string

	// MkArtifactsDir recursively ensures the ArtifactsDir exists
	MkArtifactsDir() error
}

Buildable represents a an object that can be built and produces artifacts

type Cacheable

type Cacheable interface {
	// CacheEnabled allows for overriding the default caching behavior on a per-target basis
	// TODO: Split cacheable functions from raw_target. This is a temporary hack.
	CacheEnabled() bool

	// StateFilePath is the path in the artifacts directory to the state.json file for this target
	StateFilePath() string

	// CheckLocalBuildCache checks if the local cache contains a copy of the buildable artifacts
	CheckLocalBuildCache() (bool, error)

	// LoadLocalBuildCacheState returns the contents of the state.json file at StateFilePath()
	LoadLocalBuildCacheState() (BuildCacheState, error)

	// SaveLocalBuildCacheState saves the current state to state.json file at StateFilePath()
	SaveLocalBuildCacheState() error

	// CheckRemoteCache checks if the remote cache contains a copy of the buildable artifacts
	CheckRemoteCache() (bool, error)

	// PullRemoteCache pulls a copy of the buildable artifacts from the remote cache
	PullRemoteCache() error

	// PushRemoteCache pushes a copy of the buildable artifacts to the remote cache
	PushRemoteCache() error
}

Cacheable represents a union type of the Hashable, Buildable, and methods that allow its artifacts to be cached locally and remotely

type ControlPlaneConfig

type ControlPlaneConfig struct {
	OrgID        string `hcl:"org_id,attr"`
	ProjectID    string `hcl:"project_id,attr"`
	ApiURL       string `hcl:"api_url,attr"`
	EventSinkURL string `hcl:"event_sink_url,attr"`
	LogSinkURL   string `hcl:"log_sink_url,attr"`
}

ControlPlaneConfig controls options injected into ark control plane components

type DecodeRawTargetOpts

type DecodeRawTargetOpts struct {
	HclFile          *hcl.File
	Filename         string
	Workspace        *Workspace
	HclCtx           *hcl.EvalContext
	DecodedBuildFile *DecodedBuildFile
	MaxDepth         int
	CurrentDepth     int
}

DecodeRawTargetOpts is a struct of options to pass to DecodeRawTargetsFromHCLFile()

type DecodedBuildFile

type DecodedBuildFile struct {
	Package    *Package     `hcl:"package,block"`
	Locals     *Locals      `hcl:"locals,block"`
	RawTargets []*RawTarget `hcl:"target,block"`
	Modules    []*Module    `hcl:"module,block"`
}

DecodedBuildFile ...

type EvalContextOptions

type EvalContextOptions struct {
	CurrentTarget                Target
	Package                      Package
	TargetLookupTable            LookupTable
	Workspace                    Workspace
	DisableLookupTableEvaluation bool
}

EvalContextOptions a set of dependencies for a pre build evaluation context

type FileSystemConfig

type FileSystemConfig struct {
	Ignore []string `hcl:"ignore,attr"`
}

FileSystemConfig configures the workspace file system observer

type Graph

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

Graph a directed acyclic graph of build targets

func (*Graph) Add

func (g *Graph) Add(vertex dag.Vertex) dag.Vertex

Add adds a target to the graph

func (*Graph) Connect

func (g *Graph) Connect(src, dest dag.Vertex)

Connect creates an edge between a source and destination target

func (*Graph) DirectedGraph

func (g *Graph) DirectedGraph() dag.AcyclicGraph

DirectedGraph returns the internal dag

func (*Graph) Dot

func (g *Graph) Dot() []byte

Dot exports the graph in dot format

func (*Graph) DotToFile

func (g *Graph) DotToFile(filename string) error

DotToFile exports dot graph to file

func (*Graph) Isolate

func (g *Graph) Isolate(start dag.Vertex) *Graph

Isolate returns an isolated sub graph from the starting vertex

func (*Graph) MarshalJSON

func (g *Graph) MarshalJSON() ([]byte, error)

MarshalJSON marshals the graph as JSON

func (*Graph) Roots

func (g *Graph) Roots() []dag.Vertex

Roots returns a all roots in the graph

func (*Graph) String

func (g *Graph) String() string

String returns a string representation of the graph

func (*Graph) TopologicalSort

func (g *Graph) TopologicalSort(start dag.Vertex) []dag.Vertex

TopologicalSort of a directed graph is a linear ordering of its vertices such that for every directed edge uv from vertex u to vertex v, u comes before v in the ordering This function sorts the vertices by their name to be deterministic.

func (*Graph) TransitiveReduction

func (g *Graph) TransitiveReduction()

TransitiveReduction performs the transitive reduction of graph g in place.

func (*Graph) Validate

func (g *Graph) Validate() error

Validate ensures the graph is an acyclic graph (no cycles)

func (*Graph) Walk

func (g *Graph) Walk(walk GraphWalker) error

Walk walks the graph, calling your callback as each node is visited. This will walk nodes in parallel if it can. The resulting diagnostics contains problems from all graphs visited, in no particular order.

type GraphWalker

type GraphWalker func(dag.Vertex) error

GraphWalker a callback function used to process targets in the order they should be executed in based on their dependency chain

func BuildWalker

func BuildWalker(force bool, pullFromRemoteCache bool, pushToRemoteCache bool) GraphWalker

BuildWalker walks the graph and builds each target sequentially attempting to cache where possible

type Hashable

type Hashable interface {
	// Hash a full hex string sha256sum of the buildable
	// This can be empty if the hash has not been computed and saved in the state store
	Hash() string

	// ShortHash a 7 character hex string sha256sum of the buildable
	// This can be empty if the hash has not been computed and saved in the state store
	ShortHash() string

	// HashableAttributes returns a map of attributes that are hashed for the purpose of tracking build configuration changes for a target
	HashableAttributes() map[string]interface{}
}

Hashable an interface describing objects that implement hashing methods

type InternalConfig

type InternalConfig struct {
	DisableEntrypointInjection bool `hcl:"disable_entrypoint_injection,optional"`
}

InternalConfig an object which describes arks internal configuration options

type JsonnetConfig

type JsonnetConfig struct {
	Library []string `hcl:"library,optional"`
}

JsonnetConfig allows a user to configure overrides for internal systems

type KubernetesConfig

type KubernetesConfig struct {
	SafeContexts []string `hcl:"safe_contexts,attr"`
}

KubernetesConfig holds data for applying k8s manifests to clusters

type Locals

type Locals struct {
	HCL    hcl.Body `json:"-" hcl:",remain"`
	Values map[string]cty.Value
}

Locals represents variables that are constrained to the current package/BUILD.hcl file

type LookupTable

type LookupTable map[string]Addressable

LookupTable (look up table) adds and retrieves targets by their target.Address() LookupTable["src/go/tools/monarch.go_binary:linux"]Addressable

func (LookupTable) Add

func (t LookupTable) Add(target Addressable) error

Add adds a target to the LUT

func (LookupTable) BuildGraph

func (t LookupTable) BuildGraph() (*Graph, error)

BuildGraph returns a graph of all objects in the lookup table

func (LookupTable) BuildGraphEdges

func (t LookupTable) BuildGraphEdges(graph *Graph, target Target) error

BuildGraphEdges takes a graph and a target and attempts to build edges between the target and its dependencies

func (*LookupTable) BuildTargetDependencies

func (t *LookupTable) BuildTargetDependencies(graph *Graph, addressable Addressable) error

BuildTargetDependencies takes a graph and an addressable and attempts to build build onto the graph

func (LookupTable) FilterByPatterns

func (t LookupTable) FilterByPatterns(matcher *pattern.Matcher) (addressables []Addressable)

FilterByPatterns returns a slice of Addressable targets that have been filtered against a slice of glob patterns supplied by the pattern.Matcher

func (LookupTable) FilterSortedAddresses

func (t LookupTable) FilterSortedAddresses(matcher *pattern.Matcher) (addresses []string)

FilterSortedAddresses returns a sorted slice of target addresses that have been filtered against a slice of glob patterns supplied by the pattern.Matcher

func (LookupTable) Lookup

func (t LookupTable) Lookup(packageName, targetType, targetName string) (Addressable, error)

Lookup locates a target by constructing its address This is a convenience function to be used as an hcl eval function and the CLI

func (LookupTable) LookupByAddress

func (t LookupTable) LookupByAddress(address string) (Addressable, error)

LookupByAddress uses a fully qualified address

func (LookupTable) ResolveHCLVariableDependencies

func (t LookupTable) ResolveHCLVariableDependencies(addressable Addressable) []Addressable

ResolveHCLVariableDependencies returns a list of addressables from the lookup table that are referenced as variables in hcl.Expressions This function will panic if you pass a non struct type as it uses reflection to look for HCL expression struct fields

func (LookupTable) SortedAddresses

func (t LookupTable) SortedAddresses() []string

SortedAddresses returns an alphabetical list of addresses

func (LookupTable) ToCtyVariables

func (t LookupTable) ToCtyVariables() map[string]cty.Value

ToCtyVariables returns the lookup table as a deeply nested object for use in hcl.Expressions

type Module

type Module struct {
	Name   string         `hcl:",label"`
	Source hcl.Expression `hcl:"source,attr"`
	HCL    hcl.Body       `json:"-" hcl:",remain"`
	Path   string
}

Module defines the properties used to create re-usable modules

func (*Module) EvalAttributes

func (m *Module) EvalAttributes(ctx *hcl.EvalContext) (map[string]cty.Value, hcl.Diagnostics)

EvalAttributes evaluates the attributes from the given HCL evaluation context

type Package

type Package struct {
	Name        string `hcl:",label"`
	Description string `hcl:"description,attr"`
	Version     string `hcl:"version,optional"`
	Dir         string
}

Package the package of the give target This is used to build target addressing

func (Package) Describe

func (p Package) Describe() string

Describe returns a string description of a package

type ParsedAddress

type ParsedAddress struct {
	Package string
	Type    string
	Name    string
}

ParsedAddress a struct that represents the parts of a parsed address

func ParseAddress

func ParseAddress(address string) (*ParsedAddress, error)

ParseAddress parses an address string and returns an parsed address struct

func (ParsedAddress) String

func (p ParsedAddress) String() string

String returns a string representation of an address

type Plugin

type Plugin struct {
	Name  string `hcl:"name,label"`
	Image string `hcl:"image,attr"`
}

Plugin defines a docker image that can be used as an HCL function the image must take in data from stdin and the output from the plugin is a string

type RawComputedAttrs

type RawComputedAttrs struct {
	Labels          []string `hcl:"labels,optional"`
	Files           []string `hcl:"source_files,optional"`
	IncludePatterns []string `hcl:"include_patterns,optional"`
	ExcludePatterns []string `hcl:"exclude_patterns,optional"`
}

RawComputedAttrs is a container for hcl expressions that need to be referenced

type RawTarget

type RawTarget struct {
	// initial pass properties of a target
	Type              string    `hcl:",label"`
	Name              string    `hcl:",label"`
	Description       *string   `hcl:"description,attr"`
	DependsOn         *[]string `hcl:"depends_on,attr"`
	DeclaredArtifacts *[]string `hcl:"artifacts,attr"`

	Labels hcl.Expression `hcl:"labels,optional"`

	SourceFiles     hcl.Expression `hcl:"source_files,attr"`
	IncludePatterns hcl.Expression `hcl:"include_patterns,attr"`
	ExcludePatterns hcl.Expression `hcl:"exclude_patterns,attr"`

	// A file matcher used for filtering source files
	FileMatcher *pattern.Matcher `json:"-"`

	// the remaining HCL encoded body
	HCL      hcl.Body `json:"-" hcl:",remain"`
	HCLBytes []byte   `json:"-"`

	// the directory of the BUILD.hcl file
	Dir string

	// the BUILD.hcl file this came from
	File string

	Package   *Package   `json:"-"`
	Workspace *Workspace `json:"-"`
	Locals    *Locals    `json:"-"`

	// State Management
	StateStore *state_store.StateStore

	RawComputedAttrs *RawComputedAttrs
	Module           *Module
}

RawTarget a data container for the initial decoding pass

func DecodeRawTargetsFromHCLFile

func DecodeRawTargetsFromHCLFile(opts DecodeRawTargetOpts) ([]*RawTarget, hcl.Diagnostics)

DecodeRawTargetsFromHCLFile returns a slice of RawTarget pointers after the initial decoding pass

func (RawTarget) Address

func (t RawTarget) Address() string

Address returns a string that can be used to address this target

func (RawTarget) Artifacts

func (t RawTarget) Artifacts() map[string]string

Artifacts a calculated list of artifacts that were declared

func (RawTarget) ArtifactsDir

func (t RawTarget) ArtifactsDir() string

ArtifactsDir returns the file path to the artifacts directory

func (RawTarget) Attributes

func (t RawTarget) Attributes() map[string]cty.Value

Attributes a map of attributes for use in hcl.EvalContexts

func (RawTarget) CacheEnabled

func (t RawTarget) CacheEnabled() bool

CacheEnabled returns true to cache targets by default. Can be overridden on a per-target basis

func (RawTarget) CheckLocalBuildCache

func (t RawTarget) CheckLocalBuildCache() (bool, error)

CheckLocalBuildCache loads the build cache state and verifies that the hashes match

func (RawTarget) CheckRemoteCache

func (t RawTarget) CheckRemoteCache() (bool, error)

CheckRemoteCache determines whether an artifact for a given target exists in remote storage

func (*RawTarget) Deps

func (t *RawTarget) Deps() []string

Deps returns the rawTarget.DependsOn

func (RawTarget) Describe

func (t RawTarget) Describe() string

Describe returns a string description of a target

func (RawTarget) DirRelToWorkspace

func (t RawTarget) DirRelToWorkspace() string

DirRelToWorkspace the target's directory relative to the workspace root

func (*RawTarget) EvaluateHCLExpressions

func (t *RawTarget) EvaluateHCLExpressions() error

EvaluateHCLExpressions evaluates the source_files, include_patterns, and exclude patterns of the target

func (RawTarget) FileDeps

func (t RawTarget) FileDeps() (*observer.FileMatchCache, bool)

FileDeps returns an observer file match cache

func (RawTarget) GetFileMatcher

func (t RawTarget) GetFileMatcher() *pattern.Matcher

GetFileMatcher returns the FileMatcher on the RawTarget used in the Buildable interface

func (*RawTarget) GetRawTarget

func (t *RawTarget) GetRawTarget() *RawTarget

GetRawTarget returns the RawTarget

func (*RawTarget) GetStateAttrs

func (t *RawTarget) GetStateAttrs() interface{}

GetStateAttrs returns the stored computed attrs

func (RawTarget) Hash

func (t RawTarget) Hash() string

Hash returns a hex formatted sha256 hash of the sources and dependencies If the hash is a zero hash we panic

func (RawTarget) HashableAttributes

func (t RawTarget) HashableAttributes() map[string]interface{}

HashableAttributes returns a map of attributes that are hashed for the purpose of tracking build configuration changes for a target Deprecated

func (RawTarget) Hashcode

func (t RawTarget) Hashcode() interface{}

Hashcode an interface used as a key by the DAG lib

func (RawTarget) IsolateHCLBlocks

func (t RawTarget) IsolateHCLBlocks() (*hclwrite.File, error)

IsolateHCLBlocks uses the targets source bytes to isolate its original HCL form (convenient for rewriting or hashing)

func (RawTarget) ListLabels

func (t RawTarget) ListLabels() []string

ListLabels returns a string slice of labels on a target

func (RawTarget) LoadLocalBuildCacheState

func (t RawTarget) LoadLocalBuildCacheState() (BuildCacheState, error)

LoadLocalBuildCacheState decodes the local build cache state file for the specified target

func (RawTarget) LocalVars

func (t RawTarget) LocalVars() map[string]cty.Value

LocalVars returns a map of variables local to the package for use in hcl.EvalContexts

func (RawTarget) MkArtifactsDir

func (t RawTarget) MkArtifactsDir() error

MkArtifactsDir creates the artifacts directory

func (RawTarget) MkTmpArtifactsDir

func (t RawTarget) MkTmpArtifactsDir() error

MkTmpArtifactsDir creates the artifacts directory in os.TempDir()

func (RawTarget) PackageDir

func (t RawTarget) PackageDir() string

PackageDir is the absolute path of the directory of a target

func (RawTarget) PackageName

func (t RawTarget) PackageName() string

PackageName returns the string value of package.Name

func (RawTarget) PackageVersion

func (t RawTarget) PackageVersion() string

PackageVersion returns the string value of package.Version

func (*RawTarget) PrevState

func (t *RawTarget) PrevState() state_store.KVStore

PrevState return the previous state from the state store

func (RawTarget) PullRemoteCache

func (t RawTarget) PullRemoteCache() error

PullRemoteCache pulls an artifact from remote storage that matches a target's state hash and loads it for local use

func (RawTarget) PushRemoteCache

func (t RawTarget) PushRemoteCache() error

PushRemoteCache archives and compresses an artifact and pushes the artifact into remote storage

func (RawTarget) RemoteArtifactKey

func (t RawTarget) RemoteArtifactKey() string

RemoteArtifactKey constructs a string path for a remote artifact

func (RawTarget) SaveLocalBuildCacheState

func (t RawTarget) SaveLocalBuildCacheState() error

SaveLocalBuildCacheState saves a new instance of BuildCacheState as JSON to t.StateFilePath()

func (*RawTarget) SetStateAttrs

func (t *RawTarget) SetStateAttrs(v interface{}) interface{}

SetStateAttrs updates the attrsStateKey in the state store

func (RawTarget) ShortHash

func (t RawTarget) ShortHash() string

ShortHash the first 7 characters of the calculated hash of the sources and dependencies

func (RawTarget) SourceFilesList

func (t RawTarget) SourceFilesList() (sourceFiles []string)

SourceFilesList returns a string slice of source files

func (*RawTarget) State

func (t *RawTarget) State() state_store.KVStore

State return the current state from the state store

func (RawTarget) StateFilePath

func (t RawTarget) StateFilePath() string

StateFilePath returns a string path to the state file for the target

func (RawTarget) String

func (t RawTarget) String() string

String an alias for Address

func (RawTarget) TmpArtifactsDir

func (t RawTarget) TmpArtifactsDir() string

TmpArtifactsDir returns an artifacts directory in the os.TempDir()

type Target

type Target interface {
	Addressable

	// Deps is a static list of ancestor target addresses declared in the BUILD.hcl file (this can be empty)
	Deps() []string

	// FileDeps returns an observer file match cache
	FileDeps() (*observer.FileMatchCache, bool)

	// State is a KV state store for caching data about the buildable target
	State() state_store.KVStore

	// PrevState is a secondary state store intended for comparing current state to previously known state
	PrevState() state_store.KVStore

	// LocalVars are a list of cty values used to keep HCL dry
	LocalVars() map[string]cty.Value

	// Attributes are a static list of cty values to be used in HCL EvaluationContexts
	Attributes() map[string]cty.Value

	// DirRelToWorkspace is the directory of target relative to its workspace
	// This is typically the location of the HCL file the target was declared in
	DirRelToWorkspace() string

	// EvaluateHCLExpressions evaluate source_files, include_patters, and exclude_patterns as expressions
	EvaluateHCLExpressions() error

	// PackageName returns the string value of package.Name
	PackageName() string

	// PackageVersion returns the string value of package.Version
	PackageVersion() string

	// PackageDir is the absolute path of the directory of a target
	PackageDir() string

	GetRawTarget() *RawTarget
}

Target represents the base interface for all targets which must also be Addressable

type Targets

type Targets map[string]Buildable

Targets is a map of types to their target interfaces Targets["exec"]emptyExampleExecTarget{}

func (Targets) MapRawTargets

func (ttm Targets) MapRawTargets(rawTargets []*RawTarget) ([]Buildable, hcl.Diagnostics)

MapRawTargets reflects against an internal map of buildable target types constructs a new copy of the target type in its memory, decodes the remaining rawTarget HCL into the new copy of the mapped target and embeds the rawTarget in the mappedTarget

if there is no target type for the rawTarget.Type an error will be raised if the mapped target cannot be converted into a pointer an error will be raised if the mapped target cannot be cast back into the target interface an error will be raised.

func (Targets) Register

func (ttm Targets) Register(targetType string, target Buildable)

Register adds a target type to the map

type UserConfig

type UserConfig struct {
	Token string `hcl:"address,attr"`
}

UserConfig used to authenticate users of the ark control plane

type VaultClientFactory

type VaultClientFactory func(config *vault.Config) (*vault.Client, error)

VaultClientFactory allows for the injection of a custom configured Vault client

type VaultConfig

type VaultConfig struct {
	Address       string `hcl:"address,attr"`
	EncryptionKey string `hcl:"encryption_key,optional"`
}

VaultConfig allows user to set Vault address that's not reliant on an env var

type Workspace

type Workspace struct {
	Dir  string
	File string
	HCL  hcl.Body `json:"-"`

	TargetWatch       bool
	TargetGraph       Graph
	RegisteredTargets Targets
	TargetLUT         LookupTable
	Observer          *observer.Observer
	Config            WorkspaceConfig
	Context           context.Context

	K8s       kube.Client
	Vault     *vault.Client
	Docker    *container.Docker
	KVStorage kv.Storage

	Cmd                   *cobra.Command
	Args                  []string
	PassableArgs          []string
	DefaultJsonnetLibrary []string

	PortBinderCommands       portbinder.CommandChannel
	ReadyPortCommands        portbinder.CommandChannel
	ConfigurationEnvironment string

	VaultClientFactory VaultClientFactory
}

Workspace the workspace configuration for ark

func NewWorkspace

func NewWorkspace() *Workspace

NewWorkspace creates a workspace with defaults

func (*Workspace) ArkDir

func (w *Workspace) ArkDir() string

ArkDir returns the /ark directory relative to the workspace root

func (*Workspace) ArtifactsDir

func (w *Workspace) ArtifactsDir() string

ArtifactsDir returns the .ark/artifacts directory relative to the workspace root

func (Workspace) Attributes

func (w Workspace) Attributes() map[string]interface{}

Attributes of this workspace, intended to be used in hcl.EvalContext.

func (Workspace) AttributesToCty

func (w Workspace) AttributesToCty() map[string]cty.Value

AttributesToCty returns the workspace attributes as cty values

func (Workspace) Clean

func (w Workspace) Clean() error

Clean removes generated files from the /ark/artifacts directory this is used to reset the local state and artifacts cache

func (*Workspace) DecodeBuildFiles

func (w *Workspace) DecodeBuildFiles() ([]BuildFile, error)

DecodeBuildFiles loads build files from the workspace and decodes them into build file structs.

func (*Workspace) DecodeFile

func (w *Workspace) DecodeFile(eval *hcl.EvalContext) hcl.Diagnostics

DecodeFile decodes the workspace file into the workspace configuration struct

func (*Workspace) DetermineRoot

func (w *Workspace) DetermineRoot(startingDir string) error

DetermineRoot recursively searches the current directory and all its parents for a WORKSPACE.hcl file

func (*Workspace) DetermineRootFromCWD

func (w *Workspace) DetermineRootFromCWD() error

DetermineRootFromCWD determine the workspace root from the current working directory

func (*Workspace) DirBase

func (w *Workspace) DirBase() string

DirBase returns the basedir of the workspace instead of the absolute path

func (*Workspace) ExtractCliOptions

func (w *Workspace) ExtractCliOptions(cmd *cobra.Command, args []string)

ExtractCliOptions gets all of the info passed in from the CLI

func (*Workspace) GraphWalk

func (w *Workspace) GraphWalk(address string, walk GraphWalker) error

GraphWalk walks the graph, calling your callback as each node is visited. This will walk nodes in parallel if it can. The resulting diagnostics contains problems from all graphs visited, in no particular order.

func (*Workspace) InitDockerClient

func (w *Workspace) InitDockerClient() error

InitDockerClient creates a docker client on the workspace

func (*Workspace) InitKubeClient

func (w *Workspace) InitKubeClient(namespace string) error

InitKubeClient initializes a new kubernetes client set

func (*Workspace) InitVaultClient

func (w *Workspace) InitVaultClient() error

InitVaultClient initializes a new Vault client

func (*Workspace) JsonnetLibrary

func (w *Workspace) JsonnetLibrary(ext []string) []string

JsonnetLibrary returns a list of paths to jsonnet libraries

func (*Workspace) K8sSafeContexts

func (w *Workspace) K8sSafeContexts() []string

K8sSafeContexts return a slice of k8s safe contexts

func (*Workspace) LoadBuildFiles

func (w *Workspace) LoadBuildFiles() ([]string, error)

LoadBuildFiles walks the workspace root, and it's children for BUILD.hcl files

func (*Workspace) LoadTargets

func (w *Workspace) LoadTargets(buildFiles []BuildFile) error

LoadTargets - loads all build files in the workspace - attempts to decode targets into their respective types - loads targets into the graph, and the look up table - iterates over all loaded targets to build graph edges - validates the graph for cycles and errors

func (*Workspace) SetEnvironmentConstraint

func (w *Workspace) SetEnvironmentConstraint(envFlagValue string)

SetEnvironmentConstraint sets the environment constraint from the CLI flag for the purpose of configuration loading

func (*Workspace) WatchForChanges

func (w *Workspace) WatchForChanges(filter rxgo.Predicate, onChange rxgo.Func) rxgo.Observable

WatchForChanges creates a fs observer subscription to the workspace observing changes to the root target

type WorkspaceConfig

type WorkspaceConfig struct {
	K8s                  *KubernetesConfig   `hcl:"kubernetes,block"`
	Vault                *VaultConfig        `hcl:"vault,block"`
	Artifacts            *ArtifactsConfig    `hcl:"artifacts,block"`
	FileSystem           *FileSystemConfig   `hcl:"file_system,block"`
	Jsonnet              *JsonnetConfig      `hcl:"jsonnet,block"`
	Plugins              []Plugin            `hcl:"plugin,block"`
	ControlPlane         *ControlPlaneConfig `hcl:"control_plane,block"`
	User                 *UserConfig         `hcl:"user,block"`
	Internal             *InternalConfig     `hcl:"internal,block"`
	VersionCheckDisabled *bool               `hcl:"disable_version_check,attr"`
}

WorkspaceConfig holds data for configuring a workspace

func (WorkspaceConfig) K8sConfig

func (w WorkspaceConfig) K8sConfig() *KubernetesConfig

K8sConfig performs a nil check on w.K8s and returns a pointer to a k8s config

Jump to

Keyboard shortcuts

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