Skip to content

Commit

Permalink
implemented API v0.31 changes; project volume creation depends on reg…
Browse files Browse the repository at this point in the history
…ion, not zone
  • Loading branch information
gxben committed Apr 16, 2024
1 parent ba05879 commit 351171e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/resources/volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Manages a storage volume resource

- `name` (String) Resource name
- `project` (String) Associated project name or ID
- `region` (String) Associated region name or ID
- `size` (Number) The volume size (expressed in GB)
- `type` (String) The volume type (valid options: 'os', 'iso', 'raw')
- `zone` (String) Associated zone name or ID

### Optional

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
github.com/3th1nk/cidr v0.2.0
github.com/AfterShip/email-verifier v1.4.0
github.com/dalet-oss/kowabunga-api v0.30.0
github.com/dalet-oss/kowabunga-api v0.31.0
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-framework v1.4.2
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7N
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/dalet-oss/kowabunga-api v0.30.0 h1:FJw2lmOT6MCXtIn6oolLdTrb2K79ssoK9GqvVQElSzs=
github.com/dalet-oss/kowabunga-api v0.30.0/go.mod h1:AoV+X1yaCm4mxSnY+z5tfRPQqpYURioy/bXp5bB/pQc=
github.com/dalet-oss/kowabunga-api v0.31.0 h1:1dXvdONKIvvOZgMKH/9vxK/MmhcPPFUmpKyevE/dIM0=
github.com/dalet-oss/kowabunga-api v0.31.0/go.mod h1:AoV+X1yaCm4mxSnY+z5tfRPQqpYURioy/bXp5bB/pQc=
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
12 changes: 6 additions & 6 deletions internal/provider/kowabunga_volume_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type VolumeResourceModel struct {
Name types.String `tfsdk:"name"`
Desc types.String `tfsdk:"desc"`
Project types.String `tfsdk:"project"`
Zone types.String `tfsdk:"zone"`
Region types.String `tfsdk:"region"`
Pool types.String `tfsdk:"pool"`
Template types.String `tfsdk:"template"`
Type types.String `tfsdk:"type"`
Expand All @@ -62,8 +62,8 @@ func (r *VolumeResource) Schema(ctx context.Context, req resource.SchemaRequest,
MarkdownDescription: "Associated project name or ID",
Required: true,
},
KeyZone: schema.StringAttribute{
MarkdownDescription: "Associated zone name or ID",
KeyRegion: schema.StringAttribute{
MarkdownDescription: "Associated region name or ID",
Required: true,
},
KeyPool: schema.StringAttribute{
Expand Down Expand Up @@ -133,8 +133,8 @@ func (r *VolumeResource) Create(ctx context.Context, req resource.CreateRequest,
errorCreateGeneric(resp, err)
return
}
// find parent zone
zoneId, err := getZoneID(ctx, r.Data, data.Zone.ValueString())
// find parent region
regionId, err := getRegionID(ctx, r.Data, data.Region.ValueString())
if err != nil {
errorCreateGeneric(resp, err)
return
Expand All @@ -147,7 +147,7 @@ func (r *VolumeResource) Create(ctx context.Context, req resource.CreateRequest,

// create a new volume
m := volumeResourceToModel(data)
api := r.Data.K.ProjectAPI.CreateProjectZoneVolume(ctx, projectId, zoneId).Volume(m)
api := r.Data.K.ProjectAPI.CreateProjectRegionVolume(ctx, projectId, regionId).Volume(m)
if poolId != "" {
api = api.PoolId(poolId)
}
Expand Down

0 comments on commit 351171e

Please sign in to comment.