From 32397f95d7bc3e31d9106ec59c5fd6a3c178ad2d Mon Sep 17 00:00:00 2001 From: Michael Engel Date: Fri, 27 May 2022 11:30:26 +0200 Subject: [PATCH] added feature flag for placement policy (#208) --- feature.go | 12 +++++++++++- feature_test.go | 29 ++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/feature.go b/feature.go index 806336f..1e808fb 100644 --- a/feature.go +++ b/feature.go @@ -9,8 +9,11 @@ import ( type Feature string const ( - // FeatureAutoPinning is a feature flags for autopinning support in the oVirt Engine supported since 4.4.5. + // FeatureAutoPinning is a feature flag for autopinning support in the oVirt Engine supported since 4.4.5. FeatureAutoPinning Feature = "autopinning" + + // FeaturePlacementPolicy is a feature flag to indicate placement policy support in the oVirt Engine. + FeaturePlacementPolicy Feature = "placement_policy" ) // FeatureClient provides the functions to determine the capabilities of the oVirt Engine. @@ -29,6 +32,13 @@ func (o *oVirtClient) SupportsFeature(feature Feature, retries ...RetryStrategy) Build_(5). Revision(0). MustBuild() + case FeaturePlacementPolicy: + minimumVersion = ovirtsdk.NewVersionBuilder(). + Major(4). + Minor(4). + Build_(5). + Revision(0). + MustBuild() default: return false, newError(EBug, "unknown feature: %s", feature) } diff --git a/feature_test.go b/feature_test.go index e2d2d3f..b693ded 100644 --- a/feature_test.go +++ b/feature_test.go @@ -10,13 +10,28 @@ func TestFeatureFlags(t *testing.T) { t.Parallel() helper := getHelper(t) - supported, err := helper.GetClient().SupportsFeature(ovirtclient.FeatureAutoPinning) - if err != nil { - t.Fatalf("Failed to check autopinning support (%v)", err) + testcases := map[string]struct { + input ovirtclient.Feature + }{ + "Feature Autopinning": { + input: ovirtclient.FeatureAutoPinning, + }, + "Feature Placement Policy": { + input: ovirtclient.FeatureAutoPinning, + }, } - if supported { - t.Logf("Autopinning is supported.") - } else { - t.Logf("Autopinning is not supported.") + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + supported, err := helper.GetClient().SupportsFeature(tc.input) + if err != nil { + t.Fatalf("Failed to check '%s' support (%v)", tc.input, err) + } + if supported { + t.Logf("'%s' is supported.", tc.input) + } else { + t.Logf("'%s' is not supported.", tc.input) + } + }) } }