Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update install process, adding example #58

Merged
merged 1 commit into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,32 @@ Starting from version 1.7, Packer supports a new `packer init` command allowing
automatic installation of Packer plugins. Read the
[Packer documentation](https://www.packer.io/docs/commands/init) for more information.

To install this plugin, copy and paste this code into your Packer configuration .
To install this plugin, copy and paste this code into your Packer configuration.
Then, run [`packer init`](https://www.packer.io/docs/commands/init).

```hcl
packer {
required_plugins {
scaleway = {
version = ">= 1.0.0"
source = "github.com/hashicorp/scaleway"
version = ">= 1.0.5"
source = "github.com/scaleway/scaleway"
}
}
}
```


#### Using the `packer plugins install` command

```sh
$ packer plugins install github.com/scaleway/scaleway v1.0.x
```

This command will install the most recent compatible Scaleway Packer plugin matching
version constraint. If the version constraint is omitted, the most recent
version of the plugin will be installed.


#### Manual installation

You can find pre-built binary releases of the plugin [here](https://github.com/scaleway/packer-plugin-scaleway/releases).
Expand Down
62 changes: 27 additions & 35 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Scaffolding Plugins
# Scaleway Plugin

<!--
Include a short overview about the plugin.

This document is a great location for creating a table of contents for each
of the components the plugin may provide. This document should load automatically
when navigating to the docs directory for a plugin.

-->
The [Scaleway](https://www.scaleway.com) Packer plugin provides a builder for building images in
Scaleway.

## Installation

Expand All @@ -19,23 +13,35 @@ Starting from version 1.7, Packer supports a new `packer init` command allowing
automatic installation of Packer plugins. Read the
[Packer documentation](https://www.packer.io/docs/commands/init) for more information.

To install this plugin, copy and paste this code into your Packer configuration .
To install this plugin, copy and paste this code into your Packer configuration.
Then, run [`packer init`](https://www.packer.io/docs/commands/init).

```hcl
packer {
required_plugins {
name = {
version = ">= 1.0.0"
source = "github.com/hashicorp/name"
scaleway = {
version = ">= 1.0.5"
source = "github.com/scaleway/scaleway"
}
}
}
```


#### Using the `packer plugins install` command

```sh
$ packer plugins install github.com/scaleway/scaleway v1.0.x
```

This command will install the most recent compatible Scaleway Packer plugin matching
version constraint. If the version constraint is omitted, the most recent
version of the plugin will be installed.


#### Manual installation

You can find pre-built binary releases of the plugin [here](https://github.com/hashicorp/packer-plugin-name/releases).
You can find pre-built binary releases of the plugin [here](https://github.com/scaleway/packer-plugin-scaleway/releases).
Once you have downloaded the latest archive corresponding to your target OS,
uncompress it to retrieve the plugin binary file corresponding to your platform.
To install the plugin, please follow the Packer documentation on
Expand All @@ -44,35 +50,21 @@ To install the plugin, please follow the Packer documentation on

#### From Source

If you prefer to build the plugin from its source code, clone the GitHub
repository locally and run the command `go build` from the root
directory. Upon successful compilation, a `packer-plugin-name` plugin
If you prefer to build the plugin from sources, clone the GitHub repository
locally and run the command `go build` from the root
directory. Upon successful compilation, a `packer-plugin-scaleway` plugin
binary file can be found in the root directory.
To install the compiled plugin, please follow the official Packer documentation
on [installing a plugin](https://www.packer.io/docs/extending/plugins/#installing-plugins).


## Plugin Contents

The Scaffolding plugin is intended as a starting point for creating Packer plugins, containing:
The Scaleway plugin is intended as a starting point for creating Packer plugins, containing:

### Builders

- [builder](/docs/builders/builder-name.mdx) - The scaffolding builder is used to create endless Packer
plugins using a consistent plugin structure.

### Provisioners

- [provisioner](/docs/provisioners/provisioner-name.mdx) - The scaffolding provisioner is used to provisioner
Packer builds.

### Post-processors

- [post-processor](/docs/post-processors/postprocessor-name.mdx) - The scaffolding post-processor is used to
export scaffolding builds.

### Data Sources

- [data source](/docs/datasources/datasource-name.mdx) - The scaffolding data source is used to
export scaffolding data.
- [builder](/docs/builders/scaleway.mdx) - The Scaleway Packer builder is able to create new images for use with Scaleway BareMetal and Virtual cloud server.
The builder takes a source image, runs any provisioning necessary on the image after launching it, then snapshots it into a reusable image.
This reusable image can then be used as the foundation of new servers that are launched within Scaleway.

55 changes: 37 additions & 18 deletions docs/builders/scaleway.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ of new servers that are launched within Scaleway.
The builder does _not_ manage snapshots. Once it creates an image, it is up to
you to use it or delete it.

### Installation

To install this plugin using Packer v1.7.0 or later, copy and paste this code
into your Packer configuration.

Then, run [`packer init`](https://www.packer.io/docs/commands/init).


```hcl
packer {
required_plugins {
scaleway = {
version = ">= 1.0.5"
source = "github.com/scaleway/scaleway"
}
}
}
```

## Configuration Reference

There are many configuration options available for the builder. They are
Expand Down Expand Up @@ -55,24 +74,6 @@ Here is a basic example. It is completely valid as soon as you enter your own
access tokens:

<Tabs>
<Tab heading="JSON">

```json
{
"type": "scaleway",
"project_id": "YOUR PROJECT ID",
"access_key": "YOUR ACCESS KEY",
"secret_key": "YOUR SECRET KEY",
"image": "UUID OF THE BASE IMAGE",
"zone": "fr-par-1",
"commercial_type": "DEV1-S",
"ssh_username": "root",
"ssh_private_key_file": "~/.ssh/id_rsa"
}
```

</Tab>

<Tab heading="HCL2">

```hcl
Expand All @@ -92,6 +93,24 @@ build {
}
```

</Tab>

<Tab heading="JSON">

```json
{
"type": "scaleway",
"project_id": "YOUR PROJECT ID",
"access_key": "YOUR ACCESS KEY",
"secret_key": "YOUR SECRET KEY",
"image": "UUID OF THE BASE IMAGE",
"zone": "fr-par-1",
"commercial_type": "DEV1-S",
"ssh_username": "root",
"ssh_private_key_file": "~/.ssh/id_rsa"
}
```

</Tab>
</Tabs>

Expand Down
36 changes: 20 additions & 16 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
## The Example Folder
# Example

This folder must contain a fully working example of the plugin usage. The example must define the `required_plugins`
block. A pre-defined GitHub Action will run `packer init`, `packer validate`, and `packer build` to test your plugin
with the latest version available of Packer.
## Simple Packer Build

The folder can contain multiple HCL2 compatible files. The action will execute Packer at this folder level
running `packer init -upgrade .` and `packer build .`.
After cloning this repo, move to the `example` directory by running:

If the plugin requires authentication, the configuration should be provided via GitHub Secrets and set as environment
variables in the [test-plugin-example.yml](/.github/workflows/test-plugin-example.yml) file. Example:
```sh
$ cd packer-plugin-scaleway/example
```

```yml
- name: Build
working-directory: ${{ github.event.inputs.folder }}
run: PACKER_LOG=${{ github.event.inputs.logs }} packer build .
env:
AUTH_KEY: ${{ secrets.AUTH_KEY }}
AUTH_PASSWORD: ${{ secrets.AUTH_PASSWORD }}
```
Either modify `basic_scaleway.pkr.hcl` to reflect your Scaleway keys and project id, or comment that out and set the environment variables by running:

```sh
$ export SCW_DEFAULT_PROJECT_ID=<your scaleway project id>
$ export SCW_ACCESS_KEY=<your scaleway access key>
$ export SCW_SECRET_KEY=<your scaleway secret key>
```

Then run the following commands to build a simple Scaleway image via Packer:

```sh
$ packer init basic_scaleway.pkr.hcl
$ packer build basic_scaleway.pkr.hcl
```
40 changes: 0 additions & 40 deletions example/build.pkr.hcl

This file was deleted.

23 changes: 23 additions & 0 deletions example/build_scaleway.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
packer {
required_plugins {
scaleway = {
version = ">= 1.0.5"
source = "github.com/scaleway/scaleway"
}
}
}

source "scaleway" "basic" {
project_id = "YOUR PROJECT ID"
access_key = "YOUR ACCESS KEY"
secret_key = "YOUR SECRET KEY"
commercial_type = "DEV1-S"
image = "ubuntu_focal"
image_name = "basic build"
ssh_username = "root"
zone = "fr-par-1"
}

build {
sources = ["source.scaleway.basic"]
}
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/hashicorp/packer-plugin-sdk/version"

var (
// Version is the main version number that is being run at the moment.
Version = "1.0.2"
Version = "1.0.6"

// VersionPrerelease is A pre-release marker for the Version. If this is ""
// (empty string) then it means that it is a final release. Otherwise, this
Expand Down