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

Azure / aks-app-routing-operator / 16504715713

24 Jul 2025 06:19PM UTC coverage: 81.722% (-0.05%) from 81.769%
16504715713

push

github

OliverMKing
cleanup managed cert crd code

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

3787 of 4634 relevant lines covered (81.72%)

22.02 hits per line

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

84.78
/pkg/controller/crd.go
1
package controller
2

3
import (
4
        "context"
5
        "errors"
6
        "fmt"
7
        "os"
8
        "path/filepath"
9

10
        "github.com/Azure/aks-app-routing-operator/pkg/config"
11
        "github.com/Azure/aks-app-routing-operator/pkg/util"
12
        "github.com/go-logr/logr"
13
        apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
14
        "sigs.k8s.io/controller-runtime/pkg/client"
15
        "sigs.k8s.io/yaml"
16
)
17

18
var (
19
        // should match the names in root config/crd/bases directory
20
        externalDnsCrdFilename        = "approuting.kubernetes.azure.com_externaldnses.yaml"
21
        clusterExternalDnsCrdFilename = "approuting.kubernetes.azure.com_clusterexternaldnses.yaml"
22
)
23

24
// loadCRDs loads the CRDs from the specified path into the cluster
25
func loadCRDs(c client.Client, cfg *config.Config, log logr.Logger) error {
7✔
26
        if cfg == nil {
8✔
27
                return errors.New("config cannot be nil")
1✔
28
        }
1✔
29

30
        log = log.WithValues("crdPath", cfg.CrdPath)
6✔
31
        log.Info("reading crd directory")
6✔
32
        files, err := os.ReadDir(cfg.CrdPath)
6✔
33
        if err != nil {
7✔
34
                return fmt.Errorf("reading crd directory %s: %w", cfg.CrdPath, err)
1✔
35
        }
1✔
36

37
        log.Info("applying crds")
5✔
38
        for _, file := range files {
38✔
39
                if file.IsDir() {
33✔
40
                        continue
×
41
                }
42

43
                filename := file.Name()
33✔
44
                if !shouldLoadCRD(cfg, filename) {
40✔
45
                        continue
7✔
46
                }
47

48
                path := filepath.Join(cfg.CrdPath, filename)
26✔
49
                log := log.WithValues("path", path)
26✔
50
                log.Info("reading crd file")
26✔
51
                var content []byte
26✔
52
                content, err := os.ReadFile(path)
26✔
53
                if err != nil {
26✔
54
                        return fmt.Errorf("reading crd file %s: %w", path, err)
×
55
                }
×
56

57
                log.Info("unmarshalling crd file")
26✔
58
                crd := &apiextensionsv1.CustomResourceDefinition{}
26✔
59
                if err := yaml.UnmarshalStrict(content, crd); err != nil {
27✔
60
                        return fmt.Errorf("unmarshalling crd file %s: %w", path, err)
1✔
61
                }
1✔
62

63
                log.Info("upserting crd")
25✔
64
                if err := util.Upsert(context.Background(), c, crd); err != nil {
25✔
65
                        return fmt.Errorf("upserting crd %s: %w", crd.Name, err)
×
66
                }
×
67
        }
68

69
        log.Info("crds loaded")
4✔
70
        return nil
4✔
71
}
72

73
func shouldLoadCRD(cfg *config.Config, filename string) bool {
39✔
74
        switch filename {
39✔
75
        // namespaced ExternalDNS CRD not used yet
76
        case externalDnsCrdFilename:
6✔
77
                return false
6✔
78
        case clusterExternalDnsCrdFilename:
6✔
79
                return cfg.EnabledWorkloadIdentity
6✔
NEW
80
        case externalDnsCrdFilename:
×
NEW
81
                return false
×
82

83
        default:
27✔
84
                return true
27✔
85
        }
86
}
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