Skip to content

Commit 0dcd988

Browse files
authored
Rename HasNetworkAttachment to HasNetworkAttachmentAnnot (#85)
This function actually check network attachment annotations, not network attachment
1 parent 9913136 commit 0dcd988

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pkg/utils/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ func PodScheduled(pod *kapi.Pod) bool {
3333
return pod.Spec.NodeName != ""
3434
}
3535

36-
// HasNetworkAttachment check if pod has Network Attachment
37-
func HasNetworkAttachment(pod *kapi.Pod) bool {
36+
// HasNetworkAttachmentAnnot check if pod has Network Attachment Annotation
37+
func HasNetworkAttachmentAnnot(pod *kapi.Pod) bool {
3838
return len(pod.Annotations[v1.NetworkAttachmentAnnot]) > 0
3939
}
4040

pkg/utils/utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ var _ = Describe("Utils", func() {
2121
Expect(PodScheduled(pod)).To(BeTrue())
2222
})
2323
})
24-
Context("HasNetworkAttachment", func() {
24+
Context("HasNetworkAttachmentAnnot", func() {
2525
It("Check pod if pod is has network attachment annotation", func() {
2626
pod := &kapi.Pod{ObjectMeta: metav1.ObjectMeta{
2727
Annotations: map[string]string{v1.NetworkAttachmentAnnot: `[{"name":"test"}]`}}}
28-
Expect(HasNetworkAttachment(pod)).To(BeTrue())
28+
Expect(HasNetworkAttachmentAnnot(pod)).To(BeTrue())
2929
})
3030
})
3131
Context("PodIsRunning", func() {

pkg/watcher/handler/pod.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (p *podEventHandler) OnAdd(obj interface{}) {
4949
return
5050
}
5151

52-
if !utils.HasNetworkAttachment(pod) {
52+
if !utils.HasNetworkAttachmentAnnot(pod) {
5353
log.Debug().Msgf("pod doesn't have network annotation \"%v\"", v1.NetworkAttachmentAnnot)
5454
return
5555
}
@@ -83,7 +83,7 @@ func (p *podEventHandler) OnUpdate(oldObj, newObj interface{}) {
8383
return
8484
}
8585

86-
if !utils.HasNetworkAttachment(pod) {
86+
if !utils.HasNetworkAttachmentAnnot(pod) {
8787
log.Debug().Msgf("pod doesn't have network annotation \"%v\"", v1.NetworkAttachmentAnnot)
8888
return
8989
}
@@ -115,7 +115,7 @@ func (p *podEventHandler) OnDelete(obj interface{}) {
115115
return
116116
}
117117

118-
if !utils.HasNetworkAttachment(pod) {
118+
if !utils.HasNetworkAttachmentAnnot(pod) {
119119
log.Debug().Msgf("pod doesn't have network annotation \"%v\"", v1.NetworkAttachmentAnnot)
120120
return
121121
}

0 commit comments

Comments
 (0)