New Interested in participating in the HCP Waypoint Private Beta Program? Apply here
  • 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
    • Overview
      • Overview
      • Helm
      • Heroku, Vercel, etc.
      • Kubernetes
  • Getting Started
    • Overview
    • Compatibility Promise
    • Protocol Version Table
    • Release Notifications
      • Overview
      • Upgrade to 0.2.0
      • Upgrade to 0.3.0
      • Upgrade to 0.4.0
      • Upgrade to 0.5.0
      • Upgrade to 0.6.0
      • Upgrade to 0.7.0
      • Upgrade to 0.8.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
      • Tokens
      • 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
      • ConfigSourcer
      • 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

»Destroy

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

The Destroyer interface is responsible for removing any resources which have been created by the waypoint deploy and release phase.

Platform

Destroy can only be implemented in Platform and ReleaseManager components and is implemented through the following interface.

type Destroyer interface {
  // DestroyFunc should return the method handle for the destroy operation.
  DestroyFunc() interface{}
}
type Destroyer interface {
  // DestroyFunc should return the method handle for the destroy operation.
  DestroyFunc() interface{}
}

DestroyFunc requires you return a function, like other interface functions Waypoint will automatically inject any of the standard parameters. In addition you can specify the output value returned from the DeployFunc, or from ReleaseFunc, the details of which you can use to clean up any deployments. As shown in the example below, the function signature for a DestroyFunc function only has a single output parameter which is an error used to signal if the destroy operation succeeded.

func (d *Deploy) DestroyFunc() interface{} {
  return d.destroy
}

func (d *Deploy) destroy(
  ctx context.Context,
  ui terminal.UI,
  deployment *Deployment,
) error {
  st := ui.Status()
  defer st.Close()

  err := os.RemoveAll(d.config.Directory)
  if err != nil {
    st.Step(terminal.ErrorStyle, fmt.Sprintf("Unable to remove deployments %s", d.config.Directory))
    return err
  }

  st.Step(terminal.StatusOK, fmt.Sprintf("Removed deployments %s", d.config.Directory))
  return nil
}
func (d *Deploy) DestroyFunc() interface{} {
  return d.destroy
}

func (d *Deploy) destroy(
  ctx context.Context,
  ui terminal.UI,
  deployment *Deployment,
) error {
  st := ui.Status()
  defer st.Close()

  err := os.RemoveAll(d.config.Directory)
  if err != nil {
    st.Step(terminal.ErrorStyle, fmt.Sprintf("Unable to remove deployments %s", d.config.Directory))
    return err
  }

  st.Step(terminal.StatusOK, fmt.Sprintf("Removed deployments %s", d.config.Directory))
  return nil
}
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