mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-08-27 13:55:41 +00:00
Add mount_options for container rootfs
Signed-off-by: maidl0ver <maidlover@disroot.org> Signed-off-by: maidlover <117573165+maidl0ver@users.noreply.github.com>
This commit is contained in:
parent
092edf2d08
commit
84e2a023cc
@ -108,6 +108,7 @@ const (
|
|||||||
mkDescription = "description"
|
mkDescription = "description"
|
||||||
mkDisk = "disk"
|
mkDisk = "disk"
|
||||||
mkDiskDatastoreID = "datastore_id"
|
mkDiskDatastoreID = "datastore_id"
|
||||||
|
mkDiskMountOptions = "mount_options"
|
||||||
mkDiskSize = "size"
|
mkDiskSize = "size"
|
||||||
mkFeatures = "features"
|
mkFeatures = "features"
|
||||||
mkFeaturesNesting = "nesting"
|
mkFeaturesNesting = "nesting"
|
||||||
@ -331,6 +332,7 @@ func Container() *schema.Resource {
|
|||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
mkDiskDatastoreID: dvDiskDatastoreID,
|
mkDiskDatastoreID: dvDiskDatastoreID,
|
||||||
mkDiskSize: dvDiskSize,
|
mkDiskSize: dvDiskSize,
|
||||||
|
mkDiskMountOptions: []string{},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
@ -351,6 +353,14 @@ func Container() *schema.Resource {
|
|||||||
Default: dvDiskSize,
|
Default: dvDiskSize,
|
||||||
ValidateDiagFunc: validation.ToDiagFunc(validation.IntAtLeast(0)),
|
ValidateDiagFunc: validation.ToDiagFunc(validation.IntAtLeast(0)),
|
||||||
},
|
},
|
||||||
|
mkDiskMountOptions: {
|
||||||
|
Type: schema.TypeList,
|
||||||
|
Description: "Extra mount options",
|
||||||
|
Optional: true,
|
||||||
|
Elem: &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MaxItems: 1,
|
MaxItems: 1,
|
||||||
@ -1709,12 +1719,19 @@ func containerCreateCustom(ctx context.Context, d *schema.ResourceData, m interf
|
|||||||
|
|
||||||
var rootFS *containers.CustomRootFS
|
var rootFS *containers.CustomRootFS
|
||||||
|
|
||||||
|
var diskMountOptions []string = []string{}
|
||||||
|
if diskBlock[mkDiskMountOptions] != nil {
|
||||||
|
for _, opt := range diskBlock[mkDiskMountOptions].([]any) {
|
||||||
|
diskMountOptions = append(diskMountOptions, opt.(string))
|
||||||
|
}
|
||||||
|
}
|
||||||
diskSize := diskBlock[mkDiskSize].(int)
|
diskSize := diskBlock[mkDiskSize].(int)
|
||||||
if diskDatastoreID != "" && (diskSize != dvDiskSize || len(mountPoints) > 0) {
|
if diskDatastoreID != "" && (diskSize != dvDiskSize || len(mountPoints) > 0) {
|
||||||
// This is a special case where the rootfs size is set to a non-default value at creation time.
|
// This is a special case where the rootfs size is set to a non-default value at creation time.
|
||||||
// see https://pve.proxmox.com/pve-docs/chapter-pct.html#_storage_backed_mount_points
|
// see https://pve.proxmox.com/pve-docs/chapter-pct.html#_storage_backed_mount_points
|
||||||
rootFS = &containers.CustomRootFS{
|
rootFS = &containers.CustomRootFS{
|
||||||
Volume: fmt.Sprintf("%s:%d", diskDatastoreID, diskSize),
|
Volume: fmt.Sprintf("%s:%d", diskDatastoreID, diskSize),
|
||||||
|
MountOptions: &diskMountOptions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2255,10 +2272,12 @@ func containerRead(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
|||||||
volumeParts := strings.Split(containerConfig.RootFS.Volume, ":")
|
volumeParts := strings.Split(containerConfig.RootFS.Volume, ":")
|
||||||
disk[mkDiskDatastoreID] = volumeParts[0]
|
disk[mkDiskDatastoreID] = volumeParts[0]
|
||||||
disk[mkDiskSize] = containerConfig.RootFS.Size.InGigabytes()
|
disk[mkDiskSize] = containerConfig.RootFS.Size.InGigabytes()
|
||||||
|
disk[mkDiskMountOptions] = containerConfig.RootFS.MountOptions
|
||||||
} else {
|
} else {
|
||||||
// Default value of "storage" is "local" according to the API documentation.
|
// Default value of "storage" is "local" according to the API documentation.
|
||||||
disk[mkDiskDatastoreID] = "local"
|
disk[mkDiskDatastoreID] = "local"
|
||||||
disk[mkDiskSize] = dvDiskSize
|
disk[mkDiskSize] = dvDiskSize
|
||||||
|
disk[mkDiskMountOptions] = []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDisk := d.Get(mkDisk).([]interface{})
|
currentDisk := d.Get(mkDisk).([]interface{})
|
||||||
|
Loading…
Reference in New Issue
Block a user