Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hardcoded fields for parameter substitution configuration in Cluster Loader #17072

Merged
merged 2 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions test/extended/cluster/cl.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
}
allArgs = append(allArgs, templateObj.Name)

if template.Parameters == (ParameterConfigType{}) {
e2e.Logf("Pod environment variables will not be modified.")
if template.Parameters == nil {
e2e.Logf("Template environment variables will not be modified.")
} else {
params := convertVariablesToString(template.Parameters)
allArgs = append(allArgs, params...)
}

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

err = oc.SetNamespace(nsName).Run("new-app").Args(allArgs...).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
Expand All @@ -110,7 +110,7 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
// Parse Pod file into struct
config := ParsePods(mkPath(pod.File))
// Check if environment variables are defined in CL config
if pod.Parameters == (ParameterConfigType{}) {
if pod.Parameters == nil {
e2e.Logf("Pod environment variables will not be modified.")
} else {
// Override environment variables for Pod using ConfigMap
Expand Down
11 changes: 1 addition & 10 deletions test/extended/cluster/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,7 @@ type ClusterLoaderObjectType struct {
Image string
Basename string
File string
Parameters ParameterConfigType
}

// ParameterConfigType contains config parameters for each object
type ParameterConfigType struct {
Run string `mapstructure:"run"`
RouterIP string `mapstructure:"router_ip"`
TargetHost string `mapstructure:"target_host"`
DurationSec int `mapstructure:"duration"`
Megabytes int
Parameters map[string]interface{}
}

// TuningSetType is nested type for controlling Cluster Loader deployment pattern
Expand Down
14 changes: 5 additions & 9 deletions test/extended/cluster/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"time"
"unicode"

"github.com/fatih/structs"

kapiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -165,10 +163,9 @@ func firstLowercase(s string) string {
}

// convertVariables takes our loaded struct and converts it into a map[string]string.
func convertVariablesToMap(params ParameterConfigType) map[string]string {
m := structs.Map(params)
func convertVariablesToMap(params map[string]interface{}) map[string]string {
values := make(map[string]string)
for k, v := range m {
for k, v := range params {
k = firstLowercase(k)
if v != 0 && v != "" {
if _, ok := v.(int); ok {
Expand All @@ -181,9 +178,8 @@ func convertVariablesToMap(params ParameterConfigType) map[string]string {
return values
}

func convertVariablesToString(params ParameterConfigType) (args []string) {
m := structs.Map(params)
for k, v := range m {
func convertVariablesToString(params map[string]interface{}) (args []string) {
for k, v := range params {
k = strings.ToUpper(k)
if v != 0 && v != "" {
args = append(args, "-p")
Expand All @@ -194,7 +190,7 @@ func convertVariablesToString(params ParameterConfigType) (args []string) {
}

// InjectConfigMap modifies the pod struct and replaces the environment variables.
func InjectConfigMap(c kclientset.Interface, ns string, vars ParameterConfigType, config kapiv1.Pod) string {
func InjectConfigMap(c kclientset.Interface, ns string, vars map[string]interface{}, config kapiv1.Pod) string {
configMapName := ns + "-configmap"
freshConfigVars := convertVariablesToMap(vars)
dirtyConfigVars := getClusterData(c, freshConfigVars)
Expand Down
23 changes: 0 additions & 23 deletions vendor/github.com/fatih/structs/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions vendor/github.com/fatih/structs/.travis.yml

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/fatih/structs/LICENSE

This file was deleted.

163 changes: 0 additions & 163 deletions vendor/github.com/fatih/structs/README.md

This file was deleted.

Loading