-
Notifications
You must be signed in to change notification settings - Fork 478
/
disabled_namespacewide_checker.go
52 lines (42 loc) · 1.55 KB
/
disabled_namespacewide_checker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package peerauthentications
import (
networking_v1 "istio.io/client-go/pkg/apis/networking/v1"
security_v1 "istio.io/client-go/pkg/apis/security/v1"
"github.com/kiali/kiali/kubernetes"
"github.com/kiali/kiali/models"
)
type DisabledNamespaceWideChecker struct {
PeerAuthn *security_v1.PeerAuthentication
DestinationRules []*networking_v1.DestinationRule
}
func (c DisabledNamespaceWideChecker) Check() ([]*models.IstioCheck, bool) {
validations := make([]*models.IstioCheck, 0)
// Validation only affects to PeerAuthn disabling mTLS
if _, mode := kubernetes.PeerAuthnHasMTLSEnabled(c.PeerAuthn); mode != "DISABLE" {
return validations, true
}
nsDisableDRFound := false
meshEnabledDRFound := false
for _, dr := range c.DestinationRules {
// If ns-wide Destination Rule enabling mtls found, error found
_, mode := kubernetes.DestinationRuleHasNamespaceWideMTLSEnabled(c.PeerAuthn.Namespace, dr)
if mode == "ISTIO_MUTUAL" || mode == "MUTUAL" {
check := models.Build("peerauthentications.mtls.disabledestinationrulemissing", "spec/mtls")
return append(validations, &check), false
} else if mode == "DISABLE" {
nsDisableDRFound = true
break
}
if _, mode := kubernetes.DestinationRuleHasMeshWideMTLSEnabled(dr); mode == "ISTIO_MUTUAL" || mode == "MUTUAL" {
meshEnabledDRFound = true
}
}
if nsDisableDRFound {
return validations, true
}
if meshEnabledDRFound {
check := models.Build("peerauthentications.mtls.disabledestinationrulemissing", "spec/mtls")
return append(validations, &check), false
}
return validations, true
}