/
feature_helpers.go
115 lines (96 loc) · 3 KB
/
feature_helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright 2023 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package featureflags
import (
"github.com/onsi/gomega"
"github.com/vmware-tanzu/tanzu-plugin-runtime/test/compatibility/core"
)
const (
CompatibilityTestsPlugin string = "compatibility-tests-plugin"
CompatibilityTestsPluginKey string = "compatibility-tests-plugin-key"
CompatibilityTestsPluginKey0 string = "compatibility-tests-plugin-key0"
CompatibilityTestsPluginKey1 string = "compatibility-tests-plugin-key1"
)
// DefaultIsFeatureEnabledCommand creates a IsFeatureEnabled Command with default input and output options
func DefaultIsFeatureEnabledCommand(version core.RuntimeVersion, opts ...CfgFeatureOptionArgs) *core.Command {
args := &CfgFeatureArgs{
Plugin: CompatibilityTestsPlugin,
Key: CompatibilityTestsPluginKey,
FeatureEnabled: true,
}
for _, opt := range opts {
opt(args)
}
inputOpts := &IsFeatureEnabledInputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: version,
},
Plugin: args.Plugin,
Key: args.Key,
}
outputOpts := &IsFeatureEnabledOutputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: version,
},
FeatureEnabled: args.FeatureEnabled,
ValidationStrategy: args.ValidationStrategy,
Error: args.Error,
}
cmd, err := NewIsFeatureEnabledCommand(inputOpts, outputOpts)
gomega.Expect(err).To(gomega.BeNil())
return cmd
}
// DefaultDeleteFeatureCommand creates a DeleteFeature Command with default input and output options
func DefaultDeleteFeatureCommand(version core.RuntimeVersion, opts ...CfgFeatureOptionArgs) *core.Command {
args := &CfgFeatureArgs{
Plugin: CompatibilityTestsPlugin,
Key: CompatibilityTestsPluginKey,
}
for _, opt := range opts {
opt(args)
}
inputOpts := &DeleteFeatureInputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: version,
},
Plugin: args.Plugin,
Key: args.Key,
}
outputOpts := &DeleteFeatureOutputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: version,
},
Error: args.Error,
}
cmd, err := NewDeleteFeatureCommand(inputOpts, outputOpts)
gomega.Expect(err).To(gomega.BeNil())
return cmd
}
// DefaultSetFeatureCommand creates a SetFeature Command with default input and output options
func DefaultSetFeatureCommand(version core.RuntimeVersion, opts ...CfgFeatureOptionArgs) *core.Command {
args := &CfgFeatureArgs{
Plugin: CompatibilityTestsPlugin,
Key: CompatibilityTestsPluginKey,
Value: "true",
}
for _, opt := range opts {
opt(args)
}
inputOpts := &SetFeatureInputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: version,
},
Plugin: args.Plugin,
Key: args.Key,
Value: args.Value,
}
outputOpts := &SetFeatureOutputOptions{
RuntimeAPIVersion: &core.RuntimeAPIVersion{
RuntimeVersion: version,
},
Error: args.Error,
}
cmd, err := NewSetFeatureCommand(inputOpts, outputOpts)
gomega.Expect(err).To(gomega.BeNil())
return cmd
}