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

Azure / aks-app-routing-operator / 16996039066

15 Aug 2025 05:54PM UTC coverage: 81.595% (+0.4%) from 81.213%
16996039066

push

github

OliverMKing
bump externaldns to 0.17.0

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

71 existing lines in 8 files now uncovered.

3795 of 4651 relevant lines covered (81.6%)

22.8 hits per line

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

89.13
/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
        managedCertificateCrdFilename = "approuting.kubernetes.azure.com_managedcertificates.yaml"
23
)
24

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

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

38
        log.Info("applying crds")
7✔
39
        for _, file := range files {
52✔
40
                if file.IsDir() {
45✔
UNCOV
41
                        continue
×
42
                }
43

44
                filename := file.Name()
45✔
45
                if !shouldLoadCRD(cfg, filename) {
57✔
46
                        continue
12✔
47
                }
48

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

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

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

70
        log.Info("crds loaded")
6✔
71
        return nil
6✔
72
}
73

74
func shouldLoadCRD(cfg *config.Config, filename string) bool {
53✔
75
        switch filename {
53✔
76
        case externalDnsCrdFilename:
8✔
77
                return cfg.EnableGateway
8✔
78
        case clusterExternalDnsCrdFilename:
8✔
79
                return cfg.EnableGateway
8✔
80
        case managedCertificateCrdFilename:
8✔
81
                return cfg.EnableManagedCertificates
8✔
82

83
        default:
29✔
84
                return true
29✔
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