Skip to content

Commit dddb2c4

Browse files
committed
add vmclass labels
Signed-off-by: Pavel Tishkov <[email protected]>
1 parent 357a0bd commit dddb2c4

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

images/hooks/pkg/hooks/create-generic-vmclass/hook.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ import (
3333
)
3434

3535
const (
36-
createGenericVMClassHookName = "Create generic VirtualMachineClass"
37-
moduleStateSecretSnapshot = "module-state-secret"
38-
vmClassSnapshot = "vmclass-generic"
36+
moduleStateSecretSnapshot = "module-state-secret"
37+
vmClassSnapshot = "vmclass-generic"
3938

4039
moduleStateSecretName = "module-state"
4140
genericVMClassName = "generic"
@@ -71,6 +70,12 @@ var config = &pkg.HookConfig{
7170
NameSelector: &pkg.NameSelector{
7271
MatchNames: []string{genericVMClassName},
7372
},
73+
LabelSelector: &metav1.LabelSelector{
74+
MatchLabels: map[string]string{
75+
"app": "virtualization-controller",
76+
"module": settings.ModuleName,
77+
},
78+
},
7479
ExecuteHookOnSynchronization: ptr.To(false),
7580
},
7681
},
@@ -112,6 +117,7 @@ func Reconcile(_ context.Context, input *pkg.HookInput) error {
112117
ObjectMeta: metav1.ObjectMeta{
113118
Name: genericVMClassName,
114119
Labels: map[string]string{
120+
"app": "virtualization-controller",
115121
"module": settings.ModuleName,
116122
},
117123
},

images/hooks/pkg/hooks/create-generic-vmclass/hook_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ var _ = Describe("Create Generic VMClass hook", func() {
8282
vmClass, ok := obj.(*v1alpha2.VirtualMachineClass)
8383
Expect(ok).To(BeTrue())
8484
Expect(vmClass.Name).To(Equal("generic"))
85+
Expect(vmClass.Labels).To(Equal(map[string]string{
86+
"app": "virtualization-controller",
87+
"module": "virtualization",
88+
}))
8589
})
8690

8791
Expect(Reconcile(context.Background(), newInput())).To(Succeed())

images/hooks/pkg/hooks/update-module-state/hook.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ var config = &pkg.HookConfig{
6060
NameSelector: &pkg.NameSelector{
6161
MatchNames: []string{genericVMClassName},
6262
},
63+
LabelSelector: &metav1.LabelSelector{
64+
MatchLabels: map[string]string{
65+
"app": "virtualization-controller",
66+
"module": settings.ModuleName,
67+
},
68+
},
6369
ExecuteHookOnSynchronization: ptr.To(false),
6470
},
6571
{

0 commit comments

Comments
 (0)