Skip to content

Commit

Permalink
feat(resource_machine): enable snapshotting related options (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatha authored Jun 13, 2023
1 parent cd3c005 commit 16187c6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name-template: v$NEXT_PATCH_VERSION
tag-template: v$vNEXT_PATCH_VERSION
tag-template: v$NEXT_PATCH_VERSION

template: |
## What’s Changed
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
push:
tags:
- 'v*'
- "v*"
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v2
-
name: Unshallow
- name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
-
name: Import GPG key
- name: Import GPG key
id: import_gpg
# TODO: move this to HashiCorp namespace or find alternative that is just simple gpg commands
# see https://github.com/hashicorp/terraform-provider-scaffolding/issues/22
Expand All @@ -39,12 +35,11 @@ jobs:
# These secrets will need to be configured for the repository:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
Expand Down
78 changes: 42 additions & 36 deletions pkg/provider/resource_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func resourceMachineCreate(d *schema.ResourceData, m interface{}) error {
body.AppendAsIfSet(d, "network_id", "networkId")
body.AppendAsIfSet(d, "shutdown_timeout_in_hours", "shutdownTimeoutInHours")
body.AppendAsIfSet(d, "is_managed", "isManaged")
body.AppendAsIfSet(d, "perform_auto_snapshot", "performAutoSnapshot")
body.AppendAsIfSet(d, "auto_snapshot_frequency", "autoSnapshotFrequency")
body.AppendAsIfSet(d, "auto_snapshot_save_count", "autoSnapshotSaveCount")

s := d.Get("live_forever")
if s.(bool) == true {
Expand Down Expand Up @@ -164,151 +167,154 @@ func resourceMachine() *schema.Resource {
},

Schema: map[string]*schema.Schema{
"region": &schema.Schema{
"region": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"machine_type": &schema.Schema{
"machine_type": {
Type: schema.TypeString,
Required: true,
},
"size": &schema.Schema{
"size": {
Type: schema.TypeInt,
Required: true,
},
"billing_type": &schema.Schema{
"billing_type": {
Type: schema.TypeString,
Required: true,
},
"name": &schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"template_id": &schema.Schema{
"template_id": {
Type: schema.TypeString,
Required: true,
},
"assign_public_ip": &schema.Schema{
"assign_public_ip": {
Type: schema.TypeBool,
Optional: true,
},
"network_id": &schema.Schema{
"network_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"team_id": &schema.Schema{
"team_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"user_id": &schema.Schema{
"user_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"email": &schema.Schema{
"email": {
Type: schema.TypeString,
Optional: true,
},
"password": &schema.Schema{
"password": {
Type: schema.TypeString,
Optional: true,
},
"firstname": &schema.Schema{
"firstname": {
Type: schema.TypeString,
Optional: true,
},
"lastname": &schema.Schema{
"lastname": {
Type: schema.TypeString,
Optional: true,
},
"notification_email": &schema.Schema{
"notification_email": {
Type: schema.TypeString,
Optional: true,
},
"script_id": &schema.Schema{
"script_id": {
Type: schema.TypeString,
Optional: true,
},
"dt_last_run": &schema.Schema{
"dt_last_run": {
Type: schema.TypeString,
Computed: true,
},
"os": &schema.Schema{
"os": {
Type: schema.TypeString,
Computed: true,
},
"ram": &schema.Schema{
"ram": {
Type: schema.TypeString,
Computed: true,
},
"cpus": &schema.Schema{
"cpus": {
Type: schema.TypeInt,
Computed: true,
},
"gpu": &schema.Schema{
"gpu": {
Type: schema.TypeString,
Computed: true,
},
"storage_total": &schema.Schema{
"storage_total": {
Type: schema.TypeString,
Computed: true,
},
"storage_used": &schema.Schema{
"storage_used": {
Type: schema.TypeString,
Computed: true,
},
"usage_rate": &schema.Schema{
"usage_rate": {
Type: schema.TypeString,
Computed: true,
},
"shutdown_timeout_in_hours": &schema.Schema{
"shutdown_timeout_in_hours": {
Type: schema.TypeInt,
Optional: true,
},
"shutdown_timeout_forces": &schema.Schema{
"shutdown_timeout_forces": {
Type: schema.TypeBool,
Computed: true,
},
"perform_auto_snapshot": &schema.Schema{
"perform_auto_snapshot": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"auto_snapshot_frequency": &schema.Schema{
"auto_snapshot_frequency": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"auto_snapshot_save_count": &schema.Schema{
"auto_snapshot_save_count": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"agent_type": &schema.Schema{
"agent_type": {
Type: schema.TypeString,
Computed: true,
},
"dt_created": &schema.Schema{
"dt_created": {
Type: schema.TypeString,
Computed: true,
},
"state": &schema.Schema{
"state": {
Type: schema.TypeString,
Computed: true,
},
"private_ip_address": &schema.Schema{
"private_ip_address": {
Type: schema.TypeString,
Computed: true,
},
"public_ip_address": &schema.Schema{
"public_ip_address": {
Type: schema.TypeString,
Computed: true,
},
"live_forever": &schema.Schema{
"live_forever": {
Type: schema.TypeBool,
Optional: true,
},
"is_managed": &schema.Schema{
"is_managed": {
Type: schema.TypeBool,
Optional: true,
},
Expand Down

0 comments on commit 16187c6

Please sign in to comment.