Skip to content

Commit

Permalink
Register plug-in as Packer integration (#133)
Browse files Browse the repository at this point in the history
* Upgrade plugin for integrations library

* Update top-level README for integration

* Update workflows

* Update integration Organization name

* Update identifier in workflows

* Makefile: replace build-docs by generate

* Update .web-docs/metadata.hcl

Co-authored-by: Wilken Rivera <[email protected]>

* docs/README.md: Fix broken plugin links on integration portal

* ci(integration): correct tag format

---------

Co-authored-by: BrandonRomano <[email protected]>
Co-authored-by: Lucas Bajolet <[email protected]>
Co-authored-by: Jules Castéran <[email protected]>
  • Loading branch information
4 people authored Dec 26, 2023
1 parent bc94451 commit 1316808
Show file tree
Hide file tree
Showing 10 changed files with 489 additions and 70 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ensure-docs-compiled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Ensure Docs are Compiled
on:
push:
jobs:
ensure-docs-compiled:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎
uses: actions/checkout@v2
- uses: actions/setup-go@v4
- shell: bash
run: make generate
- shell: bash
run: |
if [[ -z "$(git status -s)" ]]; then
echo "OK"
else
echo "Docs have been updated, but the compiled docs have not been committed."
echo "Run 'make generate', and commit the result to resolve this error."
exit 1
fi
50 changes: 50 additions & 0 deletions .github/workflows/notify-integration-release-via-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Manual release workflow is used for deploying documentation updates
# on the specified branch without making an official plugin release.
name: Notify Integration Release (Manual)
on:
workflow_dispatch:
inputs:
version:
description: "The release version (semver)"
default: 1.0.0
required: false
branch:
description: "A branch or SHA"
default: 'main'
required: false
jobs:
notify-release:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
ref: ${{ github.event.inputs.branch }}
# Ensure that Docs are Compiled
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
- shell: bash
run: make generate
- shell: bash
run: |
if [[ -z "$(git status -s)" ]]; then
echo "OK"
else
echo "Docs have been updated, but the compiled docs have not been committed."
echo "Run 'make generate', and commit the result to resolve this error."
exit 1
fi
# Perform the Release
- name: Checkout integration-release-action
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
repository: hashicorp/integration-release-action
path: ./integration-release-action
- name: Notify Release
uses: ./integration-release-action
with:
# The integration identifier will be used by the Packer team to register the integration
# the expected format is packer/<GitHub Org Name>/<plugin-name>
integration_identifier: "packer/scaleway/scaleway"
release_version: ${{ github.event.inputs.version }}
release_sha: ${{ github.event.inputs.branch }}
github_token: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/notify-integration-release-via-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Notify Integration Release (Tag)
on:
push:
tags:
- 'v*' # Proper releases
jobs:
strip-version:
runs-on: ubuntu-latest
outputs:
packer-version: ${{ steps.strip.outputs.packer-version }}
steps:
- name: Strip leading v from version tag
id: strip
env:
REF: ${{ github.ref_name }}
run: |
echo "packer-version=$(echo "$REF" | sed -E 's/v?([0-9]+\.[0-9]+\.[0-9]+)/\1/')" >> "$GITHUB_OUTPUT"
notify-release:
needs:
- strip-version
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
ref: ${{ github.ref }}
# Ensure that Docs are Compiled
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
- shell: bash
run: make generate
- shell: bash
run: |
if [[ -z "$(git status -s)" ]]; then
echo "OK"
else
echo "Docs have been updated, but the compiled docs have not been committed."
echo "Run 'make generate', and commit the result to resolve this error."
exit 1
fi
# Perform the Release
- name: Checkout integration-release-action
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
repository: hashicorp/integration-release-action
path: ./integration-release-action
- name: Notify Release
uses: ./integration-release-action
with:
# The integration identifier will be used by the Packer team to register the integration
# the expected format is packer/<GitHub Org Name>/<plugin-name>
integration_identifier: "packer/scaleway/scaleway"
release_version: ${{ needs.strip-version.outputs.packer-version }}
release_sha: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .web-docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
The [Scaleway](https://www.scaleway.com) Packer plugin provides a builder for building images in
Scaleway.

### Installation

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.5"
source = "github.com/scaleway/scaleway"
}
}
}
```

Alternatively, you can use `packer plugins install` to manage installation of this plugin.

```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.

### Components

#### Builders

- [scaleway](/packer/integrations/scaleway/scaleway/latest/components/builder/scaleway) - The Scaleway Packer builder is able to create new images for use with Scaleway Compute Instance servers.
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.

174 changes: 174 additions & 0 deletions .web-docs/components/builder/scaleway/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
Type: `scaleway`
Artifact BuilderId: `hashicorp.scaleway`

The `scaleway` Packer builder is able to create new images for use with
[Scaleway](https://www.scaleway.com). 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.

The builder does _not_ manage snapshots. Once it creates an image, it is up to
you to use it or delete it.

## Configuration Reference

There are many configuration options available for the builder. They are
segmented below into two categories: required and optional parameters. Within
each category, the available configuration keys are alphabetized.

In addition to the options listed here, a
[communicator](/docs/templates/legacy_json_templates/communicator) can be configured for this
builder. In addition to the options defined there, a private key file
can also be supplied to override the typical auto-generated key:

- `ssh_private_key_file` (string) - Path to a PEM encoded private key file to use to authenticate with SSH.
The `~` can be used in path and will be expanded to the home directory
of current user.


### Required:

<!-- Code generated from the comments of the Config struct in builder/scaleway/config.go; DO NOT EDIT MANUALLY -->

- `access_key` (string) - The AccessKey corresponding to the secret key.
Will be fetched first from the [scaleway configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md).
It can also be specified via the environment variable SCW_ACCESS_KEY.

- `secret_key` (string) - The SecretKey to authenticate against the Scaleway API.
Will be fetched first from the [scaleway configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md).
It can also be specified via the environment variable SCW_SECRET_KEY.

- `project_id` (string) - The Project ID in which the instances, volumes and snapshots will be created.
Will be fetched first from the [scaleway configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md).
It can also be specified via the environment variable SCW_DEFAULT_PROJECT_ID.

- `zone` (string) - The Zone in which the instances, volumes and snapshots will be created.
Will be fetched first from the [scaleway configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md).
It can also be specified via the environment variable SCW_DEFAULT_ZONE

- `image` (string) - The UUID of the base image to use. This is the image
that will be used to launch a new server and provision it. See
the images list
get the complete list of the accepted image UUID.
The marketplace image label (eg `ubuntu_focal`) also works.

- `commercial_type` (string) - The name of the server commercial type:
DEV1-S, DEV1-M, DEV1-L, DEV1-XL,
PLAY2-PICO, PLAY2-NANO, PLAY2-MICRO,
PRO2-XXS, PRO2-XS, PRO2-S, PRO2-M, PRO2-L,
GP1-XS, GP1-S, GP1-M, GP1-L, GP1-XL,
ENT1-XXS, ENT1-XS, ENT1-S, ENT1-M, ENT1-L, ENT1-XL, ENT1-2XL,
GPU-3070-S, RENDER-S, STARDUST1-S,

<!-- End of code generated from the comments of the Config struct in builder/scaleway/config.go; -->


### Optional:

<!-- Code generated from the comments of the Config struct in builder/scaleway/config.go; DO NOT EDIT MANUALLY -->

- `api_url` (string) - The Scaleway API URL to use
Will be fetched first from the [scaleway configuration file](https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md).
It can also be specified via the environment variable SCW_API_URL

- `image_size_in_gb` (int32) - The Image size in GB. Will only work for images based on block volumes.

- `snapshot_name` (string) - The name of the resulting snapshot that will
appear in your account. Default packer-TIMESTAMP

- `image_name` (string) - The name of the resulting image that will appear in
your account. Default packer-TIMESTAMP

- `server_name` (string) - The name assigned to the server. Default
packer-UUID

- `bootscript` (string) - The id of an existing bootscript to use when
booting the server.

- `boottype` (string) - The type of boot, can be either local or
bootscript, Default bootscript

- `remove_volume` (bool) - Remove Volume

- `cleanup_machine_related_data` (string) - This value allows the user to remove information
that is particular to the instance used to build the image

- `snapshot_creation_timeout` (duration string | ex: "1h5m2s") - The time to wait for snapshot creation. Defaults to "1h"

- `image_creation_timeout` (duration string | ex: "1h5m2s") - The time to wait for image creation. Defaults to "1h"

- `server_creation_timeout` (duration string | ex: "1h5m2s") - The time to wait for server creation. Defaults to "10m"

- `server_shutdown_timeout` (duration string | ex: "1h5m2s") - The time to wait for server shutdown. Defaults to "10m"

- `user_data` (map[string]string) - User data to apply when launching the instance

- `user_data_timeout` (duration string | ex: "1h5m2s") - A custom timeout for user data to assure its completion. Defaults to "0s"

- `api_token` (string) - The token to use to authenticate with your account.
It can also be specified via environment variable SCALEWAY_API_TOKEN. You
can see and generate tokens in the "Credentials"
section of the control panel.
Deprecated, use SecretKey instead

- `organization_id` (string) - The organization id to use to identify your
organization. It can also be specified via environment variable
SCALEWAY_ORGANIZATION. Your organization id is available in the
"Account" section of the
control panel.
Previously named: api_access_key with environment variable: SCALEWAY_API_ACCESS_KEY
Deprecated, use ProjectID instead

- `region` (string) - The name of the region to launch the server in (par1
or ams1). Consequently, this is the region where the snapshot will be
available.
Deprecated, use Zone instead

<!-- End of code generated from the comments of the Config struct in builder/scaleway/config.go; -->


## Basic Example

Here is a basic example. It is completely valid as soon as you enter your own
access tokens:

**HCL2**

```hcl
source "scaleway" "example" {
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"
}
build {
sources = ["source.scaleway.example"]
}
```


**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"
}
```


When you do not specify the `ssh_private_key_file`, a temporary SSH keypair
is generated to connect the server. This key will only allow the `root` user to
connect the server.
12 changes: 12 additions & 0 deletions .web-docs/metadata.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# For full specification on the configuration of this file visit:
# https://github.com/hashicorp/integration-template#metadata-configuration
integration {
name = "Scaleway"
description = "Create new images for use with Scaleway."
identifier = "packer/scaleway/scaleway"
component {
type = "builder"
name = "Scaleway"
slug = "scaleway"
}
}
Loading

0 comments on commit 1316808

Please sign in to comment.