From edb669a2964637f2bed652d4626f054c7d3571c4 Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Tue, 26 Nov 2024 11:15:40 +0100 Subject: [PATCH 1/2] New function to fetch OCP Virtualization version Signed-off-by: Raul Sevilla --- ocp-metadata/ocp-metadata.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ocp-metadata/ocp-metadata.go b/ocp-metadata/ocp-metadata.go index 0e6edc2..2d0de36 100644 --- a/ocp-metadata/ocp-metadata.go +++ b/ocp-metadata/ocp-metadata.go @@ -391,3 +391,15 @@ func toMap(str string) (map[string]interface{}, error) { } return config, nil } + +func (meta *Metadata) GetOCPVirtualizationVersion() (string, error) { + virtOp, err := meta.clientSet.AppsV1().Deployments("openshift-cnv").Get(context.TODO(), "virt-operator", metav1.GetOptions{}) + if err != nil { + return "", err + } + if virtOpVers, ok := virtOp.Labels["app.kubernetes.io/verssion"]; ok { + return virtOpVers, nil + } else { + return "", fmt.Errorf("label app.kubernetes.io/version not found in virt-operator deployment") + } +} From ac5a6353c7de19d2863d3873f39911bca027e43e Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Thu, 28 Nov 2024 11:27:22 +0100 Subject: [PATCH 2/2] Fix typo Signed-off-by: Raul Sevilla --- ocp-metadata/ocp-metadata.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocp-metadata/ocp-metadata.go b/ocp-metadata/ocp-metadata.go index 2d0de36..008635e 100644 --- a/ocp-metadata/ocp-metadata.go +++ b/ocp-metadata/ocp-metadata.go @@ -397,7 +397,7 @@ func (meta *Metadata) GetOCPVirtualizationVersion() (string, error) { if err != nil { return "", err } - if virtOpVers, ok := virtOp.Labels["app.kubernetes.io/verssion"]; ok { + if virtOpVers, ok := virtOp.Labels["app.kubernetes.io/version"]; ok { return virtOpVers, nil } else { return "", fmt.Errorf("label app.kubernetes.io/version not found in virt-operator deployment")