Skip to content
Open
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
18 changes: 11 additions & 7 deletions internal/kubernetes/storage/v1/storageclass/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ import (
// Generate the StorageClass.
func Generate(d *schema.ResourceData) storagev1.StorageClass {
var (
name = d.Get(FieldName).(string)
rawLabels = d.Get(FieldLabels).(map[string]interface{})
provisioner = d.Get(FieldProvisioner).(string)
parameters = d.Get(FieldParameters).(map[string]interface{})
name = d.Get(FieldName).(string)
rawLabels = d.Get(FieldLabels).(map[string]interface{})
provisioner = d.Get(FieldProvisioner).(string)
parameters = d.Get(FieldParameters).(map[string]interface{})
mountOptions = d.Get(FieldMountOptions).([]interface{})
)

return storagev1.StorageClass{
class := storagev1.StorageClass{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: interfaceutils.ExpandMap(rawLabels),
},
Provisioner: provisioner,
Parameters: interfaceutils.ExpandMap(parameters),
Provisioner: provisioner,
MountOptions: interfaceutils.ExpandSlice(mountOptions),
Parameters: interfaceutils.ExpandMap(parameters),
}

return class
}
1 change: 1 addition & 0 deletions internal/kubernetes/storage/v1/storageclass/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func Read(d *schema.ResourceData, m interface{}) error {
d.Set(FieldLabels, storageclass.ObjectMeta.Labels)

d.Set(FieldProvisioner, storageclass.Provisioner)
d.Set(FieldMountOptions, storageclass.MountOptions)
d.Set(FieldParameters, storageclass.Parameters)

return nil
Expand Down
17 changes: 13 additions & 4 deletions internal/kubernetes/storage/v1/storageclass/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const (
// FieldLabels is a field identifier.
FieldLabels = "labels"
// FieldProvisioner is a field identifier.
FieldProvisioner = "storage_provisioner"
FieldProvisioner = "provisioner"
// FieldMountOptions is a field identifier.
FieldMountOptions = "mount_options"
// FieldParameters is a field identifier.
FieldParameters = "parameters"
)
Expand All @@ -26,19 +28,26 @@ func Resource() *schema.Resource {
Delete: Delete,

Schema: map[string]*schema.Schema{
FieldName: &schema.Schema{
FieldName: {
Type: schema.TypeString,
Required: true,
},
FieldLabels: &schema.Schema{
FieldLabels: {
Type: schema.TypeMap,
Optional: true,
},
FieldProvisioner: {
Type: schema.TypeString,
Required: true,
},
FieldParameters: &schema.Schema{
FieldMountOptions: {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
FieldParameters: {
Type: schema.TypeMap,
Optional: true,
},
Expand Down