Skip to content

Commit

Permalink
Merge pull request #3 from crusoecloud/merge-github
Browse files Browse the repository at this point in the history
Sync with Upstream
  • Loading branch information
agutierrez8 authored Jun 22, 2023
2 parents 0ad5f0b + 4025712 commit 9b9b813
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ go 1.18
require (
github.com/BurntSushi/toml v0.3.1
github.com/antihax/optional v1.0.0
github.com/crusoecloud/client-go v0.1.16
github.com/hashicorp/terraform-plugin-framework v1.2.0
)

require github.com/crusoecloud/client-go v0.1.19

require (
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
Expand All @@ -30,7 +31,7 @@ require (
github.com/vmihailenco/tagparser v0.1.1 // indirect
golang.org/x/crypto v0.8.0
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwc
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crusoecloud/client-go v0.1.16 h1:Hz0JT98uvtlPgCR6vA6oCohV6hRQomfsPK87MBP0ISk=
github.com/crusoecloud/client-go v0.1.16/go.mod h1:SIMptmQTcJYKQgdLqkmVE221UsxWcbKpIT5LpWjQRCY=
github.com/crusoecloud/client-go v0.1.19 h1:VuNFnHGlYm4w15BnC7bVy2J38LHC+prlJ52BO4C5dEU=
github.com/crusoecloud/client-go v0.1.19/go.mod h1:k1FgpUllEJtE53osEwsF+JfbFKILn5t3UuBdHYBVpdY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -93,8 +93,8 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 h1:nt+Q6cXKz4MosCSpnbMtqiQ8Oz0pxTef2B4Vca2lvfk=
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g=
golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
2 changes: 1 addition & 1 deletion internal/disk/disk_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

const (
defaultDiskLocation = "mtkn-cdp-prod"
defaultDiskLocation = "us-northcentral1-a"
defaultDiskType = "persistent-ssd"
)

Expand Down
14 changes: 14 additions & 0 deletions internal/vm/vm_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
validators "github.com/crusoecloud/terraform-provider-crusoe/internal/validators"
)

const defaultVMLocation = "us-northcentral1-a"

type vmResource struct {
client *swagger.APIClient
}
Expand All @@ -29,6 +31,7 @@ type vmResourceModel struct {
Name types.String `tfsdk:"name"`
Type types.String `tfsdk:"type"`
SSHKey types.String `tfsdk:"ssh_key"`
Location types.String `tfsdk:"location"`
StartupScript types.String `tfsdk:"startup_script"`
ShutdownScript types.String `tfsdk:"shutdown_script"`
Disks []vmDiskResourceModel `tfsdk:"disks"`
Expand Down Expand Up @@ -100,6 +103,11 @@ func (r *vmResource) Schema(ctx context.Context, req resource.SchemaRequest, res
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()}, // cannot be updated in place
Validators: []validator.String{validators.SSHKeyValidator{}},
},
"location": schema.StringAttribute{
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()}, // cannot be updated in place
},
"startup_script": schema.StringAttribute{
Optional: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()}, // cannot be updated in place
Expand Down Expand Up @@ -189,10 +197,16 @@ func (r *vmResource) Create(ctx context.Context, req resource.CreateRequest, res
diskIds = append(diskIds, d.ID)
}

vmLocation := plan.Location.ValueString()
if vmLocation == "" {
vmLocation = defaultVMLocation
}

dataResp, httpResp, err := r.client.VMsApi.CreateInstance(ctx, swagger.InstancesPostRequestV1Alpha3{
RoleId: roleID,
Name: plan.Name.ValueString(),
ProductName: plan.Type.ValueString(),
Location: vmLocation,
SshPublicKey: plan.SSHKey.ValueString(),
StartupScript: plan.StartupScript.ValueString(),
ShutdownScript: plan.ShutdownScript.ValueString(),
Expand Down

0 comments on commit 9b9b813

Please sign in to comment.