craft_parts.filesystem_mounts module

FilesystemMounts models.

class craft_parts.filesystem_mounts.FilesystemMount(root=PydanticUndefined, **data)[source]

Bases: RootModel

FilesystemMount defines the order in which devices should be mounted.

Parameters:

root (TypeVar(RootModelRootType))

classmethod first_maps_to_slash(value)[source]

Make sure the first item in the list maps the ‘/’ mount.

Parameters:

value (list[FilesystemMountItem])

Return type:

list[FilesystemMountItem]

marshal()[source]

Create a list containing the filesystem_mount data.

Return type:

list[dict[str, Any]]

Returns:

The newly created list.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

root: Annotated[list[FilesystemMountItem]]
classmethod unmarshal(data)[source]

Create and populate a new FilesystemMount object from list.

The unmarshal method validates entries in the input list, populating the corresponding fields in the data object.

Parameters:

data (list[dict[str, Any]]) – The list to unmarshal.

Return type:

FilesystemMount

Returns:

The newly created object.

Raises:
  • TypeError – If data is not a list.

  • pydantic.ValidationError – If the data fails validation.

class craft_parts.filesystem_mounts.FilesystemMountItem(**data)[source]

Bases: BaseModel

FilesystemMountItem maps a mountpoint to a device.

Parameters:

data (Any)

device: str
marshal()[source]

Create a dictionary containing the filesystem_mount item data.

Return type:

dict[str, Any]

Returns:

The newly created dictionary.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'populate_by_name': True, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

mount: str
classmethod unmarshal(data)[source]

Create and populate a new FilesystemMountItem object from dictionary data.

The unmarshal method validates entries in the input dictionary, populating the corresponding fields in the data object.

Parameters:

data (dict[str, Any]) – The dictionary data to unmarshal.

Return type:

FilesystemMountItem

Returns:

The newly created object.

Raises:

TypeError – If data is not a dictionary.

craft_parts.filesystem_mounts.validate_filesystem_mount(data)[source]

Validate a filesystem_mount.

Parameters:

data (list[dict[str, Any]]) – The filesystem mount data to validate.

Raises:

ValueError if the filesystem mount is not valid.

Return type:

None

craft_parts.filesystem_mounts.validate_filesystem_mounts(filesystem_mounts)[source]

Validate the filesystems section.

If filesystems are defined then both partition and overlay features must be enabled. A filesystem_mounts dict must only have a single “default” entry. The first entry in default must map the ‘/’ mount.

Raises:

FilesystemMountError if the filesystem mounts are not valid.

Parameters:

filesystem_mounts (dict[str, Any] | None)

Return type:

None