Skip to content

Commit 54654da

Browse files
author
Paddy Carver
committed
Discourage the use of our marshaling types.
Deprecate our Marshal* and Unmarshal* functions to discourage third-party callers from relying on them. This is a temporary solution; we should refactor to make these not exported, if we can.
1 parent e227023 commit 54654da

File tree

12 files changed

+23
-5
lines changed

12 files changed

+23
-5
lines changed

tfprotov5/dynamic_value.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ var ErrUnknownDynamicValueType = errors.New("DynamicValue had no JSON or msgpack
2626
// that is compatible with the Type of the Value. Usually it should just be the
2727
// Type of the Value, but it can also be the DynamicPseudoType.
2828
func NewDynamicValue(t tftypes.Type, v tftypes.Value) (DynamicValue, error) {
29-
b, err := v.MarshalMsgPack(t)
29+
b, err := v.MarshalMsgPack(t) //nolint:staticcheck
30+
//
31+
// Deprecated: this is not meant to be called by third-party code.
3032
if err != nil {
3133
return DynamicValue{}, err
3234
}

tfprotov5/dynamic_value_json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func jsonUnmarshalDynamicPseudoType(buf []byte, typ tftypes.Type, p tftypes.Attr
126126
}
127127
switch key {
128128
case "type":
129-
t, err = tftypes.ParseJSONType(rawVal)
129+
t, err = tftypes.ParseJSONType(rawVal) //nolint:staticcheck
130130
if err != nil {
131131
return tftypes.Value{}, p.NewErrorf("error decoding type information: %w", err)
132132
}

tfprotov5/dynamic_value_msgpack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func msgpackUnmarshalDynamic(dec *msgpack.Decoder, path tftypes.AttributePath) (
306306
if err != nil {
307307
return tftypes.Value{}, path.NewErrorf("error decoding bytes: %w", err)
308308
}
309-
typ, err := tftypes.ParseJSONType(typeJSON)
309+
typ, err := tftypes.ParseJSONType(typeJSON) //nolint:staticcheck
310310
if err != nil {
311311
return tftypes.Value{}, path.NewErrorf("error parsing type information: %w", err)
312312
}

tfprotov5/internal/fromproto/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func SchemaAttribute(in *tfplugin5.Schema_Attribute) (*tfprotov5.SchemaAttribute
5252
DescriptionKind: StringKind(in.DescriptionKind),
5353
Deprecated: in.Deprecated,
5454
}
55-
typ, err := tftypes.ParseJSONType(in.Type)
55+
typ, err := tftypes.ParseJSONType(in.Type) //nolint:staticcheck
5656
if err != nil {
5757
return resp, err
5858
}

tfprotov5/internal/toproto/dynamic_value.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tfprotov5/tftypes/list.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ func (l List) private() {}
3131

3232
// MarshalJSON returns a JSON representation of the full type signature of `l`,
3333
// including its ElementType.
34+
//
35+
// Deprecated: this is not meant to be called by third-party code.
3436
func (l List) MarshalJSON() ([]byte, error) {
3537
elementType, err := l.ElementType.MarshalJSON()
3638
if err != nil {

tfprotov5/tftypes/map.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ func (m Map) private() {}
3030

3131
// MarshalJSON returns a JSON representation of the full type signature of `m`,
3232
// including its AttributeType.
33+
//
34+
// Deprecated: this is not meant to be called by third-party code.
3335
func (m Map) MarshalJSON() ([]byte, error) {
3436
attributeType, err := m.AttributeType.MarshalJSON()
3537
if err != nil {

tfprotov5/tftypes/object.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func (o Object) private() {}
4545

4646
// MarshalJSON returns a JSON representation of the full type signature of `o`,
4747
// including the AttributeTypes.
48+
//
49+
// Deprecated: this is not meant to be called by third-party code.
4850
func (o Object) MarshalJSON() ([]byte, error) {
4951
attrs, err := json.Marshal(o.AttributeTypes)
5052
if err != nil {

tfprotov5/tftypes/set.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ func (s Set) private() {}
3131

3232
// MarshalJSON returns a JSON representation of the full type signature of `s`,
3333
// including its ElementType.
34+
//
35+
// Deprecated: this is not meant to be called by third-party code.
3436
func (s Set) MarshalJSON() ([]byte, error) {
3537
elementType, err := s.ElementType.MarshalJSON()
3638
if err != nil {

tfprotov5/tftypes/tuple.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ func (tu Tuple) private() {}
4242

4343
// MarshalJSON returns a JSON representation of the full type signature of
4444
// `tu`, including the ElementTypes.
45+
//
46+
// Deprecated: this is not meant to be called by third-party code.
4547
func (tu Tuple) MarshalJSON() ([]byte, error) {
4648
elements, err := json.Marshal(tu.ElementTypes)
4749
if err != nil {

0 commit comments

Comments
 (0)