Skip to content

Basic interfaces for the deployers and the scaffolding of the factory.#7

Open
richackard wants to merge 1 commit into
kubernetes-sigs:mainfrom
richackard:dev
Open

Basic interfaces for the deployers and the scaffolding of the factory.#7
richackard wants to merge 1 commit into
kubernetes-sigs:mainfrom
richackard:dev

Conversation

@richackard

Copy link
Copy Markdown

Note the dummies in the factory will be replaced with the real deployers in the coming PRs.

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: richackard
Once this PR has been reviewed and has the lgtm label, please assign janetkuo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested a review from janetkuo June 10, 2026 21:24
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @richackard!

It looks like this is your first PR to kubernetes-sigs/devops-bench 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/devops-bench has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 10, 2026
Comment thread deployers/factory.py Outdated
"""
# Imported lazily to keep this module decoupled from the concrete
# implementations, which may not be present yet during migration.
from deployers.gcp.gcp_deployer import GCPDeployer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we plan on migrating the GCPDeployer? I assumed this might be a good time to drop it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh if we want to just stick with tf I am totally fine with it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new deployers package with a common Deployer interface and a get_deployer() factory, plus initial unit tests and test dependencies to validate deployer selection/precedence behavior while concrete deployers are still being migrated.

Changes:

  • Added deployers.base.Deployer ABC and deployers.factory.get_deployer() selection logic.
  • Added pytest-based tests that stub out (future) concrete deployer modules via sys.modules.
  • Added a test optional dependency group and pytest configuration; updated uv.lock accordingly.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
deployers/base.py Defines the abstract deployer interface used by the factory and future implementations.
deployers/factory.py Adds deployer-selection logic (env/config precedence, stack defaulting, resolver choice).
deployers/__init__.py Marks deployers as a Python package.
tests/test_factory.py Adds tests for factory behavior using module stubs/test doubles.
tests/__init__.py Marks tests as a package (supports import patterns used in the suite).
pyproject.toml Adds test extras + pytest configuration.
uv.lock Locks new test dependencies (pytest-mock) and metadata for extras.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread deployers/factory.py
Comment on lines +22 to +26
infra_config: dict[str, Any],
global_project_id: str,
global_cluster_name: str,
global_location: str = None,
) -> Deployer:
Comment thread deployers/factory.py
Comment on lines +36 to +46
# Imported lazily to keep this module decoupled from the concrete
# implementations, which may not be present yet during migration.
from deployers.gcp.gcp_deployer import GCPDeployer
from deployers.gcp.variables import resolve_variables as resolve_gcp_vars
from deployers.kind.variables import resolve_variables as resolve_kind_vars
from deployers.tf.tf_deployer import TFDeployer

provider_resolvers = {
"gcp": resolve_gcp_vars,
"kind": resolve_kind_vars,
}
Comment thread tests/test_factory.py
Comment on lines +90 to +95
def install(module_path, **attrs):
module = types.ModuleType(module_path)
for name, value in attrs.items():
setattr(module, name, value)
monkeypatch.setitem(sys.modules, module_path, module)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address this comment as well

Comment thread pyproject.toml
Comment thread pyproject.toml
@janetkuo

Copy link
Copy Markdown
Member

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jun 12, 2026
Note the dummies in the factory will be replaced with the real deployers in the coming PRs.
"kind": resolve_kind_vars,
}

# Respect task-level deployer first, fallback to cloud_provider if it is a valid deployer, otherwise default to terraform

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove references to terraform

"""
Factory to instantiate the appropriate infrastructure deployer.

Enforces GCP_LOCATION as the standard environment variable for location.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CLOUD_LOCATION instead of GCP_LOCATION


return TFDeployer(tf_dir=stack, variables=variables)

# Fallback to legacy GCPDeployer (kubetest2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is a bit confusing/misleading. It's newly introduced here, so shouldn't be called "legacy". Also, when users specify deployer_type as gcp, it's not a fallback, but the explicitly requested behavior.

@janetkuo

Copy link
Copy Markdown
Member

@richackard would you also take a look at Copilot review comments and resolve them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants