diff --git a/lib/services/crown_jewel.go b/lib/services/crown_jewel.go index 485028413dd82..fdcab9dcb4e2c 100644 --- a/lib/services/crown_jewel.go +++ b/lib/services/crown_jewel.go @@ -22,11 +22,11 @@ import ( "context" "github.com/gravitational/trace" + "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" crownjewelv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/crownjewel/v1" - "github.com/gravitational/teleport/lib/utils" ) // CrownJewels is the interface for managing crown jewel resources. @@ -57,7 +57,7 @@ func MarshalCrownJewel(object *crownjewelv1.CrownJewel, opts ...MarshalOption) ( object = proto.Clone(object).(*crownjewelv1.CrownJewel) object.Metadata.Revision = "" } - data, err := utils.FastMarshal(object) + data, err := protojson.Marshal(object) if err != nil { return nil, trace.Wrap(err) } @@ -74,7 +74,7 @@ func UnmarshalCrownJewel(data []byte, opts ...MarshalOption) (*crownjewelv1.Crow return nil, trace.Wrap(err) } var obj crownjewelv1.CrownJewel - if err := utils.FastUnmarshal(data, &obj); err != nil { + if err := protojson.Unmarshal(data, &obj); err != nil { return nil, trace.BadParameter(err.Error()) } if cfg.Revision != "" { diff --git a/lib/services/crown_jewels_test.go b/lib/services/crown_jewels_test.go index 75a1821e240d7..62f579ea11f47 100644 --- a/lib/services/crown_jewels_test.go +++ b/lib/services/crown_jewels_test.go @@ -95,7 +95,7 @@ func TestUnmarshalCrownJewel(t *testing.T) { obj, err := UnmarshalCrownJewel(data) require.NoError(t, err) - require.Equal(t, expected, obj) + require.True(t, proto.Equal(expected, obj), "CrownJewel objects are not equal") } const correctCrownJewelYAML = ` @@ -112,7 +112,7 @@ spec: tags: - key: env values: - - value: prod + - prod types: - ec2 teleport_matchers: