Skip to content

Commit f37047b

Browse files
Merge pull request #17072 from sjug/cl_param_fix
Automatic merge from submit-queue (batch tested with PRs 17072, 17616). Remove hardcoded fields for parameter substitution configuration in Cluster Loader Fixes #17068 This should enable us to remove `fatih/structs` as a vendor dep as well.
2 parents b5db059 + 2277f3d commit f37047b

File tree

15 files changed

+10
-3250
lines changed

15 files changed

+10
-3250
lines changed

Diff for: glide.lock

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: test/extended/cluster/cl.go

+4-4
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

Diff for: test/extended/cluster/context.go

+1-10
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

Diff for: test/extended/cluster/utils.go

+5-9
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)

Diff for: vendor/github.com/fatih/structs/.gitignore

-23
This file was deleted.

Diff for: vendor/github.com/fatih/structs/.travis.yml

-12
This file was deleted.

Diff for: vendor/github.com/fatih/structs/LICENSE

-21
This file was deleted.

Diff for: vendor/github.com/fatih/structs/README.md

-163
This file was deleted.

0 commit comments

Comments
 (0)