@@ -45,13 +45,14 @@ func (s *CiliumIdentity) Lint(ctx context.Context) error {
4545 for o := it .Next (); o != nil ; o = it .Next () {
4646 cid := o .(* v2.CiliumIdentity )
4747 fqn := client .FQN (cid .Namespace , cid .Name )
48- s .InitOutcome (fqn )
49- ctx = internal .WithSpec (ctx , ilint .SpecFor (fqn , cid ))
48+ id := client .FQN (extractNS (cid ), cid .Name )
49+ s .InitOutcome (id )
50+ ctx = internal .WithSpec (ctx , ilint .SpecFor (id , cid ))
5051 if err := s .checkStale (ctx , fqn , & refs ); err != nil {
5152 return err
5253 }
5354 s .checkNS (ctx , cid )
54- if err := s .checkSA (ctx , fqn , cid ); err != nil {
55+ if err := s .checkSA (ctx , cid ); err != nil {
5556 return err
5657 }
5758 }
@@ -75,6 +76,17 @@ const (
7576 k8sSALabel = "io.cilium.k8s.policy.serviceaccount"
7677)
7778
79+ func extractNS (cid * v2.CiliumIdentity ) string {
80+ if ns , ok := cid .Labels [k8sNSLabel ]; ok {
81+ return ns
82+ }
83+ if ns , ok := cid .SecurityLabels [k8sSecNSLabel ]; ok {
84+ return ns
85+ }
86+
87+ return client .BlankNamespace
88+ }
89+
7890func (s * CiliumIdentity ) checkNS (ctx context.Context , cid * v2.CiliumIdentity ) {
7991 ns , ok := cid .Labels [k8sNSLabel ]
8092 if ! ok {
@@ -95,7 +107,7 @@ func (s *CiliumIdentity) checkNS(ctx context.Context, cid *v2.CiliumIdentity) {
95107 }
96108}
97109
98- func (s * CiliumIdentity ) checkSA (ctx context.Context , fqn string , cid * v2.CiliumIdentity ) error {
110+ func (s * CiliumIdentity ) checkSA (ctx context.Context , cid * v2.CiliumIdentity ) error {
99111 ns , ok := cid .Labels [k8sNSLabel ]
100112 if ! ok {
101113 return fmt .Errorf ("unable to locate cid namespace" )
0 commit comments