diff --git a/ignition/resource_ignition_filesystem.go b/ignition/resource_ignition_filesystem.go index 8bfb7790..5c79c44d 100644 --- a/ignition/resource_ignition_filesystem.go +++ b/ignition/resource_ignition_filesystem.go @@ -44,6 +44,12 @@ func dataSourceFilesystem() *schema.Resource { ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, }, + "mount_options": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, "path": { Type: schema.TypeString, Optional: true, @@ -112,7 +118,12 @@ func buildFilesystem(d *schema.ResourceData) (string, error) { options, hasOptions := d.GetOk("options") if hasOptions { - fs.Options = castSliceInterfaceToMountOption(options.([]interface{})) + fs.Options = castSliceInterfaceToFilesystemOptions(options.([]interface{})) + } + + mountOptions, hasMountOptions := d.GetOk("mount_options") + if hasMountOptions { + fs.MountOptions = castSliceInterfaceToMountOptions(mountOptions.([]interface{})) } b, err := json.Marshal(fs) @@ -127,7 +138,7 @@ func buildFilesystem(d *schema.ResourceData) (string, error) { return hash(string(b)), handleReport(fs.Validate(vcontext_path.ContextPath{})) } -func castSliceInterfaceToMountOption(i []interface{}) []types.FilesystemOption { +func castSliceInterfaceToFilesystemOptions(i []interface{}) []types.FilesystemOption { var o []types.FilesystemOption for _, value := range i { if value == nil { @@ -139,3 +150,16 @@ func castSliceInterfaceToMountOption(i []interface{}) []types.FilesystemOption { return o } + +func castSliceInterfaceToMountOptions(i []interface{}) []types.MountOption { + var o []types.MountOption + for _, value := range i { + if value == nil { + continue + } + + o = append(o, types.MountOption(value.(string))) + } + + return o +} diff --git a/ignition/resource_ignition_filesystem_test.go b/ignition/resource_ignition_filesystem_test.go index 7da3f003..b63877d1 100644 --- a/ignition/resource_ignition_filesystem_test.go +++ b/ignition/resource_ignition_filesystem_test.go @@ -20,7 +20,8 @@ func TestIgnitionFilesystem(t *testing.T) { wipe_filesystem = true label = "root" uuid = "qux" - options = ["rw"] + options = ["-L", "test"] + mount_options = ["noexec"] } data "ignition_config" "test" { filesystems = [ @@ -64,10 +65,14 @@ func TestIgnitionFilesystem(t *testing.T) { return fmt.Errorf("wipe_filesystem, found %t", *f.WipeFilesystem) } - if len(f.Options) != 1 || f.Options[0] != "rw" { + if len(f.Options) != 2 || f.Options[0] != "-L" || f.Options[1] != "test" { return fmt.Errorf("options, found %q", f.Options) } + if len(f.MountOptions) != 1 || f.MountOptions[0] != "noexec" { + return fmt.Errorf("mountOptions, found %q", f.MountOptions) + } + return nil }) } diff --git a/website/docs/d/filesystem.html.md b/website/docs/d/filesystem.html.md index cd7d18f6..360897e6 100644 --- a/website/docs/d/filesystem.html.md +++ b/website/docs/d/filesystem.html.md @@ -36,6 +36,8 @@ The following arguments are supported: * `options` - (Optional) Any additional options to be passed to the format-specific mkfs utility. +* `mount_options` - (Optional) Any special options to be passed to the mount command. + * `path` - (Optional) The mount-point of the filesystem while Ignition is running relative to where the root filesystem will be mounted. This is not necessarily the same as where it should be mounted in the real root, but it is encouraged to make it the same. ## Attributes Reference