-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client-go: Move custom <resource> struct methods to <resource>_expansion files #11928
client-go: Move custom <resource> struct methods to <resource>_expansion files #11928
Conversation
Skipping CI for Draft Pull Request. |
/test all |
87c688c
to
a8a2b4f
Compare
/test all |
Our `vm` struct embed generated `VirtualMachineInterface`. The latter defines the custom methods but does not implement them, which are defined in the `vm`. We can move the expanded methods implementations in the `virtualmachine_expansion` file so that our `vm` can simply inherit them. Also, switched using full `AbsPath` with fmt.Sprintf() to request composition with `Namespace()`, `Resource()`, `Name()` and `SubResource()`. N.B. the `PortForward` method implementation remains in our `vm` struct because we cannot still implement it in the expansion file, due to the lack of the clientConfig. Signed-off-by: fossedihelm <ffossemo@redhat.com>
a8a2b4f
to
4a6304d
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: acardace The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@vasiliy-ul Can you have a look? Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just one small issue.
...-go/generated/kubevirt/clientset/versioned/typed/core/v1/virtualmachineinstance_expansion.go
Outdated
Show resolved
Hide resolved
Our `vmi` struct embed generated `VirtualMachineInstanceInterface`. The latter defines the custom methods but does not implement them, which are defined in the `vm`. We can move the expanded methods implementations in the `virtualmachineinstance_expansion` file so that our `vmi` can simply inherit them. Also, switched using full `AbsPath` with fmt.Sprintf() to request composition with `Namespace()`, `Resource()`, `Name()` and `SubResource()`. N.B. the methods that return StreamInterface remain in our `vmi` struct because we cannot still implement it in the expansion file, due to the lack of the clientConfig. Signed-off-by: fossedihelm <ffossemo@redhat.com>
Our `kv` struct embed generated `KubeVirtInterface`. The latter defines the custom methods but does not implement them, which are defined in the `kv`. We can move the expanded methods implementations in the `kubevirt_expansion` file so that our `kv` can simply inherit them. Signed-off-by: fossedihelm <ffossemo@redhat.com>
Our `vmirs` struct embed generated `VirtualMachineInstanceResplicasetInterface`. The latter defines the custom methods but does not implement them, which are defined in the `vmirs`. We can move the expanded methods implementations in the `vmirs_expansion` file so that our `vmirs` can simply inherit them. Signed-off-by: fossedihelm <ffossemo@redhat.com>
4a6304d
to
d9ab0c6
Compare
Required labels detected, running phase 2 presubmits: |
What this PR does
Before this PR:
Our
vm
,vmi
,kv
,vmirs
structs respectively embed generatedVirtualMachineInterface
,VirtualMachineInstanceInterface
,KubeVirtInterface
andVirtualMachineInstanceResplicasetInterface
.The latter define the custom methods but do not
implement them, which are only defined in the custom structs.
After this PR:
We can move the expanded methods implementations
in the
virtualmachine_expansion
,virtualmachineinstance_expansion
,kubevirt_expansion
,virtualmachineinstancereplicaset_expansion
files so that our custom structscan simply inherit them.
Also, switched to using full
AbsPath
with fmt.Sprintf()to request composition with
Namespace()
,Resource()
,Name()
andSubResource()
.Special notes for your reviewer
N.B. methods that require clientConfig, like
PortForward
, remain implemented onlyin our custom structs because we still cannot implement them in the
expansion files, due to the lack of the clientConfig.
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note