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

refactor: virtwrap: remove/improve some code #11548

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/virt-launcher/virtwrap/nichotplug.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,18 @@ func indexedDomainInterfaces(domain *api.Domain) map[string]api.Interface {
return domainInterfaces
}

type SetDomainFunc func(*v1.VirtualMachineInstance, *api.DomainSpec) (cli.VirDomain, error)
Copy link
Member

Choose a reason for hiding this comment

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

Does it need to be exposed?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, I'll change it


// withNetworkIfacesResources adds network interfaces as placeholders to the domain spec
// to trigger the addition of the dependent resources/devices (e.g. PCI controllers).
// As its last step, it reads the generated configuration and removes the network interfaces
// so none will be created with the domain creation.
// The dependent devices are left in the configuration, to allow future hotplug.
func withNetworkIfacesResources(vmi *v1.VirtualMachineInstance, domainSpec *api.DomainSpec, f func(v *v1.VirtualMachineInstance, s *api.DomainSpec) (cli.VirDomain, error)) (cli.VirDomain, error) {
func withNetworkIfacesResources(
vmi *v1.VirtualMachineInstance,
domainSpec *api.DomainSpec,
f SetDomainFunc,
) (cli.VirDomain, error) {
Comment on lines +182 to +186
Copy link
Member

Choose a reason for hiding this comment

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

The linter is configured to allow line lengths up to 140 [1]. Now that the function type is used, do we exceed it?

[1] https://github.com/kubevirt/kubevirt/blob/main/.golangci.yml#L50

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! We do have an agreed line length limit! That's great, I can point it out to people now! :)

To your question, I don't think we exceed after using function type but I'll double check and revert the change if it is still <= 140 chars per line. Thanks!

domainSpecWithIfacesResource := appendPlaceholderInterfacesToTheDomain(vmi, domainSpec)
dom, err := f(vmi, domainSpecWithIfacesResource)
if err != nil {
Expand Down