craft_providers.bases.instance_config module
Persistent instance config / datastore resident in provided environment.
- class craft_providers.bases.instance_config.InstanceConfiguration(**data)[source]
Bases:
pydantic.main.BaseModel
Instance configuration datastore.
- Parameters
compatibility_tag – Compatibility tag for instance.
snaps –
dictionary of snaps and their revisions, e.g. snaps:
- snapcraft:
revision: “x100”
- charmcraft:
revision: 834
data (
Any
) –
- compatibility_tag: Optional[str]
- classmethod load(executor, config_path=PosixPath('/etc/craft-instance.conf'))[source]
Load an instance config file from an environment.
- Parameters
executor (
Executor
) – Executor for instance.config_path (
Path
) – Path to configuration file. Default is /etc/craft-instance.conf.
- Return type
Optional
[InstanceConfiguration
]- Returns
The InstanceConfiguration object or None, if the config does not exist or is empty.
- Raises
BaseConfigurationError – If the file cannot be loaded from the environment.
- marshal()[source]
Create a dictionary containing the InstanceConfiguration data.
- Return type
Dict
[str
,Any
]- Returns
The newly created dictionary.
- save(executor, config_path=PosixPath('/etc/craft-instance.conf'))[source]
Save an instance config file to an environment.
- Parameters
executor (
Executor
) – Executor for instance.config_path (
Path
) – Path to configuration file. Default is /etc/craft-instance.conf.
- Return type
None
- snaps: Optional[Dict[str, Dict[str, Any]]]
- classmethod unmarshal(data)[source]
Create and populate a new InstanceConfig object from dictionary data.
The unmarshal method validates the data in the dictionary and populates the corresponding fields in the InstanceConfig object.
- Parameters
data (
Dict
[str
,Any
]) – The dictionary data to unmarshal.- Return type
- Returns
The newly created InstanceConfiguration object.
- Raises
BaseConfigurationError – If validation fails.
- classmethod update(executor, data, config_path=PosixPath('/etc/craft-instance.conf'))[source]
Update an instance config file in an environment.
New values are added and existing values are updated. No data are removed. If there is no existing config to update, then a new config is created.
- Parameters
executor (
Executor
) – Executor for instance.data (
Dict
[str
,Any
]) – The dictionary to update instance with.config_path (
Path
) –
- Return type
- Returns
The updated InstanceConfiguration object.
- craft_providers.bases.instance_config.update_nested_dictionaries(config_data, new_data)[source]
Recursively update a dictionary containing nested dictionaries.
New values are added and existing values are updated. No data are removed.
- Parameters
config_data (
Dict
[str
,Any
]) – dictionary of config data to update.new_data (
Dict
[str
,Any
]) – data to update config_data with.
- Return type
Dict
[str
,Any
]