cluster-api-provider-openstack
cluster-api-provider-openstack copied to clipboard
Envtest mocks
What this PR does / why we need it:
The purpose of this PR is to be able to run envtests using mock clients instead of real ones. This PR achieves that by enhancing Scope to return service clients. We add a new scope Factory interface to generate Scopes. We provide 2 implementations of Factory:
ProviderScopeFactory generates 'real' Scopes which expect to be able to make API calls to a running OpenStack cloud. MockScopeFactory uses mock clients.
Because Scopes now return clients, the scope package must import those clients. However, clients are currently in their service packages. Services use scopes and must therefore import the scope package. This is a circular dependency. To avoid this we move clients into a separate package.
With the exception of the new factory interface, all other changes are mechanical. This PR does not intentionally introduce any functional changes.
Because of the large amount of code churn I have split the change into multiple commits. These commits each make a single refactor. I suggest that this PR will be simpler to review by commit, as the mechanical code churn in each individual commit is very similar.
/hold
Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
Name | Link |
---|---|
Latest commit | bd1aabe56594e9a6679ced35aacbbfb585df7235 |
Latest deploy log | https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/63d8e558a946bf0008ad0e5e |
Deploy Preview | https://deploy-preview-1236--kubernetes-sigs-cluster-api-openstack.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: mdbooth
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [mdbooth]
Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
@mdbooth: The /test
command needs one or more targets.
The following commands are available to trigger required jobs:
-
/test pull-cluster-api-provider-openstack-build
-
/test pull-cluster-api-provider-openstack-e2e-test
-
/test pull-cluster-api-provider-openstack-test
The following commands are available to trigger optional jobs:
-
/test pull-cluster-api-provider-openstack-conformance-test
Use /test all
to run the following jobs that were automatically triggered:
-
pull-cluster-api-provider-openstack-build
-
pull-cluster-api-provider-openstack-e2e-test
-
pull-cluster-api-provider-openstack-test
In response to this:
/test
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
/test all
/retest
/retest
Looks good to me! (adding lgtm after a rebase)
We discussed removing the clientOpts
and passing the region through the Scope
struct in #1178. At least now it is an implementation detail of the ProviderScopeFactory
.
/retest-required
/test pull-cluster-api-provider-openstack-e2e-test
/retest-required
fwict, the CI failures are due to infra issues (quotas), not the change itself
/retest-required
This should be finally good to review again.
Because of the large amount of code churn I have split the change into multiple commits. These commits each make a single refactor. I suggest that this PR will be simpler to review by commit, as the mechanical code churn in each individual commit is very similar.
Thank you! It was quite nice to review per commit! :slightly_smiling_face: This looks like a good improvement to me. /lgtm
Fixed merge conflict with #1451
/hold cancel