From edb669a2964637f2bed652d4626f054c7d3571c4 Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Tue, 26 Nov 2024 11:15:40 +0100 Subject: [PATCH] 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") + } +}