config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MPL-2.0 Imports: 25 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 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 Format added in v0.3.0

func Format(input []byte, path string) ([]byte, error)

Format auto-formats the input configuration and returns the formatted result.

The "path" argument is used only for error messages. It doesn't have to be a valid path. For inputs from stdin, it is common to use a synthetic path value such as "<stdin>".

If input is already formatted, it will be returned as-is in the result.

This does not require valid Waypoint configuration. This will work with almost any HCL-formatted file. However, we may introduce Waypoint-specific opinions at some point so this is in the Waypoint configuration package.

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.

func ValidateLabels

func ValidateLabels(labels map[string]string) []error

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

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

	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) BuildUse added in v0.2.0

func (c *App) BuildUse() string

BuildUse returns the plugin "use" value.

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) DeployUse added in v0.2.0

func (c *App) DeployUse() string

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) RegistryUse added in v0.2.0

func (c *App) RegistryUse() string

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) ReleaseUse added in v0.2.0

func (c *App) ReleaseUse() string

ReleaseUse returns the plugin "use" value.

func (*App) Validate

func (c *App) Validate() 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"`
	// contains filtered or unexported fields
}

Build are the build settings.

func (*Build) Operation

func (b *Build) Operation() *Operation

type Config

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

func Load added in v0.2.0

func Load(path string, pwd string) (*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) HCLContext added in v0.2.0

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

HCLContext returns the eval context for this configuration.

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() 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 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"`
	// 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 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 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"`
	// 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"`
	// contains filtered or unexported fields
}

Release are the release settings.

func (*Release) Operation

func (b *Release) Operation() *Operation

type Runner

type Runner struct {
	// Enabled is whether or not 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 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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