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

kubevirt / hyperconverged-cluster-operator / 16339590247

17 Jul 2025 08:01AM UTC coverage: 75.103% (-0.02%) from 75.124%
16339590247

Pull #3601

github

web-flow
Merge bcff6906b into cb8d4dd66
Pull Request #3601: network,passt: Deploy Passt required objects

391 of 521 new or added lines in 10 files covered. (75.05%)

97 existing lines in 2 files now uncovered.

6908 of 9198 relevant lines covered (75.1%)

1.77 hits per line

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

80.0
/controllers/operands/networkAttachmentDefinitionHandler.go
1
package operands
2

3
import (
4
        "errors"
5
        "reflect"
6

7
        "k8s.io/apimachinery/pkg/runtime"
8
        "sigs.k8s.io/controller-runtime/pkg/client"
9

10
        netattdefv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
11

12
        hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
13
        "github.com/kubevirt/hyperconverged-cluster-operator/controllers/common"
14
        "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"
15
)
16

17
type newNetworkAttachmentDefinitionFunc func(hc *hcov1beta1.HyperConverged) *netattdefv1.NetworkAttachmentDefinition
18

19
func NewNetworkAttachmentDefinitionHandler(Client client.Client, Scheme *runtime.Scheme, newCrFunc newNetworkAttachmentDefinitionFunc) *GenericOperand {
3✔
20
        return NewGenericOperand(Client, Scheme, "NetworkAttachmentDefinition", &networkAttachmentDefinitionHooks{newCrFunc: newCrFunc}, false)
3✔
21
}
3✔
22

23
type networkAttachmentDefinitionHooks struct {
24
        newCrFunc newNetworkAttachmentDefinitionFunc
25
}
26

27
func (h networkAttachmentDefinitionHooks) GetFullCr(hc *hcov1beta1.HyperConverged) (client.Object, error) {
1✔
28
        return h.newCrFunc(hc), nil
1✔
29
}
1✔
30

31
func (networkAttachmentDefinitionHooks) GetEmptyCr() client.Object {
1✔
32
        return &netattdefv1.NetworkAttachmentDefinition{}
1✔
33
}
1✔
34

35
func (networkAttachmentDefinitionHooks) JustBeforeComplete(_ *common.HcoRequest) { /* no implementation */
1✔
36
}
1✔
37

38
func (networkAttachmentDefinitionHooks) UpdateCR(req *common.HcoRequest, Client client.Client, exists runtime.Object, required runtime.Object) (bool, bool, error) {
1✔
39
        return updateNetworkAttachmentDefinition(req, Client, exists, required)
1✔
40
}
1✔
41

42
func updateNetworkAttachmentDefinition(req *common.HcoRequest, Client client.Client, exists runtime.Object, required runtime.Object) (bool, bool, error) {
1✔
43
        networkAttachmentDefinition, ok1 := required.(*netattdefv1.NetworkAttachmentDefinition)
1✔
44
        found, ok2 := exists.(*netattdefv1.NetworkAttachmentDefinition)
1✔
45
        if !ok1 || !ok2 {
1✔
NEW
46
                return false, false, errors.New("can't convert to NetworkAttachmentDefinition")
×
NEW
47
        }
×
48
        if !reflect.DeepEqual(found.Spec, networkAttachmentDefinition.Spec) ||
1✔
49
                !util.CompareLabels(networkAttachmentDefinition, found) {
2✔
50
                if req.HCOTriggered {
2✔
51
                        req.Logger.Info("Updating existing NetworkAttachmentDefinition Spec to new opinionated values")
1✔
52
                } else {
1✔
NEW
53
                        req.Logger.Info("Reconciling an externally updated NetworkAttachmentDefinition's Spec to its opinionated values")
×
NEW
54
                }
×
55
                util.MergeLabels(&networkAttachmentDefinition.ObjectMeta, &found.ObjectMeta)
1✔
56
                networkAttachmentDefinition.Spec.DeepCopyInto(&found.Spec)
1✔
57
                err := Client.Update(req.Ctx, found)
1✔
58
                if err != nil {
1✔
NEW
59
                        return false, false, err
×
NEW
60
                }
×
61
                return true, !req.HCOTriggered, nil
1✔
62
        }
NEW
63
        return false, false, nil
×
64
}
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