ceph: remove unnecessary package

We don't need to use github.com/ghodss/yaml since
"k8s.io/apimachinery/pkg/util/yaml" provides the same functionality and
we already import it.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han committed 2021-09-17 16:10:47 +02:00
1 parent 32984f7297
commit 68a4bc2d1b
12 files changed
+26 -27

No files matched your search

-1
View File
@@ -8,7 +8,6 @@ require (
github.com/ceph/go-ceph v0.11.0
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
github.com/csi-addons/volume-replication-operator v0.1.1-0.20210525040814-ab575a2879fb
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-ini/ini v1.51.1
github.com/google/go-cmp v0.5.5
github.com/google/uuid v1.1.2
-1
View File
@@ -441,7 +441,6 @@ github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49P
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 h1:Mn26/9ZMNWSw9C9ERFA1PUxfmGpolnw2v0bKOREu5ew=
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
+2 -2
View File
@@ -20,8 +20,8 @@ import (
"encoding/json"
"testing"
"github.com/ghodss/yaml"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/util/yaml"
)
func TestCephAnnotationsMerge(t *testing.T) {
@@ -80,7 +80,7 @@ mon:
`)
// convert the raw spec yaml into JSON
rawJSON, err := yaml.YAMLToJSON(specYaml)
rawJSON, err := yaml.ToJSON(specYaml)
assert.Nil(t, err)
// unmarshal the JSON into a strongly typed annotations spec object
+2 -2
View File
@@ -20,8 +20,8 @@ import (
"encoding/json"
"testing"
"github.com/ghodss/yaml"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/util/yaml"
)
func TestCephLabelsMerge(t *testing.T) {
@@ -80,7 +80,7 @@ mon:
`)
// convert the raw spec yaml into JSON
rawJSON, err := yaml.YAMLToJSON(specYaml)
rawJSON, err := yaml.ToJSON(specYaml)
assert.Nil(t, err)
// unmarshal the JSON into a strongly typed Labels spec object
+3 -3
View File
@@ -20,14 +20,14 @@ import (
"encoding/json"
"testing"
"github.com/ghodss/yaml"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/util/yaml"
)
func TestNetworkCephSpecLegacy(t *testing.T) {
netSpecYAML := []byte(`hostNetwork: true`)
rawJSON, err := yaml.YAMLToJSON(netSpecYAML)
rawJSON, err := yaml.ToJSON(netSpecYAML)
assert.Nil(t, err)
var net NetworkSpec
@@ -53,7 +53,7 @@ selectors:
server: enp2s0f0
broker: enp2s0f0`)
rawJSON, err := yaml.YAMLToJSON(netSpecYAML)
rawJSON, err := yaml.ToJSON(netSpecYAML)
assert.Nil(t, err)
var net NetworkSpec
+2 -2
View File
@@ -19,10 +19,10 @@ import (
"encoding/json"
"testing"
"github.com/ghodss/yaml"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/yaml"
)
func TestPlacementSpec(t *testing.T) {
@@ -46,7 +46,7 @@ topologySpreadConstraints:
matchLabels:
foo: bar`)
// convert the raw spec yaml into JSON
rawJSON, err := yaml.YAMLToJSON(specYaml)
rawJSON, err := yaml.ToJSON(specYaml)
assert.Nil(t, err)
// unmarshal the JSON into a strongly typed placement spec object
@@ -20,8 +20,8 @@ import (
"encoding/json"
"testing"
"github.com/ghodss/yaml"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/util/yaml"
)
func TestPriorityClassNamesSpec(t *testing.T) {
@@ -33,7 +33,7 @@ osd: osd-class
`)
// convert the raw spec yaml into JSON
rawJSON, err := yaml.YAMLToJSON(specYaml)
rawJSON, err := yaml.ToJSON(specYaml)
assert.Nil(t, err)
// unmarshal the JSON into a strongly typed annotations spec object
+2 -2
View File
@@ -20,8 +20,8 @@ import (
"fmt"
"testing"
"github.com/ghodss/yaml"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/util/yaml"
)
func TestClusterSpecMarshal(t *testing.T) {
@@ -48,7 +48,7 @@ storage:
devicePathFilter: "^/dev/disk/by-id/.*foo.*"`)
// convert the raw spec yaml into JSON
rawJSON, err := yaml.YAMLToJSON(specYaml)
rawJSON, err := yaml.ToJSON(specYaml)
assert.Nil(t, err)
fmt.Printf("rawJSON: %s\n", string(rawJSON))
+7 -7
View File
@@ -22,25 +22,25 @@ import (
"strings"
"text/template"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
"github.com/rook/rook/pkg/operator/ceph/controller"
k8sutil "github.com/rook/rook/pkg/operator/k8sutil"
apps "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/kubernetes"
)
func loadTemplate(name, templateData string, p templateParam) (string, error) {
func loadTemplate(name, templateData string, p templateParam) ([]byte, error) {
var writer bytes.Buffer
t := template.New(name)
t, err := t.Parse(templateData)
if err != nil {
return "", errors.Wrapf(err, "failed to parse template %v", name)
return nil, errors.Wrapf(err, "failed to parse template %v", name)
}
err = t.Execute(&writer, p)
return writer.String(), err
return writer.Bytes(), err
}
func templateToService(name, templateData string, p templateParam) (*corev1.Service, error) {
@@ -50,7 +50,7 @@ func templateToService(name, templateData string, p templateParam) (*corev1.Serv
return nil, errors.Wrap(err, "failed to load service template")
}
err = yaml.Unmarshal([]byte(t), &svc)
err = yaml.Unmarshal(t, &svc)
if err != nil {
return nil, errors.Wrap(err, "failed to unmarshal service template")
}
@@ -64,7 +64,7 @@ func templateToDaemonSet(name, templateData string, p templateParam) (*apps.Daem
return nil, errors.Wrap(err, "failed to load daemonset template")
}
err = yaml.Unmarshal([]byte(t), &ds)
err = yaml.Unmarshal(t, &ds)
if err != nil {
return nil, errors.Wrap(err, "failed to unmarshal daemonset template")
}
@@ -78,7 +78,7 @@ func templateToDeployment(name, templateData string, p templateParam) (*apps.Dep
return nil, errors.Wrap(err, "failed to load deployment template")
}
err = yaml.Unmarshal([]byte(t), &dep)
err = yaml.Unmarshal(t, &dep)
if err != nil {
return nil, errors.Wrap(err, "failed to unmarshal deployment template")
}
+2 -1
View File
@@ -29,8 +29,9 @@ func TestDaemonSetTemplate(t *testing.T) {
Param: CSIParam,
Namespace: "foo",
}
_, err := templateToDaemonSet("test-ds", RBDPluginTemplatePath, tp)
ds, err := templateToDaemonSet("test-ds", RBDPluginTemplatePath, tp)
assert.Nil(t, err)
assert.Equal(t, "driver-registrar", ds.Spec.Template.Spec.Containers[0].Name)
}
func TestDeploymentTemplate(t *testing.T) {
+2 -2
View File
@@ -22,12 +22,12 @@ import (
"encoding/json"
"fmt"
"github.com/ghodss/yaml"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/yaml"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)
@@ -215,7 +215,7 @@ func YamlToContainerResource(raw string) ([]ContainerResource, error) {
if raw == "" {
return resources, nil
}
rawJSON, err := yaml.YAMLToJSON([]byte(raw))
rawJSON, err := yaml.ToJSON([]byte(raw))
if err != nil {
return resources, err
}
+2 -2
View File
@@ -19,8 +19,8 @@ package k8sutil
import (
"encoding/json"
"github.com/ghodss/yaml"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/yaml"
)
// This function takes raw YAML string and converts it to Kubernetes Tolerations array
@@ -29,7 +29,7 @@ func YamlToTolerations(raw string) ([]v1.Toleration, error) {
return []v1.Toleration{}, nil
}
rawJSON, err := yaml.YAMLToJSON([]byte(raw))
rawJSON, err := yaml.ToJSON([]byte(raw))
if err != nil {
return []v1.Toleration{}, err
}