Skip to content

Commit c7155cd

Browse files
committed
Update readme - packet init usage
1 parent 8352c0c commit c7155cd

7 files changed

Lines changed: 52 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
## 1.0.0
44

5-
Copy codebase from https://github.com/UpCloudLtd/upcloud-packer
5+
* Upgrade to Packer 1.7.0
6+
* Copy codebase from https://github.com/UpCloudLtd/upcloud-packer

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ build:
1515

1616
install: build
1717
mkdir -p ~/.packer.d/plugins
18-
install ./packer-plugin-upcloud ~/.packer.d/plugins/packer-builder-upcloud
18+
install ./packer-plugin-upcloud ~/.packer.d/plugins/
1919

2020
.PHONY: default test test_integration lint build install

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
# UpCloud Packer builder
22

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

56
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.
67

78
## Installation
89

10+
### Installing using Packer Packet Manager
11+
12+
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:
13+
14+
```hcl
15+
...
16+
packer {
17+
required_plugins {
18+
upcloud = {
19+
version = ">=v1.0.0"
20+
source = "github.com/UpCloudLtd/upcloud"
21+
}
22+
}
23+
}
24+
...
25+
```
26+
27+
Runn following command and check the output:
28+
```sh
29+
$ packer init examples/basic_example.pkr.hcl
30+
31+
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"
32+
```
33+
934
### Pre-built binaries
1035

1136
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/).
@@ -24,7 +49,7 @@ Run the following commands to download and install the plugin from the source.
2449
git clone https://github.com/UpCloudLtd/packer-plugin-upcloud
2550
cd packer-plugin-upcloud
2651
go build
27-
cp packer-plugin-upcloud ~/.packer.d/plugins/packer-builder-upcloud
52+
cp packer-plugin-upcloud ~/.packer.d/plugins/
2853
```
2954

3055
## Usage

examples/basic_example.pkr.hcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ variable "password" {
88
default = "${env("UPCLOUD_API_PASSWORD")}"
99
}
1010

11+
packer {
12+
required_plugins {
13+
upcloud = {
14+
version = ">=v1.0.0"
15+
source = "github.com/UpCloudLtd/upcloud"
16+
}
17+
}
18+
}
19+
1120
source "upcloud" "test" {
1221
username = "${var.username}"
1322
password = "${var.password}"

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/UpCloudLtd/upcloud-go-api v0.0.0-20210127073406-2964ed7e5972
1111
github.com/agext/levenshtein v1.2.3 // indirect
1212
github.com/armon/go-metrics v0.3.6 // indirect
13-
github.com/aws/aws-sdk-go v1.37.13 // indirect
13+
github.com/aws/aws-sdk-go v1.37.14 // indirect
1414
github.com/fatih/color v1.10.0 // indirect
1515
github.com/frankban/quicktest v1.11.3 // indirect
1616
github.com/gofrs/flock v0.8.0 // indirect
@@ -40,7 +40,7 @@ require (
4040
github.com/zclconf/go-cty v1.7.1
4141
go.opencensus.io v0.22.6 // indirect
4242
golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df
43-
golang.org/x/oauth2 v0.0.0-20210216194517-16ff1888fd2e // indirect
43+
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99 // indirect
4444
golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b // indirect
4545
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
4646
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ github.com/aws/aws-sdk-go v1.36.5 h1:SouM2ar1A8f+3DYWW622sDdqkkZAO3ha4j8GQjiPLFg
147147
github.com/aws/aws-sdk-go v1.36.5/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
148148
github.com/aws/aws-sdk-go v1.37.13 h1:7w1gJHJdpMfv+JbedCeOkQrYu46k0j01ULpv7oLfb3U=
149149
github.com/aws/aws-sdk-go v1.37.13/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
150+
github.com/aws/aws-sdk-go v1.37.14 h1:thuR1hd1doCvsaMDYDMhqCGSmw39bSvZaw+DPGhMm5w=
151+
github.com/aws/aws-sdk-go v1.37.14/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
150152
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
151153
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
152154
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
@@ -888,6 +890,8 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ
888890
golang.org/x/oauth2 v0.0.0-20210113205817-d3ed898aa8a3/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
889891
golang.org/x/oauth2 v0.0.0-20210216194517-16ff1888fd2e h1:xxTKAjlluPXFVQnUNoBO7OvmNNE/RpmyUeLVFSYiQQ0=
890892
golang.org/x/oauth2 v0.0.0-20210216194517-16ff1888fd2e/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
893+
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99 h1:5vD4XjIc0X5+kHZjx4UecYdjA6mJo+XXNoaW0EjU5Os=
894+
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
891895
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
892896
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
893897
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package main
22

33
import (
4+
"fmt"
5+
"os"
6+
47
upcloud "github.com/UpCloudLtd/packer-plugin-upcloud/builder/upcloud"
58

69
"github.com/hashicorp/packer-plugin-sdk/plugin"
710
)
811

912
func main() {
10-
server, err := plugin.Server()
13+
pps := plugin.NewSet()
14+
pps.RegisterBuilder(plugin.DEFAULT_NAME, new(upcloud.Builder))
15+
err := pps.Run()
1116
if err != nil {
12-
panic(err)
13-
}
14-
15-
if err := server.RegisterBuilder(new(upcloud.Builder)); err != nil {
16-
panic(err)
17+
fmt.Fprintln(os.Stderr, err.Error())
18+
os.Exit(1)
1719
}
18-
19-
server.Serve()
2020
}

0 commit comments

Comments
 (0)