github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/nodeagent/firewall/centos/interfaces.go (about) 1 package centos 2 3 import ( 4 "fmt" 5 6 "github.com/caos/orbos/internal/operator/common" 7 ) 8 9 func getEnsureAndRemoveInterfaces(zoneName string, current *common.ZoneDesc, desired common.Firewall) ([]string, []string) { 10 11 ensureIfaces := make([]string, 0) 12 removeIfaces := make([]string, 0) 13 zone := desired.Zones[zoneName] 14 15 if zone.Interfaces != nil && len(zone.Interfaces) > 0 { 16 for _, iface := range zone.Interfaces { 17 foundIface := false 18 if current.Interfaces != nil && len(current.Interfaces) > 0 { 19 for _, currentIface := range current.Interfaces { 20 if currentIface == iface { 21 foundIface = true 22 } 23 } 24 } 25 if !foundIface { 26 ensureIfaces = append(ensureIfaces, fmt.Sprintf("--change-interface=%s", iface)) 27 } 28 } 29 } 30 if current.Interfaces != nil && len(current.Interfaces) > 0 { 31 for _, currentIface := range current.Interfaces { 32 foundIface := false 33 if zone.Interfaces != nil && len(zone.Interfaces) > 0 { 34 for _, iface := range zone.Interfaces { 35 if iface == currentIface { 36 foundIface = true 37 } 38 } 39 } 40 if !foundIface { 41 removeIfaces = append(removeIfaces, fmt.Sprintf("--remove-interface=%s", currentIface)) 42 } 43 } 44 } 45 46 return ensureIfaces, removeIfaces 47 }