-
Notifications
You must be signed in to change notification settings - Fork 228
Remove .spec.network.mode
; use a global --network-plugin
flag instead
#319
Conversation
0b76084
to
909d995
Compare
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.
Great changes!
Some nits, otherwise LGTM 👍
|
||
// Convert_v1alpha1_VMNetworkSpec_To_ignite_VMNetworkSpec calls the autogenerated conversion function and possibly custom conversion logic | ||
func Convert_v1alpha1_VMNetworkSpec_To_ignite_VMNetworkSpec(in *VMNetworkSpec, out *ignite.VMNetworkSpec, s conversion.Scope) error { | ||
// .Spec.Network.Mode has been removed in v1alpha2. However, we won't persist that information anywhere in the new API, so |
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.
.Spec.Network.Mode
-> .spec.network.mode
, the wording on this comment is also a bit funky. Just something like "The network mode is not tracked in the new API, so there's no extra conversion logic" would be enough.
@@ -174,3 +174,10 @@ func Convert_v1alpha1_VMKernelSpec_To_ignite_VMKernelSpec(in *VMKernelSpec, out | |||
|
|||
return Convert_v1alpha1_OCIClaim_To_ignite_OCI(&in.OCIClaim, &out.OCI) | |||
} | |||
|
|||
// Convert_v1alpha1_VMNetworkSpec_To_ignite_VMNetworkSpec calls the autogenerated conversion function and possibly custom conversion logic |
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.
Remove "possibly"
pkg/network/flag/networkflag.go
Outdated
} | ||
} | ||
if foundPlugin == nil { | ||
return fmt.Errorf("Invalid network mode %q, must be one of %v", val, plugins) |
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.
Invalid
-> invalid
pkg/network/flag/networkflag.go
Outdated
for _, plugin := range plugins { | ||
if plugin.String() == val { | ||
foundPlugin = &plugin | ||
break |
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.
Perform *nf.value = plugin
here and return instead of break?
pkg/network/flag/networkflag.go
Outdated
return fmt.Errorf("Invalid network mode %q, must be one of %v", val, plugins) | ||
} | ||
*nf.value = *foundPlugin | ||
return nil |
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.
If there's a return in the loop, you can just return fmt.Errorf("invalid network mode %q, must be one of %v", val, plugins)
here
pkg/network/flag/networkflag.go
Outdated
} | ||
|
||
func (nf *NetworkPluginFlag) Type() string { | ||
return "network-mode" |
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.
I would call this plugin
, so the flag would be --network-plugin plugin
instead of --network-plugin network-mode
pkg/network/flag/networkflag.go
Outdated
var _ pflag.Value = &NetworkPluginFlag{} | ||
|
||
func NetworkPluginVar(fs *pflag.FlagSet, ptr *network.PluginName) { | ||
fs.Var(&NetworkPluginFlag{value: ptr}, "network-plugin", fmt.Sprintf("Networking mode to use. Available options are: %v", plugins)) |
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.
"Network plugin to use..."
pkg/operations/remove.go
Outdated
networkPlugin := providers.NetworkPlugins[vm.Spec.Network.Mode.String()] | ||
log.Debugf("Removing the container with ID %q from the %s network", networkPlugin.Name(), containerID) | ||
return networkPlugin.RemoveContainerNetwork(containerID) | ||
log.Debugf("Removing the container with ID %q from the %s network", providers.NetworkPlugin.Name(), containerID) |
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.
%s network
-> %q network
for consistency
909d995
to
fb0114d
Compare
|
||
// Convert_v1alpha1_VMNetworkSpec_To_ignite_VMNetworkSpec calls the autogenerated conversion function and custom conversion logic | ||
func Convert_v1alpha1_VMNetworkSpec_To_ignite_VMNetworkSpec(in *VMNetworkSpec, out *ignite.VMNetworkSpec, s conversion.Scope) error { | ||
// .Spec.Network.Mode is not tracked in the v1alpha2 and newer, so there's no extra conversion logic |
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.
".spec.network.mode is not tracked in v1alpha2 and newer, so there's no extra conversion logic"
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.
.Spec.Network.Mode
is exactly as valid, even more IMO. .spec.network.mode
is the JSON path
Review comments addressed, merging... |
.spec.network.mode
; use a global --network-plugin
flag instead
Fixes: #310
cc @twelho