Skip to content

Commit e08e97e

Browse files
committed
reduced output verbosity
1 parent 2c92609 commit e08e97e

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

tools/azure-npm-to-cilium-validator/azure-npm-to-cilium-validator.go

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"log"
88
"os"
9-
"strings"
109

1110
"github.com/olekukonko/tablewriter"
1211
corev1 "k8s.io/api/core/v1"
@@ -433,14 +432,10 @@ func addPoliciesWithEndportToTable(table *tablewriter.Table, ingressEndportNetwo
433432
} else {
434433
table.Append([]string{"NetworkPolicy with endPort", "❌", "Policies Affected:"})
435434
for _, policy := range ingressEndportNetworkPolicy {
436-
policyNamespace := strings.Split(policy, "/")[0]
437-
policyName := strings.Split(policy, "/")[1]
438-
table.Append([]string{"", "❌", fmt.Sprintf("Found NetworkPolicy: \033[31m%s\033[0m with Ingress endPort field in namespace: \033[31m%s\033[0m\n", policyName, policyNamespace)})
435+
table.Append([]string{"", "❌", fmt.Sprintf("\033[31m%s\033[0m with Ingress endPort field", policy)})
439436
}
440437
for _, policy := range egressEndportNetworkPolicy {
441-
policyNamespace := strings.Split(policy, "/")[0]
442-
policyName := strings.Split(policy, "/")[1]
443-
table.Append([]string{"", "❌", fmt.Sprintf("Found NetworkPolicy: \033[31m%s\033[0m\n with Egress endPort field in namespace: \033[31m%s\033[0m\n", policyName, policyNamespace)})
438+
table.Append([]string{"", "❌", fmt.Sprintf("\033[31m%s\033[0m with Egress endPort field", policy)})
444439
}
445440
}
446441
}
@@ -451,14 +446,10 @@ func addPoliciesWithCIDRToTable(table *tablewriter.Table, ingressPoliciesWithCID
451446
} else {
452447
table.Append([]string{"NetworkPolicy with CIDR", "❌", "Policies Affected:"})
453448
for _, policy := range ingressPoliciesWithCIDR {
454-
policyNamespace := strings.Split(policy, "/")[0]
455-
policyName := strings.Split(policy, "/")[1]
456-
table.Append([]string{"", "❌", fmt.Sprintf("Found NetworkPolicy: \033[31m%s\033[0m with Ingress CIDR field in namespace: \033[31m%s\033[0m\n", policyName, policyNamespace)})
449+
table.Append([]string{"", "❌", fmt.Sprintf("\033[31m%s\033[0m with Ingress CIDR field", policy)})
457450
}
458451
for _, policy := range egressPoliciesWithCIDR {
459-
policyNamespace := strings.Split(policy, "/")[0]
460-
policyName := strings.Split(policy, "/")[1]
461-
table.Append([]string{"", "❌", fmt.Sprintf("Found NetworkPolicy: \033[31m%s\033[0m with Egress CIDR field in namespace: \033[31m%s\033[0m\n", policyName, policyNamespace)})
452+
table.Append([]string{"", "❌", fmt.Sprintf("\033[31m%s\033[0m with Egress CIDR field\n", policy)})
462453
}
463454
}
464455
}
@@ -469,14 +460,10 @@ func addPoliciesWithNamedPortToTable(table *tablewriter.Table, ingressPoliciesWi
469460
} else {
470461
table.Append([]string{"NetworkPolicy with Named Port", "❌", "Policies Affected:"})
471462
for _, policy := range ingressPoliciesWithNamedPort {
472-
policyNamespace := strings.Split(policy, "/")[0]
473-
policyName := strings.Split(policy, "/")[1]
474-
table.Append([]string{"", "❌", fmt.Sprintf("Found NetworkPolicy: \033[31m%s\033[0m with Ingress Named Port field in namespace: \033[31m%s\033[0m\n", policyName, policyNamespace)})
463+
table.Append([]string{"", "❌", fmt.Sprintf("\033[31m%s\033[0m with Ingress Named Port field", policy)})
475464
}
476465
for _, policy := range egressPoliciesWithNamedPort {
477-
policyNamespace := strings.Split(policy, "/")[0]
478-
policyName := strings.Split(policy, "/")[1]
479-
table.Append([]string{"", "❌", fmt.Sprintf("Found NetworkPolicy: \033[31m%s\033[0m with Egress Named Port field in namespace: \033[31m%s\033[0m\n", policyName, policyNamespace)})
466+
table.Append([]string{"", "❌", fmt.Sprintf("\033[31m%s\033[0m with Egress Named Port field", policy)})
480467
}
481468
}
482469
}
@@ -487,9 +474,7 @@ func addEgressPoliciesToTable(table *tablewriter.Table, egressPolicies []string)
487474
} else {
488475
table.Append([]string{"NetworkPolicy with Egress (Not Allow All Egress)", "❌", "Policies Affected:"})
489476
for _, policy := range egressPolicies {
490-
policyNamespace := strings.Split(policy, "/")[0]
491-
policyName := strings.Split(policy, "/")[1]
492-
table.Append([]string{"", "❌", fmt.Sprintf("Found NetworkPolicy: \033[31m%s\033[0m with Egress field (Not Allow All) in namespace: \033[31m%s\033[0m\n", policyName, policyNamespace)})
477+
table.Append([]string{"", "❌", fmt.Sprintf("\033[31m%s\033[0m with Egress field (Not Allow All)", policy)})
493478
}
494479
}
495480
}
@@ -502,9 +487,7 @@ func addUnsafeServicesToTable(table *tablewriter.Table, unsafeServices []string)
502487
table.Append([]string{"Disruption for some Services with externalTrafficPolicy=Cluster", "❌", "Services Affected:"})
503488
// If there are any unsafe services then print them as they could be impacted by migration
504489
for _, service := range unsafeServices {
505-
serviceName := strings.Split(service, "/")[1]
506-
serviceNamespace := strings.Split(service, "/")[0]
507-
table.Append([]string{"", "❌", fmt.Sprintf("Found Service: \033[31m%s\033[0m in namespace: \033[31m%s\033[0m\n", serviceName, serviceNamespace)})
490+
table.Append([]string{"", "❌", fmt.Sprintf("\033[31m%s\033[0m with externalTrafficPolicy=Cluster", service)})
508491
}
509492
table.Append([]string{"", "", "Manual investigation is required to evaluate if ingress is allowed to the service's backend Pods."})
510493
table.Append([]string{"", "", "Please evaluate if these services would be impacted by migration."})

0 commit comments

Comments
 (0)