From 7d89ccdb6f11f945317ad8892e1e110a1e0216b4 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 20 Nov 2019 11:08:48 +0300 Subject: [PATCH] rpc: implement YAML marshaling/unmarshaling for StackParamType --- pkg/rpc/stack_param.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/rpc/stack_param.go b/pkg/rpc/stack_param.go index 343a64f9a..907e3e885 100644 --- a/pkg/rpc/stack_param.go +++ b/pkg/rpc/stack_param.go @@ -103,6 +103,23 @@ func (t *StackParamType) UnmarshalJSON(data []byte) (err error) { return } +// MarshalYAML implements the YAML Marshaler interface. +func (t *StackParamType) MarshalYAML() (interface{}, error) { + return t.String(), nil +} + +// UnmarshalYAML implements the YAML Unmarshaler interface. +func (t *StackParamType) UnmarshalYAML(unmarshal func(interface{}) error) error { + var name string + + err := unmarshal(&name) + if err != nil { + return err + } + *t, err = StackParamTypeFromString(name) + return err +} + // StackParam represent a stack parameter. type StackParam struct { Type StackParamType `json:"type"`