June 20-22 Announcing HashiConf Europe full schedule: keynotes, sessions, labs & more Register Now
  • Infrastructure
    • terraform
    • packer
  • Networking
    • consul
  • Security
    • vault
    • boundary
  • Applications
    • nomad
    • waypoint
    • vagrant
  • HashiCorp Cloud Platform

    A fully managed platform to automate infrastructure on any cloud with HashiCorp products.

    • consul
    • terraform
    • vault
    • packerbeta
    Visit cloud.hashicorp.com
  • Overview
  • Tutorials
  • Docs
  • CLI
  • Plugins
  • Community
GitHub
Download
    • v0.8.x (latest)
    • v0.7.x
    • v0.6.x
    • v0.5.x
    • v0.4.x
    • v0.3.x
    • v0.2.x
    • v0.1.x
    • Overview
      • Overview
      • Helm
      • Heroku, Vercel, etc.
      • Kubernetes
  • Getting Started
    • Overview
    • Compatibility Promise
    • Protocol Version Table
    • Release Notifications
      • Overview
      • Upgrade to 0.2.0

    • Install
    • Externally Built Images
    • Building Container Images
    • Helm Deployment
    • YAML-Free Deployment
    • YAML Directory Deployment
    • Resource Status
    • ConfigMaps and Secrets

    • Overview
    • Git Integration
    • Remote Operations
    • Overview
    • Build
    • Deploy
    • Release
    • Hooks
    • Labels
    • Workspace and Label Scoping
    • Overview
      • Overview
      • Input Variables
      • External Data
      • artifact
      • deploy
      • entrypoint
      • labels
      • path
      • workspace
      • Overview
      • Full Reference
      • Templating
      • Overview
      • Expressions
      • JSON Syntax
    • app
    • build
    • config
    • deploy
    • hook
    • plugin
    • registry
    • release
    • runner
    • url
    • use
    • variable
  • URL Service
  • Logs
  • Exec
    • Overview
    • Dynamic Values
    • Files
    • Internal Values
    • Workspace and Label Scoping
    • Overview
      • Overview
      • OIDC
      • Overview
      • Maintenance
      • Production
      • Security
    • Express Server Install
    • Overview
    • Configuration
    • Profiles
    • On-Demand Runner
    • Additional Runners
  • Workspaces
  • Plugins
  • Triggers

    • Overview
      • Overview
      • Registering Plugin Components
      • Handling Configuration
      • Implementing the Builder Interface
      • Compiling the Plugin
      • Creating an Example Application
      • Testing the Plugin
    • Initializing the SDK
    • Passing Values Between Components
      • Overview
      • Authenticator
      • Configurable
      • ConfigurableNotify
      • Builder
      • Registry
      • Platform
      • ReleaseManager
      • Destroy
      • Status
      • Default Parameters
      • Overview
    • Overview
    • Disable
    • Overview
    • GitHub Actions
    • GitLab CI/CD
    • CircleCI
    • Jenkins
  • Troubleshooting
  • Glossary

    • Overview
    • Architecture
    • Operation Execution
  • Roadmap
Type '/' to Search

»Configurable

https://pkg.go.dev/github.com/hashicorp/waypoint-plugin-sdk/component#Configurable

All plugins can receive the configuration from the Waypoint file by implementing the Configurable interface. Configurable is always called before the main component methods and is available for any component which has a definable config block, build, registry, deploy, and release.

Build Lifecycle

To implement configuration for your plugins you implement the Configurable interface on your component. This has a single method Config which has two return parameters, interface{} and error. The first parameter is a reference to a Go struct which you would like Waypoint to populate with the details from a configuration stanza.

type Configurable interface {
  Config() (interface{}, error)
}
type Configurable interface {
  Config() (interface{}, error)
}

The caller of Config expects that you return a Go Struct which has been annotated with HCL tags. For example, if you look at the following configuration there are two parameters defined output_name and source.

 build {
    use "golang" {
      output_name = "server"
      source = "./"
    }
}
 build {
    use "golang" {
      output_name = "server"
      source = "./"
    }
}

To receive this information in your plugin you need to create a struct which is annotated with HCL tags as shown below.

type BuildConfig struct {
  OutputName string `hcl:"output_name,optional"`
  Source     string `hcl:"source,optional"`
}
type BuildConfig struct {
  OutputName string `hcl:"output_name,optional"`
  Source     string `hcl:"source,optional"`
}

You can then return a reference to an instance of this Struct from the Config function. The Waypoint SDK will call the Config function on your component and will set the configuration parameters to the fields on the returned struct based on the tag specified.

type Builder struct {
  config BuildConfig
}

// Config ensures that Builder implements the method from the Configurable interface
func (b *Builder) Config() (interface{}, error) {
  return &b.config, nil
}
type Builder struct {
  config BuildConfig
}

// Config ensures that Builder implements the method from the Configurable interface
func (b *Builder) Config() (interface{}, error) {
  return &b.config, nil
}

This process uses the standard HCL2 decoder and it is possible to create complex configuration which contains nested child blocks. An example showing more complex nested configuration blocks can be seen in the Google Cloud Run plugin.

https://github.com/hashicorp/waypoint/blob/a3eb9e6872a80ed9f3e5a650fda13bd46f592c99/builtin/google/cloudrun/platform.go#L510

For a general overview of HCL2 configuration please see the HCL github repo and documentation.

https://github.com/hashicorp/hcl

github logoEdit this page

Using Waypoint

The best way to understand what Waypoint can enable for your projects is to give it a try.

Waypoint tutorials
Waypoint documentation
Tutorial

Get Started - Kubernetes

Build, deploy, and release applications to a Kubernetes cluster.

View
Tutorial

Introduction to Waypoint

Waypoint enables you to publish any application to any platform with a single file and a single command.

View

Waypoint is maintained by HashiCorp, Inc.

View Code of Conduct
DocumentationCLI ReferenceTutorialsIntegrations
All systems normal