Skip to content

Commit

Permalink
added feature flag for placement policy (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
engelmi authored May 27, 2022
1 parent 4e5fd84 commit 32397f9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
12 changes: 11 additions & 1 deletion feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
}
Expand Down
29 changes: 22 additions & 7 deletions feature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
}

0 comments on commit 32397f9

Please sign in to comment.