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

kubeovn / kube-ovn / 20405539887

21 Dec 2025 05:53AM UTC coverage: 22.596% (-0.005%) from 22.601%
20405539887

push

github

web-flow
refactor: unify type constants (#6081)

Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>

7 of 67 new or added lines in 13 files covered. (10.45%)

7 existing lines in 5 files now uncovered.

12056 of 53354 relevant lines covered (22.6%)

0.26 hits per line

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

13.16
/pkg/controller/network_attachment.go
1
package controller
2

3
import (
4
        "context"
5
        "encoding/json"
6
        "time"
7

8
        nadv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
9
        "gopkg.in/k8snetworkplumbingwg/multus-cni.v4/pkg/logging"
10
        multustypes "gopkg.in/k8snetworkplumbingwg/multus-cni.v4/pkg/types"
11
        "k8s.io/client-go/tools/cache"
12
        "k8s.io/klog/v2"
13

14
        "github.com/kubeovn/kube-ovn/pkg/util"
15
)
16

17
func (c *Controller) isNetAttachCRDInstalled() (bool, error) {
×
NEW
18
        return apiResourceExists(
×
NEW
19
                c.config.AttachNetClient.Discovery(),
×
NEW
20
                nadv1.SchemeGroupVersion.String(),
×
NEW
21
                util.ObjectKind[*nadv1.NetworkAttachmentDefinition](),
×
NEW
22
        )
×
UNCOV
23
}
×
24

25
// the network-attachment-definition CRD is not required to be installed so
26
// periodically check and see if we should start the informer.
27
func (c *Controller) StartNetAttachInformerFactory(ctx context.Context) {
×
28
        ticker := time.NewTicker(10 * time.Second)
×
29
        go func() {
×
30
                defer ticker.Stop()
×
31
                for {
×
32
                        select {
×
33
                        case <-ticker.C:
×
34
                                exists, err := c.isNetAttachCRDInstalled()
×
35
                                if err != nil {
×
36
                                        klog.Errorf("checking network attachment CRD exists: %v", err)
×
37
                                        continue
×
38
                                }
39

40
                                if exists {
×
41
                                        klog.Info("Start attachment informer")
×
42

×
43
                                        c.netAttachInformerFactory.Start(ctx.Done())
×
44
                                        if !cache.WaitForCacheSync(ctx.Done(), c.netAttachSynced) {
×
45
                                                util.LogFatalAndExit(nil, "failed to wait for network attachment cache to sync")
×
46
                                        }
×
47

48
                                        return
×
49
                                }
50
                        case <-ctx.Done():
×
51
                                return
×
52
                        }
53
                }
54
        }()
55
}
56

57
func loadNetConf(bytes []byte) (*multustypes.DelegateNetConf, error) {
1✔
58
        delegateConf := &multustypes.DelegateNetConf{}
1✔
59
        if err := json.Unmarshal(bytes, &delegateConf.Conf); err != nil {
1✔
60
                return nil, logging.Errorf("LoadDelegateNetConf: error unmarshalling delegate config: %v", err)
×
61
        }
×
62

63
        if delegateConf.Conf.Type == "" {
1✔
64
                if err := multustypes.LoadDelegateNetConfList(bytes, delegateConf); err != nil {
×
65
                        return nil, logging.Errorf("LoadDelegateNetConf: failed with: %v", err)
×
66
                }
×
67
        }
68
        return delegateConf, nil
1✔
69
}
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