minitrino.cmd.snapshot module#

Snapshot command for Minitrino CLI.

Provides functionality to create, validate, and manage snapshots of Minitrino environments, including modules and configuration files.

minitrino.cmd.snapshot.validate_name(name: str) None[source][source]#

Validate the chosen filename for correct input.

Parameters:

name (str) – The filename to validate.

Raises:

UserError – If the filename contains illegal characters.

minitrino.cmd.snapshot.check_exists(ctx: MinitrinoContext, name: str, directory: str, force: bool) None[source][source]#

Check if the snapshot tarball exists and handle overwrite logic.

Parameters:
  • name (str) – Name of the snapshot file.

  • directory (str) – Directory containing the snapshot file.

  • force (bool) – If True, overwrite without prompting.

minitrino.cmd.snapshot.create_temp_snapshot_dir(name: str, no_scrub: bool, modules: list[str]) str[source][source]#

Create and populate a temporary directory for snapshot staging.

Parameters:
  • name (str) – Name of the snapshot.

  • no_scrub (bool) – If True, do not scrub sensitive data from config.

  • modules (list of str) – List of modules to include in the snapshot.

Returns:

Absolute path of the named snapshot directory.

Return type:

str

minitrino.cmd.snapshot.write_provision_script(ctx: MinitrinoContext, temp_snapshot_dir: str, modules: list[str] | None = None) None[source][source]#

Write the provisioning shell script for restoring the snapshot.

Parameters:
  • temp_snapshot_dir (str) – Directory where the shell script will be created.

  • modules (list of str, optional) – List of modules to include in the command.

minitrino.cmd.snapshot.build_command_string(modules: list[str] | None = None) str[source][source]#

Build the shell command for provisioning from the snapshot.

Parameters:

modules (list of str, optional) – List of modules to include in the command.

Returns:

The constructed command string.

Return type:

str

minitrino.cmd.snapshot.copy_core_lib_structure(ctx: MinitrinoContext, temp_snapshot_dir: str, name: str) None[source][source]#

Copy core Minitrino library files and structure to the snapshot dir.

Parameters:
  • temp_snapshot_dir (str) – Directory where the snapshot will be created.

  • name (str) – Name of the snapshot.

minitrino.cmd.snapshot.copy_user_config(ctx: MinitrinoContext, temp_snapshot_dir: str, no_scrub: bool) None[source][source]#

Copy user config, optionally scrub sensitive data.

Parameters:
  • temp_snapshot_dir (str) – Directory where the config file will be copied.

  • no_scrub (bool) – If True, do not scrub sensitive data from config.

minitrino.cmd.snapshot.copy_and_scrub_user_config(ctx: MinitrinoContext, temp_snapshot_dir: str, no_scrub: bool = False) None[source][source]#

Copy the user config file and scrub sensitive data if requested.

Parameters:
  • temp_snapshot_dir (str) – Directory where the config file will be copied.

  • no_scrub (bool, optional) – If True, do not scrub sensitive data from config.

minitrino.cmd.snapshot.scrub_user_config(ctx: MinitrinoContext, temp_snapshot_dir: str) None[source][source]#

Scrub sensitive data from the user config file.

Parameters:

temp_snapshot_dir (str) – Directory containing the config file to scrub.

minitrino.cmd.snapshot.scrub_line(ctx: MinitrinoContext, line: str) str[source][source]#

Scrub a single line of config if it contains a sensitive key.

Parameters:

line (str) – The line to scrub.

Returns:

The scrubbed line.

Return type:

str

minitrino.cmd.snapshot.copy_module_dirs(ctx: MinitrinoContext, temp_snapshot_dir: str, modules: list[str] | None = None) None[source][source]#

Copy specified module directories into the snapshot directory.

Parameters:
  • temp_snapshot_dir (str) – Directory where modules will be copied.

  • modules (list of str, optional) – List of modules to copy.

minitrino.cmd.snapshot.create_snapshot_tarball(name: str, temp_snapshot_dir: str, save_dir: str) None[source][source]#

Create a tarball archive of the snapshot directory.

Parameters:
  • name (str) – Name of the snapshot.

  • temp_snapshot_dir (str) – Directory to archive.

  • save_dir (str) – Directory to save the tarball.

minitrino.cmd.snapshot.move_snapshot_to_destination(name: str, temp_snapshot_dir: str, directory: str) None[source][source]#

Move resources to the user-specified directory.

Parameters:
  • name (str) – Name of the snapshot.

  • temp_snapshot_dir (str) – Directory to move.

  • directory (str) – Directory to save the tarball.

minitrino.cmd.snapshot.snapshot_runner(name: str, no_scrub: bool, modules: list[str] | None = None, directory: str = '') None[source][source]#

Orchestrate the full snapshot creation and output process.

Parameters:
  • name (str) – Name of the snapshot.

  • no_scrub (bool) – If True, do not scrub sensitive data from config.

  • modules (list[str], optional) – List of modules to snapshot.

  • directory (str, optional) – Directory to save the snapshot tarball.

minitrino.cmd.snapshot.check_complete(name: str, directory: str)[source][source]#

Check if the snapshot tarball was created successfully.

Parameters:
  • name (str) – Name of the snapshot.

  • directory (str) – Directory containing the snapshot file.

Raises:

MinitrinoError – If the snapshot tarball was not written.