Skip to content

Commit faac929

Browse files
committed
System: Skip interface edits if no interface is given
1 parent a847e63 commit faac929

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

cmd/system.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
2323
deleteInterface := deleteInterfaceFlag != nil && deleteInterfaceFlag.Changed
2424
renameInterface := renameInterfaceFlag != nil && renameInterfaceFlag.Changed
2525
systemInterface, keyInMap := system.Interfaces[systemNewInterface]
26-
if !keyInMap {
27-
// Interface doesn't exist, so add a new one.
26+
if systemNewInterface != "" && !keyInMap {
27+
// Interface doesn't exist and non-empty string, so add a new one.
2828
// We cannot call CreateInterface because the system might not exist.
2929
system.Interfaces[systemNewInterface] = cobbler.Interface{}
3030
systemInterface = system.Interfaces[systemNewInterface]
@@ -521,7 +521,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
521521
}
522522
system.SerialBaudRate = systemNewSerialBaudRate
523523
case "bonding-opts":
524-
if renameInterface || deleteInterface {
524+
if renameInterface || deleteInterface || systemNewInterface == "" {
525525
return
526526
}
527527
var systemNewBondingOpts string
@@ -531,7 +531,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
531531
}
532532
systemInterface.BondingOpts = systemNewBondingOpts
533533
case "bridge-opts":
534-
if renameInterface || deleteInterface {
534+
if renameInterface || deleteInterface || systemNewInterface == "" {
535535
return
536536
}
537537
var systemNewBridgeOpts string
@@ -541,7 +541,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
541541
}
542542
systemInterface.BridgeOpts = systemNewBridgeOpts
543543
case "cnames":
544-
if renameInterface || deleteInterface {
544+
if renameInterface || deleteInterface || systemNewInterface == "" {
545545
return
546546
}
547547
var systemNewCNames []string
@@ -551,7 +551,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
551551
}
552552
systemInterface.CNAMEs = systemNewCNames
553553
case "connected-mode":
554-
if renameInterface || deleteInterface {
554+
if renameInterface || deleteInterface || systemNewInterface == "" {
555555
return
556556
}
557557
var systemNewConnectedMode bool
@@ -561,7 +561,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
561561
}
562562
systemInterface.ConnectedMode = systemNewConnectedMode
563563
case "dhcp-tag":
564-
if renameInterface || deleteInterface {
564+
if renameInterface || deleteInterface || systemNewInterface == "" {
565565
return
566566
}
567567
var systemNewDhcpTag string
@@ -571,7 +571,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
571571
}
572572
systemInterface.DHCPTag = systemNewDhcpTag
573573
case "dns-name":
574-
if renameInterface || deleteInterface {
574+
if renameInterface || deleteInterface || systemNewInterface == "" {
575575
return
576576
}
577577
var systemNewDnsName string
@@ -581,7 +581,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
581581
}
582582
systemInterface.DNSName = systemNewDnsName
583583
case "if-gateway":
584-
if renameInterface || deleteInterface {
584+
if renameInterface || deleteInterface || systemNewInterface == "" {
585585
return
586586
}
587587
var systemNewIfGateway string
@@ -591,7 +591,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
591591
}
592592
systemInterface.Gateway = systemNewIfGateway
593593
case "interface-master":
594-
if renameInterface || deleteInterface {
594+
if renameInterface || deleteInterface || systemNewInterface == "" {
595595
return
596596
}
597597
var systemNewInterfaceMaster string
@@ -601,7 +601,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
601601
}
602602
systemInterface.InterfaceMaster = systemNewInterfaceMaster
603603
case "interface-type":
604-
if renameInterface || deleteInterface {
604+
if renameInterface || deleteInterface || systemNewInterface == "" {
605605
return
606606
}
607607
var systemNewInterfaceType string
@@ -611,7 +611,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
611611
}
612612
systemInterface.InterfaceType = systemNewInterfaceType
613613
case "ip-address":
614-
if renameInterface || deleteInterface {
614+
if renameInterface || deleteInterface || systemNewInterface == "" {
615615
return
616616
}
617617
var systemNewIpAddress string
@@ -621,7 +621,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
621621
}
622622
systemInterface.IPAddress = systemNewIpAddress
623623
case "ipv6-address":
624-
if renameInterface || deleteInterface {
624+
if renameInterface || deleteInterface || systemNewInterface == "" {
625625
return
626626
}
627627
var systemNewIpv6Address string
@@ -631,7 +631,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
631631
}
632632
systemInterface.IPv6Address = systemNewIpv6Address
633633
case "ipv6-default-gateway":
634-
if renameInterface || deleteInterface {
634+
if renameInterface || deleteInterface || systemNewInterface == "" {
635635
return
636636
}
637637
var systemNewIpv6DefaultGateway string
@@ -641,7 +641,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
641641
}
642642
systemInterface.IPv6DefaultGateway = systemNewIpv6DefaultGateway
643643
case "ipv6-mtu":
644-
if renameInterface || deleteInterface {
644+
if renameInterface || deleteInterface || systemNewInterface == "" {
645645
return
646646
}
647647
var systemNewIpv6Mtu string
@@ -651,7 +651,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
651651
}
652652
systemInterface.IPv6MTU = systemNewIpv6Mtu
653653
case "ipv6-prefix":
654-
if renameInterface || deleteInterface {
654+
if renameInterface || deleteInterface || systemNewInterface == "" {
655655
return
656656
}
657657
var systemNewIpv6Prefix string
@@ -661,7 +661,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
661661
}
662662
systemInterface.IPv6Prefix = systemNewIpv6Prefix
663663
case "ipv6-secondaries":
664-
if renameInterface || deleteInterface {
664+
if renameInterface || deleteInterface || systemNewInterface == "" {
665665
return
666666
}
667667
var systemNewIpv6Secondaries []string
@@ -671,7 +671,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
671671
}
672672
systemInterface.IPv6Secondaries = systemNewIpv6Secondaries
673673
case "ipv6-static-routes":
674-
if renameInterface || deleteInterface {
674+
if renameInterface || deleteInterface || systemNewInterface == "" {
675675
return
676676
}
677677
var systemNewIpv6StaticRoutes []string
@@ -681,7 +681,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
681681
}
682682
systemInterface.IPv6StaticRoutes = systemNewIpv6StaticRoutes
683683
case "mac-address":
684-
if renameInterface || deleteInterface {
684+
if renameInterface || deleteInterface || systemNewInterface == "" {
685685
return
686686
}
687687
var systemNewMacAddress string
@@ -691,7 +691,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
691691
}
692692
systemInterface.MACAddress = systemNewMacAddress
693693
case "management":
694-
if renameInterface || deleteInterface {
694+
if renameInterface || deleteInterface || systemNewInterface == "" {
695695
return
696696
}
697697
var systemNewManagement bool
@@ -701,7 +701,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
701701
}
702702
systemInterface.Management = systemNewManagement
703703
case "mtu":
704-
if renameInterface || deleteInterface {
704+
if renameInterface || deleteInterface || systemNewInterface == "" {
705705
return
706706
}
707707
var systemNewMtu string
@@ -711,7 +711,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
711711
}
712712
systemInterface.MTU = systemNewMtu
713713
case "netmask":
714-
if renameInterface || deleteInterface {
714+
if renameInterface || deleteInterface || systemNewInterface == "" {
715715
return
716716
}
717717
var systemNewNetmask string
@@ -721,7 +721,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
721721
}
722722
systemInterface.Netmask = systemNewNetmask
723723
case "static":
724-
if renameInterface || deleteInterface {
724+
if renameInterface || deleteInterface || systemNewInterface == "" {
725725
return
726726
}
727727
var systemNewStatic bool
@@ -731,7 +731,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
731731
}
732732
systemInterface.Static = systemNewStatic
733733
case "static-routes":
734-
if renameInterface || deleteInterface {
734+
if renameInterface || deleteInterface || systemNewInterface == "" {
735735
return
736736
}
737737
var systemNewStaticRoutes []string
@@ -741,7 +741,7 @@ func updateSystemFromFlags(cmd *cobra.Command, system *cobbler.System) error {
741741
}
742742
systemInterface.StaticRoutes = systemNewStaticRoutes
743743
case "virt-bridge":
744-
if renameInterface || deleteInterface {
744+
if renameInterface || deleteInterface || systemNewInterface == "" {
745745
return
746746
}
747747
var systemNewVirtBridge string

0 commit comments

Comments
 (0)