providers: move `get_instance_name()` to providers.py
Metadata
Current evaluation
Merged. Moved get_instance_name() to snapcraft/providers/providers.py, removing snapcraft-specific logic from provider modules. This refactoring prepares the codebase for the new craft-providers API. Approved by reviewers and passed all CI checks.
Suggested action: —
No scores available.
Issue body
- [X] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [X] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [X] Have you successfully run `make lint`?
- [X] Have you successfully run `pytest tests/unit`?
-----
`get_instance_name()` is a snapcraft-specific call, so it is moved out of the craft-providers interface. See [this PR](https://github.com/canonical/rockcraft/pull/74) in rockcraft for reference.
This is the first out of a series of PRs to prepare for the new `craft-providers` API. The goals are simple:
1. `_provider.py`, `_lxd.py`, and `_multipass.py` contain no snapcraft-specific code
2. All snapcraft-specific code related to `craft-providers` is moved into `snapcraft/providers/providers.py`
This preparation is complete in `rockcraft`. The new interface will be migrated from `rockcraft` to `craft-providers` in the coming week.
(CRAFT-1305)
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged. Moved get_instance_name() to snapcraft/providers/providers.py, removing snapcraft-specific logic from provider modules. This refactoring prepares the codebase for the new craft-providers API. Approved by reviewers and passed all CI checks. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Relocated get_instance_name() to snapcraft/providers/providers.py, removing snapcraft-specific logic from provider modules. This refactoring prepares the codebase for the new craft-providers API and aligns with rockcraft changes. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged moving get_instance_name() from craft-providers to snapcraft/providers/providers.py. This isolates snapcraft-specific code for the new craft-providers API, mirroring prior rockcraft updates. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #74 providers: move get_instance_name() to providers.py | rockcraft | merged | Merged after approval and passing CI. Moved the rockcraft-specific get_instance_name() function to providers.py, changing 8 files. Resolves CRAFT-1350. | |
| #898 providers: move `get_provider()` to providers.py | charmcraft | merged | Merged after approval. Moved the get_provider() function to providers.py as part of CRAFT-1410. The refactoring touched 10 files, adding 178 lines and removing 226, and was previously blocked by PR 896. | |
| #885 (internal) Moved get_instance_name functionality to providers helper (CRAFT-1304). | charmcraft | merged | Merged refactoring moving get_instance_name to a providers helper, resolving CRAFT-1304. Approved by one reviewer with no unresolved comments, spanning eight files with a net reduction of 49 lines. | |
| #92 providers: refactor get_provider() | rockcraft | merged | Merged after approval and passing CI. Refactored and moved get_provider() from _get_provider.py to providers.py across seven files, reducing code by 25 lines. Resolves CRAFT-1375. | |
| #80 providers: move `get_instance_name()` call to lifecycle.py | rockcraft | merged | Merged. Moved the rockcraft-specific get_instance_name() call from provider classes to lifecycle.py to separate application-specific logic. Approved by reviewer, CI passed, spanning 6 files with 57 additions and 34 deletions. | |
| #3935 providers: refactor `capture_logs_from_instance()` | snapcraft | merged | Merged into main following approval and passing CI. Refactored capture_logs_from_instance() to use craft-providers temporarily_pull_file() and moved it to providers.py, trimming 28 lines and increasing coverage by 0.09%. | |
| #3940 providers: move `get_provider()` to providers.py | snapcraft | merged | Merged the refactoring that moves get_provider() to providers.py. Aligned with rockcraft, the change passed code review and CI checks, modified 7 files, and was successfully integrated into main. | |
| #3927 providers: move `get_command_environment()` to providers.py | snapcraft | merged | Merged pull request moving the snapcraft-specific get_command_environment() function out of the craft-providers interface and into providers.py. Approved, passed CI checks, and achieved 100% coverage. | |
| #81 providers: move base configuration logic to providers.py | rockcraft | merged | Merged refactoring that moves base configuration logic to providers.py. The logic is now encapsulated in a single function called by lifecycle.py instead of individual provider classes, resolving CRAFT-1380. Approved and passed CI. | |
| #3938 providers: move `confirm_with_user()` call to providers.py (#91) | snapcraft | merged | Merged changes moving the snapcraft-specific confirm_with_user() call out of the craft-providers interface into providers.py. The update was approved, passed CI, and aligns with parallel rockcraft modifications. |