Skip to content

Commit 3bef3a2

Browse files
committed
Remove hardcoded fields for Cluster Loader parameters
1 parent 6f2ba91 commit 3bef3a2

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

test/extended/cluster/cl.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
9292
}
9393
allArgs = append(allArgs, templateObj.Name)
9494

95-
if template.Parameters == (ParameterConfigType{}) {
96-
e2e.Logf("Pod environment variables will not be modified.")
95+
if template.Parameters == nil {
96+
e2e.Logf("Template environment variables will not be modified.")
9797
} else {
9898
params := convertVariablesToString(template.Parameters)
9999
allArgs = append(allArgs, params...)
100100
}
101101

102102
config, err := oc.AdminTemplateClient().Template().Templates(nsName).Create(templateObj)
103-
e2e.Logf("Template %v created, config: %+v", templateObj.Name, config)
103+
e2e.Logf("Template %v created, arguments: %v, config: %+v", templateObj.Name, allArgs, config)
104104

105105
err = oc.SetNamespace(nsName).Run("new-app").Args(allArgs...).Execute()
106106
o.Expect(err).NotTo(o.HaveOccurred())
@@ -110,7 +110,7 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
110110
// Parse Pod file into struct
111111
config := ParsePods(mkPath(pod.File))
112112
// Check if environment variables are defined in CL config
113-
if pod.Parameters == (ParameterConfigType{}) {
113+
if pod.Parameters == nil {
114114
e2e.Logf("Pod environment variables will not be modified.")
115115
} else {
116116
// Override environment variables for Pod using ConfigMap

test/extended/cluster/context.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,7 @@ type ClusterLoaderObjectType struct {
3333
Image string
3434
Basename string
3535
File string
36-
Parameters ParameterConfigType
37-
}
38-
39-
// ParameterConfigType contains config parameters for each object
40-
type ParameterConfigType struct {
41-
Run string `mapstructure:"run"`
42-
RouterIP string `mapstructure:"router_ip"`
43-
TargetHost string `mapstructure:"target_host"`
44-
DurationSec int `mapstructure:"duration"`
45-
Megabytes int
36+
Parameters map[string]interface{}
4637
}
4738

4839
// TuningSetType is nested type for controlling Cluster Loader deployment pattern

test/extended/cluster/utils.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"time"
1414
"unicode"
1515

16-
"github.com/fatih/structs"
17-
1816
kapiv1 "k8s.io/api/core/v1"
1917
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2018
"k8s.io/apimachinery/pkg/labels"
@@ -165,10 +163,9 @@ func firstLowercase(s string) string {
165163
}
166164

167165
// convertVariables takes our loaded struct and converts it into a map[string]string.
168-
func convertVariablesToMap(params ParameterConfigType) map[string]string {
169-
m := structs.Map(params)
166+
func convertVariablesToMap(params map[string]interface{}) map[string]string {
170167
values := make(map[string]string)
171-
for k, v := range m {
168+
for k, v := range params {
172169
k = firstLowercase(k)
173170
if v != 0 && v != "" {
174171
if _, ok := v.(int); ok {
@@ -181,9 +178,8 @@ func convertVariablesToMap(params ParameterConfigType) map[string]string {
181178
return values
182179
}
183180

184-
func convertVariablesToString(params ParameterConfigType) (args []string) {
185-
m := structs.Map(params)
186-
for k, v := range m {
181+
func convertVariablesToString(params map[string]interface{}) (args []string) {
182+
for k, v := range params {
187183
k = strings.ToUpper(k)
188184
if v != 0 && v != "" {
189185
args = append(args, "-p")
@@ -194,7 +190,7 @@ func convertVariablesToString(params ParameterConfigType) (args []string) {
194190
}
195191

196192
// InjectConfigMap modifies the pod struct and replaces the environment variables.
197-
func InjectConfigMap(c kclientset.Interface, ns string, vars ParameterConfigType, config kapiv1.Pod) string {
193+
func InjectConfigMap(c kclientset.Interface, ns string, vars map[string]interface{}, config kapiv1.Pod) string {
198194
configMapName := ns + "-configmap"
199195
freshConfigVars := convertVariablesToMap(vars)
200196
dirtyConfigVars := getClusterData(c, freshConfigVars)

0 commit comments

Comments
 (0)