mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-08-25 12: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"
|
||||
mkDisk = "disk"
|
||||
mkDiskDatastoreID = "datastore_id"
|
||||
mkDiskMountOptions = "mount_options"
|
||||
mkDiskSize = "size"
|
||||
mkFeatures = "features"
|
||||
mkFeaturesNesting = "nesting"
|
||||
@ -329,8 +330,9 @@ func Container() *schema.Resource {
|
||||
DefaultFunc: func() (interface{}, error) {
|
||||
return []interface{}{
|
||||
map[string]interface{}{
|
||||
mkDiskDatastoreID: dvDiskDatastoreID,
|
||||
mkDiskSize: dvDiskSize,
|
||||
mkDiskDatastoreID: dvDiskDatastoreID,
|
||||
mkDiskSize: dvDiskSize,
|
||||
mkDiskMountOptions: []string{},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
@ -351,6 +353,14 @@ func Container() *schema.Resource {
|
||||
Default: dvDiskSize,
|
||||
ValidateDiagFunc: validation.ToDiagFunc(validation.IntAtLeast(0)),
|
||||
},
|
||||
mkDiskMountOptions: {
|
||||
Type: schema.TypeList,
|
||||
Description: "Extra mount options",
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
MaxItems: 1,
|
||||
@ -1709,12 +1719,19 @@ func containerCreateCustom(ctx context.Context, d *schema.ResourceData, m interf
|
||||
|
||||
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)
|
||||
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.
|
||||
// see https://pve.proxmox.com/pve-docs/chapter-pct.html#_storage_backed_mount_points
|
||||
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, ":")
|
||||
disk[mkDiskDatastoreID] = volumeParts[0]
|
||||
disk[mkDiskSize] = containerConfig.RootFS.Size.InGigabytes()
|
||||
disk[mkDiskMountOptions] = containerConfig.RootFS.MountOptions
|
||||
} else {
|
||||
// Default value of "storage" is "local" according to the API documentation.
|
||||
disk[mkDiskDatastoreID] = "local"
|
||||
disk[mkDiskSize] = dvDiskSize
|
||||
disk[mkDiskMountOptions] = []string{}
|
||||
}
|
||||
|
||||
currentDisk := d.Get(mkDisk).([]interface{})
|
||||
|
Loading…
Reference in New Issue
Block a user