Skip to content

Commit

Permalink
Rename HasNetworkAttachment to HasNetworkAttachmentAnnot (#85)
Browse files Browse the repository at this point in the history
This function actually check network attachment annotations,
not network attachment
  • Loading branch information
e0ne authored Jan 13, 2021
1 parent 9913136 commit 0dcd988
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func PodScheduled(pod *kapi.Pod) bool {
return pod.Spec.NodeName != ""
}

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

Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ var _ = Describe("Utils", func() {
Expect(PodScheduled(pod)).To(BeTrue())
})
})
Context("HasNetworkAttachment", func() {
Context("HasNetworkAttachmentAnnot", func() {
It("Check pod if pod is has network attachment annotation", func() {
pod := &kapi.Pod{ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{v1.NetworkAttachmentAnnot: `[{"name":"test"}]`}}}
Expect(HasNetworkAttachment(pod)).To(BeTrue())
Expect(HasNetworkAttachmentAnnot(pod)).To(BeTrue())
})
})
Context("PodIsRunning", func() {
Expand Down
6 changes: 3 additions & 3 deletions pkg/watcher/handler/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (p *podEventHandler) OnAdd(obj interface{}) {
return
}

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

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

if !utils.HasNetworkAttachment(pod) {
if !utils.HasNetworkAttachmentAnnot(pod) {
log.Debug().Msgf("pod doesn't have network annotation \"%v\"", v1.NetworkAttachmentAnnot)
return
}
Expand Down

0 comments on commit 0dcd988

Please sign in to comment.