Skip to content

Commit

Permalink
Update readme - packet init usage
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfrei committed Feb 19, 2021
1 parent 8352c0c commit c7155cd
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

## 1.0.0

Copy codebase from https://github.com/UpCloudLtd/upcloud-packer
* Upgrade to Packer 1.7.0
* Copy codebase from https://github.com/UpCloudLtd/upcloud-packer
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ build:

install: build
mkdir -p ~/.packer.d/plugins
install ./packer-plugin-upcloud ~/.packer.d/plugins/packer-builder-upcloud
install ./packer-plugin-upcloud ~/.packer.d/plugins/

.PHONY: default test test_integration lint build install
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
# UpCloud Packer builder

![Build Status](https://github.com/UpCloudLtd/packer-plugin-upcloud/workflows/test/badge.svg)
![Release Status](https://github.com/UpCloudLtd/packer-plugin-upcloud/workflows/test/release.svg)

This is a builder plugin for Packer which can be used to generate storage templates on UpCloud. It utilises the [UpCloud Go API](https://github.com/UpCloudLtd/upcloud-go-api) to interface with the UpCloud API.

## Installation

### Installing using Packer Packet Manager

In order to use `packer init` you need to have Packer version ">=1.7.0" installed. Config template should be in `hcl` format and contains `required_plugins` block. For example:

```hcl
...
packer {
required_plugins {
upcloud = {
version = ">=v1.0.0"
source = "github.com/UpCloudLtd/upcloud"
}
}
}
...
```

Runn following command and check the output:
```sh
$ packer init examples/basic_example.pkr.hcl

Installed plugin github.com/upcloudltd/upcloud v1.0.0 in "/Users/johndoe/.packer.d/plugins/github.com/upcloudltd/upcloud/packer-plugin-upcloud_v1.0.0_x5.0_darwin_amd64"
```

### Pre-built binaries

You can download the pre-built binaries of the plugin from the [GitHub releases page](https://github.com/UpCloudLtd/packer-plugin-upcloud/releases). Just download the archive for your operating system and architecture, unpack it, and place the binary in the appropriate location, e.g. on Linux `~/.packer.d/plugins`. Make sure the file is executable, then install [Packer](https://www.packer.io/).
Expand All @@ -24,7 +49,7 @@ Run the following commands to download and install the plugin from the source.
git clone https://github.com/UpCloudLtd/packer-plugin-upcloud
cd packer-plugin-upcloud
go build
cp packer-plugin-upcloud ~/.packer.d/plugins/packer-builder-upcloud
cp packer-plugin-upcloud ~/.packer.d/plugins/
```

## Usage
Expand Down
9 changes: 9 additions & 0 deletions examples/basic_example.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ variable "password" {
default = "${env("UPCLOUD_API_PASSWORD")}"
}

packer {
required_plugins {
upcloud = {
version = ">=v1.0.0"
source = "github.com/UpCloudLtd/upcloud"
}
}
}

source "upcloud" "test" {
username = "${var.username}"
password = "${var.password}"
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/UpCloudLtd/upcloud-go-api v0.0.0-20210127073406-2964ed7e5972
github.com/agext/levenshtein v1.2.3 // indirect
github.com/armon/go-metrics v0.3.6 // indirect
github.com/aws/aws-sdk-go v1.37.13 // indirect
github.com/aws/aws-sdk-go v1.37.14 // indirect
github.com/fatih/color v1.10.0 // indirect
github.com/frankban/quicktest v1.11.3 // indirect
github.com/gofrs/flock v0.8.0 // indirect
Expand Down Expand Up @@ -40,7 +40,7 @@ require (
github.com/zclconf/go-cty v1.7.1
go.opencensus.io v0.22.6 // indirect
golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df
golang.org/x/oauth2 v0.0.0-20210216194517-16ff1888fd2e // indirect
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99 // indirect
golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ github.com/aws/aws-sdk-go v1.36.5 h1:SouM2ar1A8f+3DYWW622sDdqkkZAO3ha4j8GQjiPLFg
github.com/aws/aws-sdk-go v1.36.5/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.37.13 h1:7w1gJHJdpMfv+JbedCeOkQrYu46k0j01ULpv7oLfb3U=
github.com/aws/aws-sdk-go v1.37.13/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.37.14 h1:thuR1hd1doCvsaMDYDMhqCGSmw39bSvZaw+DPGhMm5w=
github.com/aws/aws-sdk-go v1.37.14/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down Expand Up @@ -888,6 +890,8 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20210113205817-d3ed898aa8a3/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210216194517-16ff1888fd2e h1:xxTKAjlluPXFVQnUNoBO7OvmNNE/RpmyUeLVFSYiQQ0=
golang.org/x/oauth2 v0.0.0-20210216194517-16ff1888fd2e/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99 h1:5vD4XjIc0X5+kHZjx4UecYdjA6mJo+XXNoaW0EjU5Os=
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package main

import (
"fmt"
"os"

upcloud "github.com/UpCloudLtd/packer-plugin-upcloud/builder/upcloud"

"github.com/hashicorp/packer-plugin-sdk/plugin"
)

func main() {
server, err := plugin.Server()
pps := plugin.NewSet()
pps.RegisterBuilder(plugin.DEFAULT_NAME, new(upcloud.Builder))
err := pps.Run()
if err != nil {
panic(err)
}

if err := server.RegisterBuilder(new(upcloud.Builder)); err != nil {
panic(err)
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}

server.Serve()
}

0 comments on commit c7155cd

Please sign in to comment.