Default Parameters
Warning
This content is part of the legacy version of Waypoint that is no longer actively maintained. For additional information on the new vision of Waypoint, check out this blog post and the HCP Waypoint documentation.
In addition to user defined return values you can also request waypoint injects default parameters. At present there are 11 possible parameters which you can inject, these are:
- context.Context
- *component.Source
- *component.JobInfo
- *component.DeploymentConfig
- hclog.Logger
- terminal.UI
- *component.LabelSet
context.Context
https://pkg.go.dev/context#Context
Context is a default parameter and is used by Waypoint to notify you when the work that component is
performing should be cancelled. As with any Go code calling the Err()
function on the Context will return
an error if the Context has already been cancelled, you can also use the channel returned by the Done()
function
to notify you when Waypoint cancels the current operation.
*component.Source
https://pkg.go.dev/github.com/hashicorp/waypoint-plugin-sdk/component#Source
Source is a data struct which provides the current application name App
, and Path
which is the directory
containing the current Waypoint file.
*component.JobInfo
https://pkg.go.dev/github.com/hashicorp/waypoint-plugin-sdk/component#JobInfo
JobInfo is a data struct which provides details related to the current Job.
*component.DeploymentConfig
https://pkg.go.dev/github.com/hashicorp/waypoint-plugin-sdk/component#DeploymentConfig
DeploymentConfig contains configuration which the entrypoint binary requires in order to run correctly. For example if you deploy an application to Google Cloud Run which is using the builtin Docker builder, the entrypoint is automatically bundled into the container. In order for the entrypoint to function correctly it needs to be configured correctly.
To simplify the configuration of the entrypoint environment variables DeploymentConfig also has a function which returns a map of the correct environment variables and their values.
hclog.Logger
https://pkg.go.dev/github.com/hashicorp/go-hclog#Logger
Logger provides you with the ability to write to the Waypoint standard logger using different log levels such as
Info, Debug, Trace, etc. By default, log output is disabled when running a waypoint command. The environment variable
WAYPOINT_LOG_LEVEL=[debug, trace, info, warning]
can be set to enable log output in the CLI.
terminal.UI
https://pkg.go.dev/github.com/hashicorp/waypoint-plugin-sdk/terminal#UI
UI allows you to build rich output for your plugin, more details on using terminal.UI can be found in the Interacting with the UI section.
*component.LabelSet
https://pkg.go.dev/github.com/hashicorp/waypoint-plugin-sdk/component#LabelSet
LabelSet allows you to read the labels defined at an app level on your Waypoint configuration.
The LabelSet struct exposes a single field Labels which is of type map[string]string
, this collection contains
all the labels defined in the configuration.