config

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MPL-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const Filename = "waypoint.hcl"

Filename is the default filename for the Waypoint configuration.

Variables

This section is empty.

Functions

func AddVariables added in v0.5.0

func AddVariables(ctx *hcl.EvalContext, vs variables.Values) *hcl.EvalContext

AddVariables uses the final map of InputValues to add all input variables to the given hcl EvalContext.

func EvalContext

func EvalContext(parent *hcl.EvalContext, pwd string) *hcl.EvalContext

EvalContext returns the common eval context to use for parsing all configurations. This should always be available for all config types.

The pwd param is the directory to use as a working directory for determining things like relative paths. This should be considered the pwd over the actual process pwd.

func FindPath

func FindPath(start, filename string, searchParent bool) (string, error)

FindPath looks for our configuration file starting at "start" and traversing parent directories until it is found. If it is found, the path is returned. If it is not found, an empty string is returned. Error will be non-nil only if an error occurred.

If start is empty, start will be the current working directory. If filename is empty, it will default to the Filename constant.

If searchParent is false, then we will not search parent directories and require the Waypoint configuration file be directly in the "start" directory.

func TestConfigFile

func TestConfigFile(t testing.T, src string)

TestConfigFile writes the default Waypoint configuration file with the given contents.

func TestSource

func TestSource(t testing.T) string

TestSource returns valid configuration.

func TestSourceJSON added in v0.3.0

func TestSourceJSON(t testing.T) string

TestSourceJSON returns valid configuration in JSON format.

Types

type App

type App struct {
	Name   string            `hcl:",label"`
	Path   string            `hcl:"path,optional"`
	Labels map[string]string `hcl:"labels,optional"`
	URL    *AppURL           `hcl:"url,block" default:"{}"`
	Config *genericConfig    `hcl:"config,block"`

	Runner *Runner `hcl:"runner,block"`

	BuildRaw   *hclBuild `hcl:"build,block"`
	DeployRaw  *hclStage `hcl:"deploy,block"`
	ReleaseRaw *hclStage `hcl:"release,block"`

	Body hcl.Body `hcl:",body"`
	// contains filtered or unexported fields
}

App represents a single application.

func (*App) Build

func (c *App) Build(ctx *hcl.EvalContext) (*Build, error)

Build loads the Build section of the configuration.

func (*App) BuildLabels added in v0.6.0

func (c *App) BuildLabels(ctx *hcl.EvalContext) (map[string]string, error)

BuildLabels returns the labels for this stage.

func (*App) BuildUse added in v0.2.0

func (c *App) BuildUse(ctx *hcl.EvalContext) (string, error)

BuildUse returns the plugin "use" value.

func (*App) ConfigMetadata added in v0.4.0

func (c *App) ConfigMetadata() (*ConfigMetadata, *ConfigMetadata)

ConfigMetadata returns any configuration metadata about the project and app.

func (*App) ConfigVars added in v0.2.0

func (c *App) ConfigVars() ([]*pb.ConfigVar, error)

ConfigVars returns the configuration variables for the app, including merging the configuration variables from the project level.

For access to only the app-level config vars, use the Config attribute directly.

func (*App) Deploy

func (c *App) Deploy(ctx *hcl.EvalContext) (*Deploy, error)

Deploy loads the associated section of the configuration.

func (*App) DeployLabels added in v0.6.0

func (c *App) DeployLabels(ctx *hcl.EvalContext) (map[string]string, error)

DeployLabels returns the labels for this stage.

func (*App) DeployUse added in v0.2.0

func (c *App) DeployUse(ctx *hcl.EvalContext) (string, error)

DeployUse returns the plugin "use" value.

func (*App) Ref added in v0.2.0

func (c *App) Ref() *pb.Ref_Application

Ref returns the ref for this app.

func (*App) Registry added in v0.2.0

func (c *App) Registry(ctx *hcl.EvalContext) (*Registry, error)

Registry loads the Registry section of the configuration.

func (*App) RegistryLabels added in v0.6.0

func (c *App) RegistryLabels(ctx *hcl.EvalContext) (map[string]string, error)

RegistryLabels returns the labels for this stage.

func (*App) RegistryUse added in v0.2.0

func (c *App) RegistryUse(ctx *hcl.EvalContext) (string, error)

RegistryUse returns the plugin "use" value.

func (*App) Release

func (c *App) Release(ctx *hcl.EvalContext) (*Release, error)

Release loads the associated section of the configuration.

func (*App) ReleaseLabels added in v0.6.0

func (c *App) ReleaseLabels(ctx *hcl.EvalContext) (map[string]string, error)

ReleaseLabels returns the labels for this stage.

func (*App) ReleaseUse added in v0.2.0

func (c *App) ReleaseUse(ctx *hcl.EvalContext) (string, error)

ReleaseUse returns the plugin "use" value.

func (*App) Validate

func (c *App) Validate() (ValidationResults, error)

Validate validates the application.

Similar to Config.App, this doesn't validate configuration that is further deferred such as build, deploy, etc. stanzas so call Validate on those as they're loaded.

type AppURL

type AppURL struct {
	AutoHostname *bool `hcl:"auto_hostname,optional"`
}

AppURL configures the App-specific URL settings.

type Build

type Build struct {
	Labels map[string]string `hcl:"labels,optional"`
	Hooks  []*Hook           `hcl:"hook,block"`
	Use    *Use              `hcl:"use,block"`

	// This should not be used directly. This is here for validation.
	// Instead, use App.Registry().
	Registry *Registry `hcl:"registry,block"`

	// Unused for practical reasons, but we need this here so that
	// the decoding validates successfully (HCL doesn't error of
	// unexpected things).
	WorkspaceScoped []*scopedStage `hcl:"workspace,block"`
	LabelScoped     []*scopedStage `hcl:"label,block"`
	// contains filtered or unexported fields
}

Build are the build settings.

func (*Build) Operation

func (b *Build) Operation() *Operation

type Config

type Config struct {
	InputVariables map[string]*variables.Variable
	// contains filtered or unexported fields
}

func Load added in v0.2.0

func Load(path string, opts *LoadOptions) (*Config, error)

Load loads the configuration file from the given path.

Configuration loading in Waypoint is lazy. This will load just the amount necessary to return the initial Config structure. Additional functions on Config must be called to load additional parts of the Config.

This also means that the config may be invalid. To validate the config call the Validate method.

func TestConfig

func TestConfig(t testing.T, src string) *Config

TestConfig returns a Config from a string source and fails the test if parsing the configuration fails.

func (*Config) App added in v0.2.0

func (c *Config) App(n string, ctx *hcl.EvalContext) (*App, error)

App returns the configured app named n. If the app doesn't exist, this will return (nil, nil).

func (*Config) Apps

func (c *Config) Apps() []string

Apps returns the names of all the apps.

func (*Config) ConfigAppRunner added in v0.7.2

func (c *Config) ConfigAppRunner(name string) *Runner

ConfigAppRunner returns the runner stanza on an application

func (*Config) ConfigPath added in v0.7.0

func (c *Config) ConfigPath() string

ConfigPath returns the path to the directory that contains the config file (waypoint.hcl)

func (*Config) ConfigRunner added in v0.7.2

func (c *Config) ConfigRunner() *Runner

ConfigRunner returns the runner stanza on a project

func (*Config) HCLContext added in v0.2.0

func (c *Config) HCLContext() *hcl.EvalContext

HCLContext returns the eval context for this configuration.

func (*Config) Pipeline added in v0.10.0

func (c *Config) Pipeline(id string, ctx *hcl.EvalContext) (*Pipeline, error)

Pipeline returns the configured pipeline named n. If the pipeline doesn't exist, this will return (nil, nil). Note that currently this parsing function does not attempt to detect cycles between embedded pipelines.

func (*Config) PipelineProtos added in v0.10.0

func (c *Config) PipelineProtos() ([]*pb.Pipeline, error)

PipelineProtos will take the existing HCL eval context, eval the config and translate the HCL result into a Pipeline Proto to be returned for operations such as ConfigSync. If a pipeline has an embedded pipeline defined, PipelineProtos will return each as its own separate Pipeline proto message where the step that defined the embedded pipeline is actually a Pipeline Step reference.

func (*Config) Pipelines added in v0.10.0

func (c *Config) Pipelines() []string

Pipelines returns the id of all the defined pipelines

func (*Config) Plugins

func (c *Config) Plugins() []*Plugin

Plugins returns all the plugins defined by this configuration. This will include the implicitly defined plugins via `use` statements.

func (*Config) Validate

func (c *Config) Validate() (ValidationResults, error)

Validate the structure of the configuration.

This will validate required fields are specified and the types of some fields. Plugin-specific fields won't be validated until later. Fields that use functions and variables will not be validated until those values can be realized.

Users of this package should call Validate on each subsequent configuration that is loaded (Apps, Builds, Deploys, etc.) for further rich validation.

type ConfigMetadata added in v0.4.0

type ConfigMetadata struct {
	FileChangeSignal string
}

ConfigMetadata holds information about the configuration variables or process themselves.

type DataSource

type DataSource struct {
	Type string   `hcl:",label"`
	Body hcl.Body `hcl:",remain"`
}

DataSource configures the data source for the runner.

type Deploy

type Deploy struct {
	Labels map[string]string `hcl:"labels,optional"`
	Hooks  []*Hook           `hcl:"hook,block"`
	Use    *Use              `hcl:"use,block"`

	// Unused, see Build
	WorkspaceScoped []*scopedStage `hcl:"workspace,block"`
	LabelScoped     []*scopedStage `hcl:"label,block"`
	// contains filtered or unexported fields
}

Deploy are the deploy settings.

func (*Deploy) Operation

func (b *Deploy) Operation() *Operation

type Hook

type Hook struct {
	When      string   `hcl:"when,attr"`
	Command   []string `hcl:"command,attr"`
	OnFailure string   `hcl:"on_failure,optional"`
}

Hook is the configuration for a hook that runs at specified times.

func (*Hook) ContinueOnFailure

func (h *Hook) ContinueOnFailure() bool

type LoadOptions added in v0.4.0

type LoadOptions struct {
	// Pwd is the current working directory. This is used to setup the
	// `path.pwd` variable and also makes things such as the Git rules work.
	Pwd string

	// Workspace is the workspace that we are executing in. This is used to
	// setup `workspace.name` variables.
	Workspace string
}

LoadOptions should be set for the Load function.

type Operation

type Operation struct {
	Labels map[string]string `hcl:"labels,optional"`
	Hooks  []*Hook           `hcl:"hook,block"`
	Use    *Use              `hcl:"use,block"`
	// contains filtered or unexported fields
}

Operation is something in the Waypoint configuration that is executed using some underlying plugin. This is a general shared structure that is used by internal/core to initialize all the proper plugins.

func (*Operation) Configure added in v0.2.0

func (op *Operation) Configure(plugin interface{}, ctx *hcl.EvalContext) hcl.Diagnostics

Configure configures the plugin with the use body of this operation.

type Pipeline added in v0.10.0

type Pipeline struct {
	Name string `hcl:",label"`

	StepRaw []*hclStep `hcl:"step,block"`
	Steps   []*Step

	Config *Config
	// contains filtered or unexported fields
}

Pipeline represents a single pipeline definition

func (*Pipeline) Ref added in v0.10.0

func (c *Pipeline) Ref() *pb.Ref_Pipeline

Ref returns the ref for this pipeline.

func (*Pipeline) Validate added in v0.10.0

func (c *Pipeline) Validate() error

type Plugin

type Plugin struct {
	// Name of the plugin. This is expected to match the plugin binary
	// "waypoint-plugin-<name>" including casing.
	Name string `hcl:",label"`

	// Type is the type of plugin this is. This can be multiple.
	Type struct {
		Mapper   bool `hcl:"mapper,optional"`
		Builder  bool `hcl:"build,optional"`
		Registry bool `hcl:"registry,optional"`
		Platform bool `hcl:"deploy,optional"`
		Releaser bool `hcl:"release,optional"`
	} `hcl:"type,block"`

	// Checksum is the SHA256 checksum to validate this plugin.
	Checksum string `hcl:"checksum,optional"`
}

Plugin configures a plugin.

func (*Plugin) Types

func (p *Plugin) Types() []component.Type

Types returns the list of types that this plugin implements.

type Poll added in v0.3.0

type Poll struct {
	Enabled  bool   `hcl:"enabled,optional"`
	Interval string `hcl:"interval,optional"`
}

Poll configures the polling settings for a project.

type Registry

type Registry struct {
	Labels map[string]string `hcl:"labels,optional"`
	Hooks  []*Hook           `hcl:"hook,block"`
	Use    *Use              `hcl:"use,block"`

	// Unused, see Build
	WorkspaceScoped []*scopedStage `hcl:"workspace,block"`
	LabelScoped     []*scopedStage `hcl:"label,block"`
	// contains filtered or unexported fields
}

Registry are the registry settings.

func (*Registry) Operation

func (b *Registry) Operation() *Operation

type Release

type Release struct {
	Labels map[string]string `hcl:"labels,optional"`
	Hooks  []*Hook           `hcl:"hook,block"`
	Use    *Use              `hcl:"use,block"`

	// Unused, see Build
	WorkspaceScoped []*scopedStage `hcl:"workspace,block"`
	LabelScoped     []*scopedStage `hcl:"label,block"`
	// contains filtered or unexported fields
}

Release are the release settings.

func (*Release) Operation

func (b *Release) Operation() *Operation

type Runner

type Runner struct {
	// Profile is the name of the on-demand runner configuration.
	Profile string `hcl:"profile,optional"`

	// Enabled is whether runners are enabled. If this is false
	// then the "-remote" flag will not work.
	Enabled bool `hcl:"enabled,optional"`

	// DataSource is the default data source when a remote job is queued.
	DataSource *DataSource `hcl:"data_source,block"`

	// Poll are the settings related to polling.
	Poll *Poll `hcl:"poll,block"`
}

Runner is the configuration for supporting runners in this project.

type Step added in v0.10.0

type Step struct {
	Labels map[string]string `hcl:"labels,optional"`
	Use    *Use              `hcl:"use,block"`

	// Give this step a name
	Name string `hcl:",label"`

	// If set, this step will depend on the defined step. The default step
	// will be the previously defined step in order that it was defined
	// in a waypoint.hcl
	DependsOn []string `hcl:"depends_on,optional"`

	// The OCI image to use for executing this step
	ImageURL string `hcl:"image_url,optional"`

	// An optional embedded pipeline stanza
	Pipeline *Pipeline `hcl:"pipeline,block"`

	// Optional workspace scoping
	Workspace string `hcl:"workspace,optional"`
	// contains filtered or unexported fields
}

Step are the step settings for pipelines

func (*Step) Configure added in v0.10.0

func (s *Step) Configure(plugin interface{}, ctx *hcl.EvalContext) hcl.Diagnostics

Configure configures the plugin for a given Step with the use body of this operation.

type Use

type Use struct {
	Type string   `hcl:",label"`
	Body hcl.Body `hcl:",remain"`
}

Use is something in the Waypoint configuration that is executed using some underlying plugin. This is a general shared structure that is used by internal/core to initialize all the proper plugins.

type ValidationResult added in v0.9.0

type ValidationResult struct {
	Error   error
	Warning string
}

func (ValidationResult) String added in v0.9.0

func (v ValidationResult) String() string

type ValidationResults added in v0.9.0

type ValidationResults []ValidationResult

func ValidateLabels

func ValidateLabels(labels map[string]string) ValidationResults

ValidateLabels validates a set of labels. This ensures that labels are set according to our requirements:

  • key and value length can't be greater than 255 characters each
  • keys must be in hostname format (RFC 952)
  • keys can't be prefixed with "waypoint/" which is reserved for system use

func (ValidationResults) Error added in v0.9.0

func (v ValidationResults) Error() string

func (ValidationResults) HasErrors added in v0.9.1

func (v ValidationResults) HasErrors() bool

type VariableLoopError added in v0.4.0

type VariableLoopError struct {
	LoopVars []string
}

VariableLoopError is returned when, in the course of sorting the variables, a loop is detected. This means the variables can never be properly evaluated.

func (*VariableLoopError) Error added in v0.4.0

func (v *VariableLoopError) Error() string

Directories

Path Synopsis
Package dynamic contains the HCL function, types, and logic for implementing dynamic config sourcing HCL configuration.
Package dynamic contains the HCL function, types, and logic for implementing dynamic config sourcing HCL configuration.

Jump to

Keyboard shortcuts

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