Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
812 changes: 567 additions & 245 deletions stackit/internal/services/sfs/sfs_acc_test.go

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions stackit/internal/services/sfs/share/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ func (r *shareDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
},
"export_policy": schema.StringAttribute{
Description: `Name of the Share Export Policy to use in the Share.
Note that if this is not set, the Share can only be mounted in read only by
clients with IPs matching the IP ACL of the Resource Pool hosting this Share.
Note that if this is not set, the Share can only be mounted in read only by
clients with IPs matching the IP ACL of the Resource Pool hosting this Share.
You can also assign a Share Export Policy after creating the Share`,
Computed: true,
},
"space_hard_limit_gigabytes": schema.Int64Attribute{
Computed: true,
Description: `Space hard limit for the Share.
Description: `Space hard limit for the Share.
If zero, the Share will have access to the full space of the Resource Pool it lives in.
(unit: gigabytes)`,
},
Expand Down Expand Up @@ -207,8 +207,10 @@ func mapDataSourceFields(_ context.Context, region string, share *sfs.GetShareRe
utils.Coalesce(model.ShareId, types.StringPointerValue(share.Id)).ValueString(),
)
model.Name = types.StringPointerValue(share.Name)
if policy := share.ExportPolicy.Get(); policy != nil {
model.ExportPolicyName = types.StringPointerValue(policy.Name)
if share.ExportPolicy != nil {
if policy := share.ExportPolicy.Get(); policy != nil {
model.ExportPolicyName = types.StringPointerValue(policy.Name)
}
}

model.SpaceHardLimitGigabytes = types.Int64PointerValue(share.SpaceHardLimitGigabytes)
Expand Down
14 changes: 8 additions & 6 deletions stackit/internal/services/sfs/share/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ func (r *shareResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
},
"export_policy": schema.StringAttribute{
Description: `Name of the Share Export Policy to use in the Share.
Note that if this is set to an empty string, the Share can only be mounted in read only by
clients with IPs matching the IP ACL of the Resource Pool hosting this Share.
Note that if this is set to an empty string, the Share can only be mounted in read only by
clients with IPs matching the IP ACL of the Resource Pool hosting this Share.
You can also assign a Share Export Policy after creating the Share`,
Required: true,
Optional: true,
},
"space_hard_limit_gigabytes": schema.Int64Attribute{
Required: true,
Description: `Space hard limit for the Share.
Description: `Space hard limit for the Share.
If zero, the Share will have access to the full space of the Resource Pool it lives in.
(unit: gigabytes)`,
},
Expand Down Expand Up @@ -496,8 +496,10 @@ func mapFields(_ context.Context, share *sfs.GetShareResponseShare, region strin
)
model.Name = types.StringPointerValue(share.Name)

if policy := share.ExportPolicy.Get(); policy != nil {
model.ExportPolicyName = types.StringPointerValue(policy.Name)
if share.ExportPolicy != nil {
if policy := share.ExportPolicy.Get(); policy != nil {
model.ExportPolicyName = types.StringPointerValue(policy.Name)
}
}

model.SpaceHardLimitGigabytes = types.Int64PointerValue(share.SpaceHardLimitGigabytes)
Expand Down
10 changes: 10 additions & 0 deletions stackit/internal/services/sfs/testdata/export-policy-max.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

variable "project_id" {}
variable "name" {}
variable "rules" {}

resource "stackit_sfs_export_policy" "exportpolicy" {
project_id = var.project_id
name = var.name
rules = var.rules
}
8 changes: 8 additions & 0 deletions stackit/internal/services/sfs/testdata/export-policy-min.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

variable "project_id" {}
variable "name" {}

resource "stackit_sfs_export_policy" "exportpolicy" {
project_id = var.project_id
name = var.name
}
18 changes: 18 additions & 0 deletions stackit/internal/services/sfs/testdata/resource-pool-max.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

variable "project_id" {}
variable "name" {}
variable "availability_zone" {}
variable "performance_class" {}
variable "size_gigabytes" {}
variable "acl" {}
variable "snapshots_are_visible" {}

resource "stackit_sfs_resource_pool" "resourcepool" {
project_id = var.project_id
name = var.name
availability_zone = var.availability_zone
performance_class = var.performance_class
size_gigabytes = var.size_gigabytes
ip_acl = var.acl
snapshots_are_visible = var.snapshots_are_visible
}
16 changes: 16 additions & 0 deletions stackit/internal/services/sfs/testdata/resource-pool-min.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

variable "project_id" {}
variable "name" {}
variable "availability_zone" {}
variable "performance_class" {}
variable "size_gigabytes" {}
variable "acl" {}

resource "stackit_sfs_resource_pool" "resourcepool" {
project_id = var.project_id
name = var.name
availability_zone = var.availability_zone
performance_class = var.performance_class
size_gigabytes = var.size_gigabytes
ip_acl = var.acl
}
35 changes: 35 additions & 0 deletions stackit/internal/services/sfs/testdata/share-max.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

variable "project_id" {}
variable "resource_pool_name" {}
variable "export_policy_name" {}
variable "name" {}
variable "space_hard_limit_gigabytes" {}

resource "stackit_sfs_resource_pool" "resourcepool" {
project_id = var.project_id
name = var.resource_pool_name
availability_zone = "eu01-m"
performance_class = "Standard"
size_gigabytes = 512
ip_acl = ["192.168.42.1/32"]
region = "eu01"
}

resource "stackit_sfs_export_policy" "exportpolicy" {
project_id = var.project_id
name = var.export_policy_name
rules = [
{
ip_acl = ["192.168.2.0/24"]
order = 1
}
]
}

resource "stackit_sfs_share" "share" {
project_id = var.project_id
resource_pool_id = stackit_sfs_resource_pool.resourcepool.resource_pool_id
name = var.name
export_policy = stackit_sfs_export_policy.exportpolicy.name
space_hard_limit_gigabytes = var.space_hard_limit_gigabytes
}
22 changes: 22 additions & 0 deletions stackit/internal/services/sfs/testdata/share-min.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

variable "project_id" {}
variable "resource_pool_name" {}
variable "name" {}
variable "space_hard_limit_gigabytes" {}

resource "stackit_sfs_resource_pool" "resourcepool" {
project_id = var.project_id
name = var.resource_pool_name
availability_zone = "eu01-m"
performance_class = "Standard"
size_gigabytes = 512
ip_acl = ["192.168.42.1/32"]
region = "eu01"
}

resource "stackit_sfs_share" "share" {
project_id = var.project_id
resource_pool_id = stackit_sfs_resource_pool.resourcepool.resource_pool_id
name = var.name
space_hard_limit_gigabytes = var.space_hard_limit_gigabytes
}
Loading