Skip to content

Commit

Permalink
Update goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
arnouthoebreckx committed May 6, 2023
1 parent be82a85 commit 285800c
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ examples/.terraform*
examples/terraform.tfstate*
examples/main*
bin
.vscode
.vscode
dist/
48 changes: 48 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goarch:
- amd64
- 386
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
29 changes: 14 additions & 15 deletions client/virtualmachinemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type GuestInfo struct {
}

type CreateGuestVnicRequest struct {

}

type CreateGuestResponse struct {
Expand Down Expand Up @@ -251,17 +250,17 @@ func (vdisk VDisk) String() string {
func createValidRequestMap(input []interface{}, allowedKeys []string) []map[string]interface{} {
var output []map[string]interface{}

for _, elem := range input {
if v, ok := elem.(map[string]interface{}); ok {
filtered := make(map[string]interface{})
for _, k := range allowedKeys {
if val, found := v[k]; found && val != nil && val != "" {
filtered[k] = val
}
}
output = append(output, filtered)
}
}

return output
}
for _, elem := range input {
if v, ok := elem.(map[string]interface{}); ok {
filtered := make(map[string]interface{})
for _, k := range allowedKeys {
if val, found := v[k]; found && val != nil && val != "" {
filtered[k] = val
}
}
output = append(output, filtered)
}
}

return output
}
71 changes: 35 additions & 36 deletions provider/resource_vmm_guest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package provider

import (
"context"
"fmt"
"github.com/arnouthoebreckx/terraform-provider-synology/client"
"log"
"strconv"
"time"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -24,30 +24,30 @@ func guestItem() *schema.Resource {
Required: true,
Description: "The guest name",
},
"guest_id": {
"guest_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Computed: true,
Description: "The guest name",
},
"description": {
Type: schema.TypeString,
Optional: true,
Description: "Optional. The description of the guest.",
},
"poweron": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Optional. Default VM is not powered on.",
},
"poweron": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Optional. Default VM is not powered on.",
},
"autorun": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
Description: "Optional. 0: off 1: last state 2: on",
},
"status": {
"status": {
Type: schema.TypeString,
Computed: true,
Description: "The guest status. (running/shutdown/inaccessiblen/booting/shutting_down/moving/stor_migrating/creating/importing/preparing/ha_standby/unknown/crashed/undefined",
Expand Down Expand Up @@ -96,13 +96,13 @@ func guestItem() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ForceNew: true,
Description: "Optional. Connected network group id. At least network_id or network_name should be given. Note: network_id can be an empty string to represent not being connected.",
},
"network_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ForceNew: true,
Description: "Optional. Connected network group name. At least network_id or network_name should be given.",
},
"vnic_id": {
Expand All @@ -122,34 +122,34 @@ func guestItem() *schema.Resource {
"create_type": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
ForceNew: true,
Description: "0: Create an empty vDisk, 1: Clone an existing image",
},
"vdisk_size": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
ForceNew: true,
Description: "Optional. If create_type is 0, this field must be set. The created vDisk size in MB.",
ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) {
if size, ok := val.(int); ok {
if size < 10240 {
errs = append(errs, fmt.Errorf("%q must be greater than 10240", key))
}
}
return
},
ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) {
if size, ok := val.(int); ok {
if size < 10240 {
errs = append(errs, fmt.Errorf("%q must be greater than 10240", key))
}
}
return
},
},
"image_id": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
ForceNew: true,
Description: "Optional. If create_type is 1, at least image_id or image_name should be given. The id of the image that is to be cloned. Note: Image type should be disk.",
},
"image_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ForceNew: true,
Description: "Optional. If create_type is 1, at least image_id or image_name should be given. The name of the image that is to be cloned. Note: Image type should be disk.",
},
"controller": {
Expand Down Expand Up @@ -254,7 +254,6 @@ func resourceGuestCreateItem(ctx context.Context, d *schema.ResourceData, m inte
return diags
}


func resourceGuestReadItem(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diags diag.Diagnostics

Expand Down Expand Up @@ -329,12 +328,12 @@ func resourceGuestDeleteItem(ctx context.Context, d *schema.ResourceData, m inte
service := GuestService{synologyClient: client}
name := d.Get("guest_name").(string)

// Incase of recreate turn off the VM
err := service.Power(name, false)
if err != nil {
return diag.FromErr(err)
}
time.Sleep(10 * time.Second)
// Incase of recreate turn off the VM
err := service.Power(name, false)
if err != nil {
return diag.FromErr(err)
}
time.Sleep(10 * time.Second)

err = service.Delete(name)

Expand All @@ -346,8 +345,8 @@ func resourceGuestDeleteItem(ctx context.Context, d *schema.ResourceData, m inte
}

func getShutdownNeeded(d *schema.ResourceData, shutdown_updates []string) bool {
if d.HasChanges(shutdown_updates...) {
return true
}
return false
}
if d.HasChanges(shutdown_updates...) {
return true
}
return false
}
2 changes: 1 addition & 1 deletion provider/resource_vmm_guest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ func testAccCheckSynologyVMMGuestExists(guestName string) resource.TestCheckFunc

return nil
}
}
}

0 comments on commit 285800c

Please sign in to comment.