Skip to content

Commit ad0bf95

Browse files
authored
feat: update generate_template_labels method (#2604)
* update generate_template_labels method on multi-arch clusters multiple templates of same OS (with diff arch) exists added optional architecture param * add ARCH constants class
1 parent 3d55201 commit ad0bf95

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

ocp_resources/template.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ class Labels:
1212
FLAVOR = "flavor.template.kubevirt.io"
1313
OS = "os.template.kubevirt.io"
1414
WORKLOAD = "workload.template.kubevirt.io"
15+
ARCHITECTURE = f"{NamespacedResource.ApiGroup.TEMPLATE_KUBEVIRT_IO}/architecture"
16+
17+
class Architecture:
18+
AMD64 = "amd64"
19+
ARM64 = "arm64"
20+
S390X = "s390x"
1521

1622
class Workload:
1723
DESKTOP = "desktop"
@@ -61,9 +67,12 @@ def process(self, client=None, **kwargs):
6167
return response.to_dict()["objects"]
6268

6369
@staticmethod
64-
def generate_template_labels(os, workload, flavor):
65-
return [
66-
f"{Template.Labels.OS}/{os}",
67-
(f"{Template.Labels.WORKLOAD}/{getattr(Template.Workload, workload.upper())}"),
68-
f"{Template.Labels.FLAVOR}/{getattr(Template.Flavor, flavor.upper())}",
70+
def generate_template_labels(os, workload, flavor, architecture=None):
71+
labels = [
72+
f"{Template.Labels.OS}/{os}=true",
73+
f"{Template.Labels.WORKLOAD}/{getattr(Template.Workload, workload.upper())}=true",
74+
f"{Template.Labels.FLAVOR}/{getattr(Template.Flavor, flavor.upper())}=true",
6975
]
76+
if architecture:
77+
labels.append(f"{Template.Labels.ARCHITECTURE}={getattr(Template.Architecture, architecture.upper())}")
78+
return labels

0 commit comments

Comments
 (0)