Map api version of generation info to openshift version
@@ -5,6 +5,8 @@ import (
"k8s.io/apimachinery/pkg/runtime"
+ k6tv1 "kubevirt.io/client-go/api/v1"
+
appsv1 "k8s.io/api/apps/v1"
operatorsv1 "github.com/openshift/api/operator/v1"
@@ -45,14 +47,16 @@ func getGroupResource(required runtime.Object) (group string, resource string, e
return
}
-func GetExpectedGeneration(required runtime.Object, previousGenerations []operatorsv1.GenerationStatus) int64 {
+func GetExpectedGeneration(required runtime.Object, previousGenerations []k6tv1.GenerationStatus) int64 {
group, resource, err := getGroupResource(required)
if err != nil {
return -1
}
+ operatorGenerations := toOperatorGenerations(previousGenerations)
+
meta := required.(v1.Object)
- generation := resourcemerge.GenerationFor(previousGenerations, schema.GroupResource{Group: group, Resource: resource}, meta.GetNamespace(), meta.GetName())
+ generation := resourcemerge.GenerationFor(operatorGenerations, schema.GroupResource{Group: group, Resource: resource}, meta.GetNamespace(), meta.GetName())
if generation == nil {
return -1
}
@@ -60,7 +64,8 @@ func GetExpectedGeneration(required runtime.Object, previousGenerations []operat
return generation.LastGeneration
}
-func SetGeneration(generations *[]operatorsv1.GenerationStatus, actual runtime.Object) {
+func SetGeneration(generations *[]k6tv1.GenerationStatus, actual runtime.Object) {
+
if actual == nil {
return
}
@@ -70,13 +75,53 @@ func SetGeneration(generations *[]operatorsv1.GenerationStatus, actual runtime.O
return
}
+ operatorGenerations := toOperatorGenerations(*generations)
meta := actual.(v1.Object)
- resourcemerge.SetGeneration(generations, operatorsv1.GenerationStatus{
+ resourcemerge.SetGeneration(&operatorGenerations, operatorsv1.GenerationStatus{
Group: group,
Resource: resource,
Namespace: meta.GetNamespace(),
Name: meta.GetName(),
LastGeneration: meta.GetGeneration(),
})
+
+ newGenerations := toAPIGenerations(operatorGenerations)
+ *generations = newGenerations
+}
+
+func toOperatorGeneration(generation k6tv1.GenerationStatus) operatorsv1.GenerationStatus {
+ return operatorsv1.GenerationStatus{
+ Group: generation.Group,
+ Resource: generation.Resource,
+ Namespace: generation.Namespace,
+ Name: generation.Name,
+ LastGeneration: generation.LastGeneration,
+ Hash: generation.Hash,
+ }
+}
+
+func toAPIGeneration(generation operatorsv1.GenerationStatus) k6tv1.GenerationStatus {
+ return k6tv1.GenerationStatus{
+ Group: generation.Group,
+ Resource: generation.Resource,
+ Namespace: generation.Namespace,
+ Name: generation.Name,
+ LastGeneration: generation.LastGeneration,
+ Hash: generation.Hash,
+ }
+}
+
+func toOperatorGenerations(generations []k6tv1.GenerationStatus) (operatorGenerations []operatorsv1.GenerationStatus) {
+ for _, generation := range generations {
+ operatorGenerations = append(operatorGenerations, toOperatorGeneration(generation))
+ }
+ return operatorGenerations
+}
+
+func toAPIGenerations(generations []operatorsv1.GenerationStatus) (apiGenerations []k6tv1.GenerationStatus) {
+ for _, generation := range generations {
+ apiGenerations = append(apiGenerations, toAPIGeneration(generation))
+ }
+ return apiGenerations
}
