• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Azure / aks-app-routing-operator / 13729247518

07 Mar 2025 09:02PM UTC coverage: 82.098%. Remained the same
13729247518

push

github

jaiveerk
merged controllerutils changes

0 of 1 new or added line in 1 file covered. (0.0%)

3499 of 4262 relevant lines covered (82.1%)

19.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pkg/controller/controllerutils/serviceaccount.go
1
package controllerutils
2

3
import (
4
        "context"
5
        "errors"
6
        "fmt"
7

8
        corev1 "k8s.io/api/core/v1"
9
        "k8s.io/apimachinery/pkg/types"
10
        "sigs.k8s.io/controller-runtime/pkg/client"
11
)
12

13
const wiSaClientIdAnnotation = "azure.workload.identity/client-id"
14

15
func GetServiceAccountAndVerifyWorkloadIdentity(ctx context.Context, k8sclient client.Client, saName, saNamespace string) (string, error) {
×
16
        // ensure referenced serviceaccount exists
×
17
        saObj := &corev1.ServiceAccount{}
×
18
        err := k8sclient.Get(ctx, types.NamespacedName{Name: saName, Namespace: saNamespace}, saObj)
×
19

×
20
        if client.IgnoreNotFound(err) != nil {
×
21
                return "", fmt.Errorf("failed to fetch serviceaccount to verify workload identity configuration: %s", err)
×
22
        }
×
23

24
        // SA wasn't found, return appropriate error
25
        if err != nil {
×
26
                return "", NewUserError(err, fmt.Sprintf("serviceAccount %s does not exist", saName))
×
27
        }
×
28
        // check for required annotations
29
        if saObj.Annotations == nil || saObj.Annotations[wiSaClientIdAnnotation] == "" {
×
NEW
30
                return "", NewUserError(errors.New("user-specified service account does not contain WI annotation"), fmt.Sprintf("serviceAccount %s was specified but does not include necessary annotation for workload identity", saName))
×
31
        }
×
32

33
        return saObj.Annotations[wiSaClientIdAnnotation], nil
×
34
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc