Skip to content

Commit c840a71

Browse files
committed
fix: fix creating bridged network interface
Signed-off-by: Dharsan <[email protected]>
1 parent 02c4637 commit c840a71

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

cmd/limactl/network.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,23 +174,23 @@ func networkCreateAction(cmd *cobra.Command, args []string) error {
174174
return err
175175
}
176176

177-
switch mode {
178-
case networks.ModeBridged:
177+
if mode == networks.ModeBridged {
179178
if gateway != "" {
180179
return fmt.Errorf("network mode %q does not support specifying gateway", mode)
181180
}
182181
if intf == "" {
183182
return fmt.Errorf("network mode %q requires specifying interface", mode)
184183
}
185-
default:
186-
if gateway == "" {
187-
return fmt.Errorf("network mode %q requires specifying gateway", mode)
188-
}
189-
if intf != "" {
190-
return fmt.Errorf("network mode %q does not support specifying interface", mode)
191-
}
184+
yq := fmt.Sprintf(`.networks.%q = {"mode":%q,"interface":%q}`, name, mode, intf)
185+
return networkApplyYQ(yq)
192186
}
193187

188+
if gateway == "" {
189+
return fmt.Errorf("network mode %q requires specifying gateway", mode)
190+
}
191+
if intf != "" {
192+
return fmt.Errorf("network mode %q does not support specifying interface", mode)
193+
}
194194
if !strings.Contains(gateway, "/") {
195195
gateway += "/24"
196196
}
@@ -208,7 +208,6 @@ func networkCreateAction(cmd *cobra.Command, args []string) error {
208208
// TODO: check IP range collision
209209

210210
yq := fmt.Sprintf(`.networks.%q = {"mode":%q,"gateway":%q,"netmask":%q,"interface":%q}`, name, mode, gwIP.String(), gwMaskStr, intf)
211-
212211
return networkApplyYQ(yq)
213212
}
214213

0 commit comments

Comments
 (0)