Skip to content

Commit 1c01b3d

Browse files
committed
rename annotationsutils pkg/folder into annotations
Signed-off-by: Michael Shitrit <[email protected]> Signed-off-by: Michael Shitrit <[email protected]>
1 parent 5b2ae0d commit 1c01b3d

File tree

9 files changed

+36
-36
lines changed

9 files changed

+36
-36
lines changed

api/v1alpha1/nodehealthcheck_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
logf "sigs.k8s.io/controller-runtime/pkg/log"
3434
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3535

36-
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotationutils"
36+
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotations"
3737
)
3838

3939
const (
@@ -201,7 +201,7 @@ func (v *customValidator) isMultipleTemplatesSupported(ctx context.Context, nhcE
201201
}
202202

203203
for _, actualTemplate := range templateList.Items {
204-
if !annotationutils.HasMultipleTemplatesAnnotation(&actualTemplate) {
204+
if !annotations.HasMultipleTemplatesAnnotation(&actualTemplate) {
205205
return false
206206
}
207207
}

controllers/machinehealthcheck_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
"github.com/medik8s/node-healthcheck-operator/controllers/mhc"
3636
"github.com/medik8s/node-healthcheck-operator/controllers/resources"
3737
"github.com/medik8s/node-healthcheck-operator/controllers/utils"
38-
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotationutils"
38+
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotations"
3939
"github.com/medik8s/node-healthcheck-operator/metrics"
4040
)
4141

@@ -172,7 +172,7 @@ func (r *MachineHealthCheckReconciler) Reconcile(ctx context.Context, req ctrl.R
172172
}()
173173

174174
// Return early if the object is paused
175-
if annotationutils.HasMHCPausedAnnotation(mhc) {
175+
if annotations.HasMHCPausedAnnotation(mhc) {
176176
log.Info("Reconciliation is paused")
177177
return result, nil
178178
}

controllers/machinehealthcheck_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
"github.com/medik8s/node-healthcheck-operator/controllers/mhc"
3838
"github.com/medik8s/node-healthcheck-operator/controllers/resources"
3939
"github.com/medik8s/node-healthcheck-operator/controllers/utils"
40-
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotationutils"
40+
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotations"
4141
)
4242

4343
const (
@@ -132,7 +132,7 @@ func TestReconcile(t *testing.T) {
132132

133133
machineHealthCheckPaused := newMachineHealthCheck("machineHealthCheck")
134134
machineHealthCheckPaused.Annotations = make(map[string]string)
135-
machineHealthCheckPaused.Annotations[annotationutils.MHCPausedAnnotation] = "test"
135+
machineHealthCheckPaused.Annotations[annotations.MHCPausedAnnotation] = "test"
136136

137137
// remediationExternal
138138
nodeUnhealthyForTooLong := newNodeForMHC("nodeUnhealthyForTooLong", false)

controllers/nodehealthcheck_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import (
5757
"github.com/medik8s/node-healthcheck-operator/controllers/mhc"
5858
"github.com/medik8s/node-healthcheck-operator/controllers/resources"
5959
"github.com/medik8s/node-healthcheck-operator/controllers/utils"
60-
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotationutils"
60+
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotations"
6161
"github.com/medik8s/node-healthcheck-operator/metrics"
6262
)
6363

@@ -483,8 +483,8 @@ func (r *NodeHealthCheckReconciler) deleteOrphanedRemediationCRs(nhc *remediatio
483483
log.Info("Going to delete orphaned remediation CRs", "count", len(orphanedRemediationCRs))
484484
for _, cr := range orphanedRemediationCRs {
485485
nodeName := cr.GetName()
486-
if cr.GetAnnotations() != nil && len(cr.GetAnnotations()[annotationutils.NodeNameAnnotation]) > 0 {
487-
nodeName = cr.GetAnnotations()[annotationutils.NodeNameAnnotation]
486+
if cr.GetAnnotations() != nil && len(cr.GetAnnotations()[annotations.NodeNameAnnotation]) > 0 {
487+
nodeName = cr.GetAnnotations()[annotations.NodeNameAnnotation]
488488
}
489489
// do some housekeeping first. When the CRs are deleted, we never get back here...
490490
if err := rm.CleanUp(nodeName); err != nil {

controllers/nodehealthcheck_controller_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"github.com/medik8s/node-healthcheck-operator/api/v1alpha1"
3333
"github.com/medik8s/node-healthcheck-operator/controllers/resources"
3434
"github.com/medik8s/node-healthcheck-operator/controllers/utils"
35-
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotationutils"
35+
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotations"
3636
)
3737

3838
const (
@@ -960,7 +960,7 @@ var _ = Describe("Node Health Check CR", func() {
960960
g.Expect(k8sClient.Get(context.Background(), client.ObjectKeyFromObject(newCr), newCr)).To(Succeed())
961961
g.Expect(cr.GetAnnotations()).To(HaveKeyWithValue(Equal("remediation.medik8s.io/nhc-timed-out"), Not(BeNil())))
962962
g.Expect(newCr.GetName()).To(Equal(unhealthyNodeName))
963-
g.Expect(newCr.GetAnnotations()).ToNot(HaveKey(Equal(annotationutils.NodeNameAnnotation)))
963+
g.Expect(newCr.GetAnnotations()).ToNot(HaveKey(Equal(annotations.NodeNameAnnotation)))
964964

965965
}, time.Second*10, time.Millisecond*300).Should(Succeed())
966966

@@ -979,8 +979,8 @@ var _ = Describe("Node Health Check CR", func() {
979979
thirdCR = getRemediationCRForMultiKindSupportTemplate(multiSupportTemplateRef.Name)
980980
g.Expect(thirdCR).ToNot(BeNil())
981981
g.Expect(thirdCR.GetName()).ToNot(Equal(unhealthyNodeName))
982-
g.Expect(thirdCR.GetAnnotations()[annotationutils.NodeNameAnnotation]).To(Equal(unhealthyNodeName))
983-
g.Expect(thirdCR.GetAnnotations()[annotationutils.TemplateNameAnnotation]).To(Equal(multiSupportTemplateRef.Name))
982+
g.Expect(thirdCR.GetAnnotations()[annotations.NodeNameAnnotation]).To(Equal(unhealthyNodeName))
983+
g.Expect(thirdCR.GetAnnotations()[annotations.TemplateNameAnnotation]).To(Equal(multiSupportTemplateRef.Name))
984984
g.Expect(thirdCR.GetAnnotations()).ToNot(HaveKey(Equal("remediation.medik8s.io/nhc-timed-out")))
985985
}, time.Second*10, time.Millisecond*300).Should(Succeed())
986986

@@ -990,8 +990,8 @@ var _ = Describe("Node Health Check CR", func() {
990990
thirdCR = getRemediationCRForMultiKindSupportTemplate(multiSupportTemplateRef.Name)
991991
g.Expect(thirdCR).ToNot(BeNil())
992992
g.Expect(thirdCR.GetName()).ToNot(Equal(unhealthyNodeName))
993-
g.Expect(thirdCR.GetAnnotations()[annotationutils.NodeNameAnnotation]).To(Equal(unhealthyNodeName))
994-
g.Expect(thirdCR.GetAnnotations()[annotationutils.TemplateNameAnnotation]).To(Equal(multiSupportTemplateRef.Name))
993+
g.Expect(thirdCR.GetAnnotations()[annotations.NodeNameAnnotation]).To(Equal(unhealthyNodeName))
994+
g.Expect(thirdCR.GetAnnotations()[annotations.TemplateNameAnnotation]).To(Equal(multiSupportTemplateRef.Name))
995995
g.Expect(thirdCR.GetAnnotations()).To(HaveKeyWithValue(Equal("remediation.medik8s.io/nhc-timed-out"), Not(BeNil())))
996996
}, time.Second*10, time.Millisecond*300).Should(Succeed())
997997

@@ -1001,8 +1001,8 @@ var _ = Describe("Node Health Check CR", func() {
10011001
forthCR = getRemediationCRForMultiKindSupportTemplate(secondMultiSupportTemplateRef.Name)
10021002
g.Expect(forthCR).ToNot(BeNil())
10031003
g.Expect(forthCR.GetName()).ToNot(Equal(unhealthyNodeName))
1004-
g.Expect(forthCR.GetAnnotations()[annotationutils.NodeNameAnnotation]).To(Equal(unhealthyNodeName))
1005-
g.Expect(forthCR.GetAnnotations()[annotationutils.TemplateNameAnnotation]).To(Equal(secondMultiSupportTemplateRef.Name))
1004+
g.Expect(forthCR.GetAnnotations()[annotations.NodeNameAnnotation]).To(Equal(unhealthyNodeName))
1005+
g.Expect(forthCR.GetAnnotations()[annotations.TemplateNameAnnotation]).To(Equal(secondMultiSupportTemplateRef.Name))
10061006
g.Expect(forthCR.GetAnnotations()).ToNot(HaveKey(Equal("remediation.medik8s.io/nhc-timed-out")))
10071007
}, time.Second*10, time.Millisecond*300).Should(Succeed())
10081008

@@ -2052,7 +2052,7 @@ func getRemediationCRForMultiKindSupportTemplate(templateName string) *unstructu
20522052
for _, cr := range resourceList.Items {
20532053
ann := cr.GetAnnotations()
20542054
if ann != nil {
2055-
if ann[annotationutils.TemplateNameAnnotation] == templateName {
2055+
if ann[annotations.TemplateNameAnnotation] == templateName {
20562056
return &cr
20572057
}
20582058
}

controllers/resources/manager.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
remediationv1alpha1 "github.com/medik8s/node-healthcheck-operator/api/v1alpha1"
2424
"github.com/medik8s/node-healthcheck-operator/controllers/utils"
25-
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotationutils"
25+
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotations"
2626
)
2727

2828
type Manager interface {
@@ -125,9 +125,9 @@ func (m *manager) generateRemediationCR(name string, healthCheckOwnerRef *metav1
125125
templateSpec, _, _ := unstructured.NestedMap(template.Object, "spec", "template", "spec")
126126
unstructured.SetNestedField(remediationCR.Object, templateSpec, "spec")
127127

128-
if annotationutils.HasMultipleTemplatesAnnotation(template) {
128+
if annotations.HasMultipleTemplatesAnnotation(template) {
129129
remediationCR.SetGenerateName(name)
130-
remediationCR.SetAnnotations(map[string]string{annotationutils.NodeNameAnnotation: name, annotationutils.TemplateNameAnnotation: template.GetName()})
130+
remediationCR.SetAnnotations(map[string]string{annotations.NodeNameAnnotation: name, annotations.TemplateNameAnnotation: template.GetName()})
131131
} else {
132132
remediationCR.SetName(name)
133133
}
@@ -177,7 +177,7 @@ func (m *manager) GenerateRemediationCRBase(gvk schema.GroupVersionKind) *unstru
177177
// CreateRemediationCR creates the given remediation CR from remediationCR it'll return: a bool indicator of success, a *time.Duration an indicator on when requeue is needed in order to extend the lease, a *unstructured.Unstructured of the created/existing CR and an error
178178
func (m *manager) CreateRemediationCR(remediationCR *unstructured.Unstructured, owner client.Object, nodeName *string, currentRemediationDuration, previousRemediationsDuration time.Duration) (bool, *time.Duration, *unstructured.Unstructured, error) {
179179
var err error
180-
if remediationCR.GetAnnotations() == nil || len(remediationCR.GetAnnotations()[annotationutils.NodeNameAnnotation]) == 0 {
180+
if remediationCR.GetAnnotations() == nil || len(remediationCR.GetAnnotations()[annotations.NodeNameAnnotation]) == 0 {
181181
err = m.Get(m.ctx, client.ObjectKeyFromObject(remediationCR), remediationCR)
182182
} else {
183183
remediationCR, err = m.getCRWithNodeNameAnnotation(remediationCR)
@@ -358,8 +358,8 @@ func (m *manager) getOwningMachineWithNamespace(node *corev1.Node) (*metav1.Owne
358358
}
359359

360360
func (m *manager) getCRWithNodeNameAnnotation(remediationCR *unstructured.Unstructured) (*unstructured.Unstructured, error) {
361-
nodeName := remediationCR.GetAnnotations()[annotationutils.NodeNameAnnotation]
362-
templateName := remediationCR.GetAnnotations()[annotationutils.TemplateNameAnnotation]
361+
nodeName := remediationCR.GetAnnotations()[annotations.NodeNameAnnotation]
362+
templateName := remediationCR.GetAnnotations()[annotations.TemplateNameAnnotation]
363363

364364
resourceList := &unstructured.UnstructuredList{Object: m.GenerateRemediationCRBase(remediationCR.GroupVersionKind()).Object}
365365
if err := m.List(m.ctx, resourceList); err == nil {
@@ -382,22 +382,22 @@ func (m *manager) isMatchNodeTemplate(cr unstructured.Unstructured, nodeName str
382382
if cr.GetAnnotations() == nil {
383383
return cr.GetName() == nodeName
384384
}
385-
annotations := cr.GetAnnotations()
386-
if _, isMultiSupported := annotations[annotationutils.TemplateNameAnnotation]; !isMultiSupported {
385+
ann := cr.GetAnnotations()
386+
if _, isMultiSupported := ann[annotations.TemplateNameAnnotation]; !isMultiSupported {
387387
return cr.GetName() == nodeName
388388
}
389-
return annotations[annotationutils.TemplateNameAnnotation] == templateName && annotations[annotationutils.NodeNameAnnotation] == nodeName
389+
return ann[annotations.TemplateNameAnnotation] == templateName && ann[annotations.NodeNameAnnotation] == nodeName
390390
}
391391

392392
func (m *manager) extractNodeName(cr unstructured.Unstructured) string {
393393
if cr.GetAnnotations() == nil {
394394
return cr.GetName()
395395
}
396-
annotations := cr.GetAnnotations()
397-
if _, isMultiSupported := annotations[annotationutils.TemplateNameAnnotation]; !isMultiSupported {
396+
ann := cr.GetAnnotations()
397+
if _, isMultiSupported := ann[annotations.TemplateNameAnnotation]; !isMultiSupported {
398398
return cr.GetName()
399399
}
400-
return annotations[annotationutils.NodeNameAnnotation]
400+
return ann[annotations.NodeNameAnnotation]
401401
}
402402

403403
func createOwnerRef(obj client.Object) *metav1.OwnerReference {

controllers/resources/status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
99

1010
remediationv1alpha1 "github.com/medik8s/node-healthcheck-operator/api/v1alpha1"
11-
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotationutils"
11+
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotations"
1212
"github.com/medik8s/node-healthcheck-operator/metrics"
1313
)
1414

@@ -24,7 +24,7 @@ func UpdateStatusRemediationStarted(node *corev1.Node, nhc *remediationv1alpha1.
2424

2525
var templateName string
2626
if remediationCR.GetAnnotations() != nil {
27-
templateName = remediationCR.GetAnnotations()[annotationutils.TemplateNameAnnotation]
27+
templateName = remediationCR.GetAnnotations()[annotations.TemplateNameAnnotation]
2828
}
2929
remediation := remediationv1alpha1.Remediation{
3030
Resource: corev1.ObjectReference{

controllers/suite_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import (
5656
"github.com/medik8s/node-healthcheck-operator/controllers/mhc"
5757

5858
// +kubebuilder:scaffold:imports
59-
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotationutils"
59+
"github.com/medik8s/node-healthcheck-operator/controllers/utils/annotations"
6060
)
6161

6262
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
@@ -187,10 +187,10 @@ var _ = BeforeSuite(func() {
187187
Expect(k8sClient.Create(context.Background(), newTestRemediationCRD(multiSupportTestKind))).To(Succeed())
188188
time.Sleep(time.Second)
189189
multiSupportTemplate := newTestRemediationTemplateCR(multiSupportTestKind, MachineNamespace, MultipleSupportTemplateName)
190-
multiSupportTemplate.SetAnnotations(map[string]string{annotationutils.MultipleTemplatesSupportedAnnotation: "true"})
190+
multiSupportTemplate.SetAnnotations(map[string]string{annotations.MultipleTemplatesSupportedAnnotation: "true"})
191191
Expect(k8sClient.Create(context.Background(), multiSupportTemplate)).To(Succeed())
192192
secondMultiSupportTemplate := newTestRemediationTemplateCR(multiSupportTestKind, MachineNamespace, SecondMultipleSupportTemplateName)
193-
secondMultiSupportTemplate.SetAnnotations(map[string]string{annotationutils.MultipleTemplatesSupportedAnnotation: "true"})
193+
secondMultiSupportTemplate.SetAnnotations(map[string]string{annotations.MultipleTemplatesSupportedAnnotation: "true"})
194194
Expect(k8sClient.Create(context.Background(), secondMultiSupportTemplate)).To(Succeed())
195195

196196
upgradeChecker = &fakeClusterUpgradeChecker{

controllers/utils/annotationutils/annotations.go renamed to controllers/utils/annotations/annotations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package annotationutils
1+
package annotations
22

33
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
44

0 commit comments

Comments
 (0)