Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #531 from longngn/yaml-unmarshal
Browse files Browse the repository at this point in the history
[MTB] refactor: use yaml unmarshal
  • Loading branch information
k8s-ci-robot authored Mar 23, 2020
2 parents b8224bf + 833544b commit 58f2cb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
12 changes: 6 additions & 6 deletions benchmarks/e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
const ConfigPath = "./config.yaml"

type BenchmarkConfig struct {
Adminkubeconfig string `json:"adminKubeconfig"`
Label string `json:"label,omitempty"`
TenantA TenantSpec `json:"tenantA,omitempty"`
TenantB TenantSpec `json:"tenantB,omitempty"`
Adminkubeconfig string `yaml:"adminKubeconfig"`
Label string `yaml:"label,omitempty"`
TenantA TenantSpec `yaml:"tenantA,omitempty"`
TenantB TenantSpec `yaml:"tenantB,omitempty"`
}

type TenantSpec struct {
Kubeconfig string `json:"kubeconfig"`
Namespace string `json:"namespace"`
Kubeconfig string `yaml:"kubeconfig"`
Namespace string `yaml:"namespace"`
}

func (c *BenchmarkConfig) GetValidTenant() TenantSpec {
Expand Down
10 changes: 2 additions & 8 deletions benchmarks/e2e/config/utils.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package test

import (
"encoding/json"
"io/ioutil"
"os"

yaml "k8s.io/apimachinery/pkg/util/yaml"
"gopkg.in/yaml.v2"
kubernetes "k8s.io/client-go/kubernetes"
clientcmd "k8s.io/client-go/tools/clientcmd"
"k8s.io/kubernetes/test/e2e/framework"
Expand Down Expand Up @@ -39,12 +38,7 @@ func ReadConfig(path string) (*BenchmarkConfig, error) {
return nil, err
}

data, err := yaml.ToJSON(file)
if err != nil {
return nil, err
}

if err := json.Unmarshal(data, &config); err != nil {
if err := yaml.Unmarshal(file, &config); err != nil {
return nil, err
}

Expand Down

0 comments on commit 58f2cb1

Please sign in to comment.