»Compiling the plugin

Video tutorial below:

To compile the plugin, you can use the Makefile that the template generated for you. The contents of this file look like:

PLUGIN_NAME=template

all: protos build

protos:
    @echo ""
    @echo "Build Protos"

  protoc -I . --go_out=plugins=grpc:builder --go_opt=paths=source_relative ./builder/output.proto
  protoc -I . --go_out=plugins=grpc:registry --go_opt=paths=source_relative ./registry/output.proto
  protoc -I . --go_out=plugins=grpc:platform --go_opt=paths=source_relative ./platform/output.proto
  protoc -I . --go_out=plugins=grpc:release --go_opt=paths=source_relative ./release/output.proto

build:
    @echo ""
    @echo "Compile Plugin"

    go build -o ./bin/waypoint-plugin-${PLUGIN_NAME} ./main.go

Let's modify it a little. Edit the Makefile and change the PLUGIN_NAME to your plugin name gobuilder

PLUGIN_NAME=gobuilder

By default, the templated plugin will generate the Go code for all the different components, since your plugin only implements the Builder component, you can remove all the other protoc commands.

  protoc -I . --go_out=plugins=grpc:builder --go_opt=paths=source_relative ./builder/output.proto

Your Makefile should now look like:

PLUGIN_NAME=gobuilder

all: protos build

protos:
    @echo ""
    @echo "Build Protos"

  protoc -I . --go_out=plugins=grpc:builder --go_opt=paths=source_relative ./builder/output.proto

build:
    @echo ""
    @echo "Compile Plugin"

    go build -o ./bin/waypoint-plugin-${PLUGIN_NAME} ./main.go

With the Makefile changed, you can now run make to build the plugin.

make

Build Protos

protoc -I . --go_out=plugins=grpc:builder --go_opt=paths=source_relative ./builder/output.proto

Compile Plugin
go build -o ./bin/waypoint-plugin-gobuilder ./main.go

If you look in the ./bin folder, you will see your compile plugin.

ls ./bin
waypoint-plugin-gobuilder

Let's now install the plugin so that it can be used by the Waypoint CLI.

»Installing the plugin

You can install your plugin using the make install command. Waypoint will automatically load plugins from certain know locations, these are:

  • Same directory as any waypoint.hcl
  • <waypoint_app_folder>/.waypoint/plugins/
  • \$XDG_CONFIG_HOME/waypoint/plugins/

The make install command will copy the plugin to the Waypoint config in your $HOME folder. Note that this may not match your $XDG_CONFIG_HOME value so please double check this is correct for you.

make install

Installing Plugin
cp ./bin/waypoint-plugin-gobuilder /home/nicj/.config/waypoint/plugins/

Now the plugin has been installed, let's create an example application which uses your new plugin.

Next - Creating an Example Application