Skip to content

Commit

Permalink
Switch to sigs.k8s.io/yaml to correctly serialize/deserialize objects
Browse files Browse the repository at this point in the history
Previous yaml package gopkg.in/yaml.v2 does not support json tags on
fields. Switch to a yaml package that can correctly
serialize/deserialize devfile/api objects.

Signed-off-by: Angel Misevski <[email protected]>
  • Loading branch information
amisevsk committed Nov 4, 2020
1 parent 11fef57 commit 52854ef
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion controllers/workspace/restapis/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import (
"github.com/devfile/devworkspace-operator/pkg/config"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"gopkg.in/yaml.v2"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8sRuntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
runtimeClient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/yaml"
)

var configmapDiffOpts = cmp.Options{
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/devfile/api v0.0.0-20200826083800-9e2280a95680
github.com/eclipse/che-go-jsonrpc v0.0.0-20200317130110-931966b891fe // indirect
github.com/eclipse/che-plugin-broker v3.4.0+incompatible
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-logr/logr v0.1.0
github.com/google/go-cmp v0.4.0
github.com/google/uuid v1.1.1
Expand All @@ -16,11 +15,11 @@ require (
github.com/openshift/api v0.0.0-20200205133042-34f0ec8dab87
github.com/operator-framework/operator-sdk v0.17.0
github.com/stretchr/testify v1.6.1
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.18.6
k8s.io/apimachinery v0.18.6
k8s.io/client-go v12.0.0+incompatible
sigs.k8s.io/controller-runtime v0.6.2
sigs.k8s.io/yaml v1.2.0
)

// devfile/api requires v12.0.0+incompatible but this causes issues with go commands
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/cmd_terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha1"

"gopkg.in/yaml.v2"
"sigs.k8s.io/yaml"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal_registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (

"github.com/eclipse/che-plugin-broker/model"
brokerModel "github.com/eclipse/che-plugin-broker/model"
"gopkg.in/yaml.v2"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/yaml"
)

const (
Expand Down
5 changes: 1 addition & 4 deletions pkg/library/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import (

"github.com/devfile/api/pkg/apis/workspaces/v1alpha1"
"github.com/stretchr/testify/assert"

// ghodss/yaml is required instead of the default gopkg.in/yaml.v2 since the latter
// only supports yaml struct tags and the DevWorkspace API only uses json.
"github.com/ghodss/yaml"
"sigs.k8s.io/yaml"
)

type testCase struct {
Expand Down

0 comments on commit 52854ef

Please sign in to comment.