Skip to content
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

Merged
merged 4 commits into from
May 22, 2024

Conversation

fossedihelm
Copy link
Contributor

@fossedihelm fossedihelm commented May 16, 2024

What this PR does

Before this PR:

Our vm, vmi, kv, vmirs structs respectively embed generated
VirtualMachineInterface, VirtualMachineInstanceInterface,
KubeVirtInterface and VirtualMachineInstanceResplicasetInterface.
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 structs
can simply inherit them.

Also, switched to using full AbsPath with fmt.Sprintf()
to request composition with Namespace(), Resource(),
Name() and SubResource().

Special notes for your reviewer

N.B. methods that require clientConfig, like PortForward, remain implemented only
in 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

NONE

@kubevirt-bot kubevirt-bot added the release-note-none Denotes a PR that doesn't merit a release note. label May 16, 2024
@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XL labels May 16, 2024
@fossedihelm
Copy link
Contributor Author

/test all

@kubevirt-bot kubevirt-bot added the sig/buildsystem Denotes an issue or PR that relates to changes in the build system. label May 16, 2024
@fossedihelm
Copy link
Contributor Author

/test all

@fossedihelm fossedihelm marked this pull request as ready for review May 20, 2024 08:34
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 20, 2024
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>
@acardace
Copy link
Member

/approve

@kubevirt-bot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 22, 2024
@fossedihelm
Copy link
Contributor Author

@vasiliy-ul Can you have a look? Thanks

Copy link
Contributor

@vasiliy-ul vasiliy-ul left a 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.

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>
@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label May 22, 2024
@kubevirt-commenter-bot
Copy link

Required labels detected, running phase 2 presubmits:
/test pull-kubevirt-e2e-windows2016
/test pull-kubevirt-e2e-kind-sriov
/test pull-kubevirt-e2e-k8s-1.30-ipv6-sig-network
/test pull-kubevirt-e2e-k8s-1.28-sig-network
/test pull-kubevirt-e2e-k8s-1.28-sig-storage
/test pull-kubevirt-e2e-k8s-1.28-sig-compute
/test pull-kubevirt-e2e-k8s-1.28-sig-operator
/test pull-kubevirt-e2e-k8s-1.29-sig-network
/test pull-kubevirt-e2e-k8s-1.29-sig-storage
/test pull-kubevirt-e2e-k8s-1.29-sig-compute
/test pull-kubevirt-e2e-k8s-1.29-sig-operator

@kubevirt-bot kubevirt-bot merged commit 05904ce into kubevirt:main May 22, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. sig/buildsystem Denotes an issue or PR that relates to changes in the build system. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants