Skip to content

Commit d121081

Browse files
committed
Add register-date and retire-date labels
1 parent c798e29 commit d121081

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

sabakan/generator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ func MachineToNode(m *Machine, tmpl *cke.Node) *cke.Node {
5252
n.Labels["cke.cybozu.com/rack"] = strconv.Itoa(m.Spec.Rack)
5353
n.Labels["cke.cybozu.com/index-in-rack"] = strconv.Itoa(m.Spec.IndexInRack)
5454
n.Labels["cke.cybozu.com/role"] = m.Spec.Role
55+
n.Labels["cke.cybozu.com/retire-date"] = m.Spec.RetireDate.Format("2006-01")
56+
n.Labels["cke.cybozu.com/register-date"] = m.Spec.RegisterDate.Format("2006-01")
5557
n.Labels["node-role.kubernetes.io/"+m.Spec.Role] = "true"
5658
if n.ControlPlane {
5759
n.Labels["node-role.kubernetes.io/master"] = "true"

sabakan/generator_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ func testMachineToNode(t *testing.T) {
7676
if res1.Labels["node-role.kubernetes.io/control-plane"] != "true" {
7777
t.Error(`res1.Lables["node-role.kubernetes.io/control-plane"] != "true", actual:`, res1.Labels)
7878
}
79+
if res1.Labels[domain+"/register-date"] != testPast250.Format("2006-01") {
80+
t.Error(`res1.Labels["cke.cybozu.com/register-date"] != machine.Spec.RegisterDate.Format("2006-01"), actual:`, res1.Labels)
81+
}
82+
if res1.Labels[domain+"/retire-date"] != testBaseTS.Format("2006-01") {
83+
t.Error(`res1.Labels["cke.cybozu.com/register-date"] != machine.Spec.RetireDate.Format("2006-01"), actual:`, res1.Labels)
84+
}
7985
if !containsTaint(res1.Taints, corev1.Taint{Key: "foo", Effect: corev1.TaintEffectNoSchedule}) {
8086
t.Error(`res1.Taints do not have corev1.Taint{Key"foo", Effect: corev1.TaintEffectNoSchedule}, actual:`, res1.Taints)
8187
}

0 commit comments

Comments
 (0)