Skip to content

Commit

Permalink
Use 'sigs.k8s.io/yaml' instead of 'github.com/ghodss/yaml'
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
  • Loading branch information
tenzen-y committed Jul 30, 2023
1 parent 5a2df5a commit 20a1723
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 35 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ require (
github.com/tidwall/gjson v1.14.1
golang.org/x/net v0.7.0
google.golang.org/grpc v1.53.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.25.3
k8s.io/apimachinery v0.25.3
k8s.io/client-go v0.25.3
Expand All @@ -33,6 +32,7 @@ require (
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
sigs.k8s.io/controller-runtime v0.13.0
sigs.k8s.io/yaml v1.3.0
)

require (
Expand Down Expand Up @@ -130,6 +130,7 @@ require (
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.1.0 // indirect
k8s.io/apiextensions-apiserver v0.25.0 // indirect
k8s.io/cloud-provider v0.21.0 // indirect
Expand All @@ -139,5 +140,4 @@ require (
k8s.io/legacy-cloud-providers v0.21.0 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
14 changes: 3 additions & 11 deletions pkg/controller.v1beta1/suggestion/composer/composer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package composer

import (
"context"
"encoding/json"
"fmt"
stdlog "log"
"os"
Expand All @@ -31,7 +30,6 @@ import (

"github.com/onsi/gomega"
"github.com/spf13/viper"
"gopkg.in/yaml.v3"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
Expand All @@ -45,6 +43,7 @@ import (
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/yaml"

configv1beta1 "github.com/kubeflow/katib/pkg/apis/config/v1beta1"
apis "github.com/kubeflow/katib/pkg/apis/controller"
Expand Down Expand Up @@ -705,15 +704,8 @@ func newFakeKatibConfig(suggestionConfig configv1beta1.SuggestionConfig, earlySt
},
},
}
bKatibConfig, err := json.Marshal(katibConfig)
if err != nil {
stdlog.Fatal(err)
}
yamlKatibConfig := make(map[string]interface{})
if err = yaml.Unmarshal(bKatibConfig, yamlKatibConfig); err != nil {
stdlog.Fatal(err)
}
bKatibConfig, err = yaml.Marshal(yamlKatibConfig)

bKatibConfig, err := yaml.Marshal(katibConfig)
if err != nil {
stdlog.Fatal(err)
}
Expand Down
13 changes: 2 additions & 11 deletions pkg/controller.v1beta1/suggestion/suggestion_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ limitations under the License.
package suggestion

import (
"encoding/json"
"fmt"
stdlog "log"
"sigs.k8s.io/yaml"
"strings"
"sync"
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/onsi/gomega"
"gopkg.in/yaml.v3"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
Expand Down Expand Up @@ -455,15 +454,7 @@ func newKatibConfigMapInstance() *corev1.ConfigMap {
},
},
}
bKatibConfig, err := json.Marshal(katibConfig)
if err != nil {
stdlog.Fatal(err)
}
yamlKatibConfig := make(map[string]interface{})
if err = yaml.Unmarshal(bKatibConfig, yamlKatibConfig); err != nil {
stdlog.Fatal(err)
}
bKatibConfig, err = yaml.Marshal(yamlKatibConfig)
bKatibConfig, err := yaml.Marshal(katibConfig)
if err != nil {
stdlog.Fatal(err)
}
Expand Down
13 changes: 2 additions & 11 deletions pkg/util/v1beta1/katibconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ limitations under the License.
package katibconfig

import (
"encoding/json"
"log"
"os"
"path/filepath"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -35,6 +33,7 @@ import (
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/yaml"

configv1beta1 "github.com/kubeflow/katib/pkg/apis/config/v1beta1"
commonv1beta1 "github.com/kubeflow/katib/pkg/apis/controller/common/v1beta1"
Expand Down Expand Up @@ -483,15 +482,7 @@ func newFakeKatibConfigMap(config *configv1beta1.KatibConfig) *corev1.ConfigMap

data := map[string]string{}
if config != nil {
bKatibConfig, err := json.Marshal(config)
if err != nil {
log.Fatal(err)
}
yamlKatibConfig := make(map[string]interface{})
if err = yaml.Unmarshal(bKatibConfig, yamlKatibConfig); err != nil {
log.Fatal(err)
}
bKatibConfig, err = yaml.Marshal(yamlKatibConfig)
bKatibConfig, err := yaml.Marshal(config)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 20a1723

Please sign in to comment.