chore: update to latest api
This commit is contained in:
parent
5a757074ea
commit
1bcf592fcf
5 changed files with 120 additions and 119 deletions
|
@ -1,11 +1,11 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import rpcv1 "code.icb4dc0.de/buildr/api/generated/rpc/v1"
|
import commonv1 "code.icb4dc0.de/buildr/api/generated/common/v1"
|
||||||
|
|
||||||
type SpecUnmarshaler interface {
|
type SpecUnmarshaler interface {
|
||||||
UnmarshalModuleSpec(val *rpcv1.ModuleSpec) error
|
UnmarshalModuleSpec(val *commonv1.ModuleSpec) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type SpecValueUnmarshaler interface {
|
type SpecValueUnmarshaler interface {
|
||||||
UnmarshalSpecValue(val *rpcv1.ModuleSpec_Value) error
|
UnmarshalSpecValue(val *commonv1.ModuleSpec_Value) error
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
rpcv1 "code.icb4dc0.de/buildr/api/generated/rpc/v1"
|
commonv1 "code.icb4dc0.de/buildr/api/generated/common/v1"
|
||||||
|
rpcv1 "code.icb4dc0.de/buildr/api/generated/common/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrExpectedStruct = errors.New("expected struct")
|
var ErrExpectedStruct = errors.New("expected struct")
|
||||||
|
@ -15,7 +16,7 @@ type marshalConfigOption interface {
|
||||||
applyToMarshalConfig(cfg *marshalConfig)
|
applyToMarshalConfig(cfg *marshalConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Marshal(in any, opts ...marshalConfigOption) (*rpcv1.ModuleSpec, error) {
|
func Marshal(in any, opts ...marshalConfigOption) (*commonv1.ModuleSpec, error) {
|
||||||
cfg := marshalConfig{
|
cfg := marshalConfig{
|
||||||
protocolConfig: defaultConfig(),
|
protocolConfig: defaultConfig(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package protocol_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
rpcv1 "code.icb4dc0.de/buildr/api/generated/rpc/v1"
|
commonv1 "code.icb4dc0.de/buildr/api/generated/common/v1"
|
||||||
"code.icb4dc0.de/buildr/common/protocol"
|
"code.icb4dc0.de/buildr/common/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ func TestMarshal_Bool_Success(t *testing.T) {
|
||||||
t.Fatal("IsDeleted not found")
|
t.Fatal("IsDeleted not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if nameVal.Type != rpcv1.ModuleSpec_ValueTypeSingle {
|
if nameVal.Type != commonv1.ModuleSpec_ValueTypeSingle {
|
||||||
t.Fatalf("Expected single value type, got %v", nameVal.Type)
|
t.Fatalf("Expected single value type, got %v", nameVal.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s, ok := nameVal.SingleValue.(*rpcv1.ModuleSpec_Value_BoolValue); !ok {
|
if s, ok := nameVal.SingleValue.(*commonv1.ModuleSpec_Value_BoolValue); !ok {
|
||||||
t.Fatalf("Expected string value, got %v", nameVal.SingleValue)
|
t.Fatalf("Expected string value, got %v", nameVal.SingleValue)
|
||||||
} else if !s.BoolValue {
|
} else if !s.BoolValue {
|
||||||
t.Errorf("Expected bool value to be true, got %t", s.BoolValue)
|
t.Errorf("Expected bool value to be true, got %t", s.BoolValue)
|
||||||
|
@ -52,7 +52,7 @@ func TestMarshal_BoolSlice_Success(t *testing.T) {
|
||||||
t.Fatal("IsDeleted not found")
|
t.Fatal("IsDeleted not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if nameVal.Type != rpcv1.ModuleSpec_ValueTypeBoolSlice {
|
if nameVal.Type != commonv1.ModuleSpec_ValueTypeBoolSlice {
|
||||||
t.Fatalf("Expected bool slice value type, got %v", nameVal.Type)
|
t.Fatalf("Expected bool slice value type, got %v", nameVal.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,11 +82,11 @@ func TestMarshal_Int_Success(t *testing.T) {
|
||||||
t.Fatal("Age not found")
|
t.Fatal("Age not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if nameVal.Type != rpcv1.ModuleSpec_ValueTypeSingle {
|
if nameVal.Type != commonv1.ModuleSpec_ValueTypeSingle {
|
||||||
t.Fatalf("Expected single value type, got %v", nameVal.Type)
|
t.Fatalf("Expected single value type, got %v", nameVal.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s, ok := nameVal.SingleValue.(*rpcv1.ModuleSpec_Value_IntValue); !ok {
|
if s, ok := nameVal.SingleValue.(*commonv1.ModuleSpec_Value_IntValue); !ok {
|
||||||
t.Fatalf("Expected string value, got %v", nameVal.SingleValue)
|
t.Fatalf("Expected string value, got %v", nameVal.SingleValue)
|
||||||
} else if s.IntValue != 42 {
|
} else if s.IntValue != 42 {
|
||||||
t.Errorf("Expected int value to be 42, got %d", s.IntValue)
|
t.Errorf("Expected int value to be 42, got %d", s.IntValue)
|
||||||
|
@ -110,7 +110,7 @@ func TestMarshal_IntSlice_Success(t *testing.T) {
|
||||||
t.Fatal("Ages not found")
|
t.Fatal("Ages not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if nameVal.Type != rpcv1.ModuleSpec_ValueTypeIntSlice {
|
if nameVal.Type != commonv1.ModuleSpec_ValueTypeIntSlice {
|
||||||
t.Fatalf("Expected int slice value type, got %v", nameVal.Type)
|
t.Fatalf("Expected int slice value type, got %v", nameVal.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,11 +140,11 @@ func TestMarshal_StringField_Success(t *testing.T) {
|
||||||
t.Fatal("Name not found")
|
t.Fatal("Name not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if nameVal.Type != rpcv1.ModuleSpec_ValueTypeSingle {
|
if nameVal.Type != commonv1.ModuleSpec_ValueTypeSingle {
|
||||||
t.Fatalf("Expected single value type, got %v", nameVal.Type)
|
t.Fatalf("Expected single value type, got %v", nameVal.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s, ok := nameVal.SingleValue.(*rpcv1.ModuleSpec_Value_StringValue); !ok {
|
if s, ok := nameVal.SingleValue.(*commonv1.ModuleSpec_Value_StringValue); !ok {
|
||||||
t.Fatalf("Expected string value, got %v", nameVal.SingleValue)
|
t.Fatalf("Expected string value, got %v", nameVal.SingleValue)
|
||||||
} else if s.StringValue != "John Doe" {
|
} else if s.StringValue != "John Doe" {
|
||||||
t.Errorf("Expected string value to be John Doe, got %s", s.StringValue)
|
t.Errorf("Expected string value to be John Doe, got %s", s.StringValue)
|
||||||
|
@ -168,11 +168,11 @@ func TestMarshal_Float64_Success(t *testing.T) {
|
||||||
t.Fatal("Pi not found")
|
t.Fatal("Pi not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if nameVal.Type != rpcv1.ModuleSpec_ValueTypeSingle {
|
if nameVal.Type != commonv1.ModuleSpec_ValueTypeSingle {
|
||||||
t.Fatalf("Expected single value type, got %v", nameVal.Type)
|
t.Fatalf("Expected single value type, got %v", nameVal.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s, ok := nameVal.SingleValue.(*rpcv1.ModuleSpec_Value_DoubleValue); !ok {
|
if s, ok := nameVal.SingleValue.(*commonv1.ModuleSpec_Value_DoubleValue); !ok {
|
||||||
t.Fatalf("Expected double value, got %v", nameVal.SingleValue)
|
t.Fatalf("Expected double value, got %v", nameVal.SingleValue)
|
||||||
} else if s.DoubleValue-3.14 > 0.000001 {
|
} else if s.DoubleValue-3.14 > 0.000001 {
|
||||||
t.Errorf("Expected double value to be 3.14, got %f", s.DoubleValue)
|
t.Errorf("Expected double value to be 3.14, got %f", s.DoubleValue)
|
||||||
|
@ -201,7 +201,7 @@ func TestMarshal_NestedStruct_Success(t *testing.T) {
|
||||||
t.Fatal("Address not found")
|
t.Fatal("Address not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if addressVal.Type != rpcv1.ModuleSpec_ValueTypeObject {
|
if addressVal.Type != commonv1.ModuleSpec_ValueTypeObject {
|
||||||
t.Fatalf("Expected object value type, got %v", addressVal.Type)
|
t.Fatalf("Expected object value type, got %v", addressVal.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,11 +210,11 @@ func TestMarshal_NestedStruct_Success(t *testing.T) {
|
||||||
t.Fatal("City not found")
|
t.Fatal("City not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cityVal.Type != rpcv1.ModuleSpec_ValueTypeSingle {
|
if cityVal.Type != commonv1.ModuleSpec_ValueTypeSingle {
|
||||||
t.Fatalf("Expected single value type, got %v", cityVal.Type)
|
t.Fatalf("Expected single value type, got %v", cityVal.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cityVal.SingleValue.(*rpcv1.ModuleSpec_Value_StringValue).StringValue != "New York" {
|
if cityVal.SingleValue.(*commonv1.ModuleSpec_Value_StringValue).StringValue != "New York" {
|
||||||
t.Errorf("Expected string value to be New York, got %s", cityVal.SingleValue.(*rpcv1.ModuleSpec_Value_StringValue).StringValue)
|
t.Errorf("Expected string value to be New York, got %s", cityVal.SingleValue.(*commonv1.ModuleSpec_Value_StringValue).StringValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
rpcv1 "code.icb4dc0.de/buildr/api/generated/rpc/v1"
|
commonv1 "code.icb4dc0.de/buildr/api/generated/common/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrUnmatchingType = errors.New("field type does not match wire value")
|
var ErrUnmatchingType = errors.New("field type does not match wire value")
|
||||||
|
@ -15,7 +15,7 @@ type unmarshalConfigOption interface {
|
||||||
applyToUnmarshalConfig(cfg *unmarshalConfig)
|
applyToUnmarshalConfig(cfg *unmarshalConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Unmarshal(input *rpcv1.ModuleSpec, into any, opts ...unmarshalConfigOption) error {
|
func Unmarshal(input *commonv1.ModuleSpec, into any, opts ...unmarshalConfigOption) error {
|
||||||
if u, ok := into.(SpecUnmarshaler); ok {
|
if u, ok := into.(SpecUnmarshaler); ok {
|
||||||
return u.UnmarshalModuleSpec(input)
|
return u.UnmarshalModuleSpec(input)
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ type unmarshalConfig struct {
|
||||||
protocolConfig
|
protocolConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg unmarshalConfig) unmarshal(input map[string]*rpcv1.ModuleSpec_Value, into reflect.Value, intoType reflect.Type) error {
|
func (cfg unmarshalConfig) unmarshal(input map[string]*commonv1.ModuleSpec_Value, into reflect.Value, intoType reflect.Type) error {
|
||||||
for i := 0; i < intoType.NumField(); i++ {
|
for i := 0; i < intoType.NumField(); i++ {
|
||||||
tf := intoType.Field(i)
|
tf := intoType.Field(i)
|
||||||
if !tf.IsExported() {
|
if !tf.IsExported() {
|
||||||
|
@ -82,11 +82,11 @@ func (cfg unmarshalConfig) unmarshal(input map[string]*rpcv1.ModuleSpec_Value, i
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg unmarshalConfig) mapSpecValueTo(val *rpcv1.ModuleSpec_Value, targetType reflect.Type) (reflect.Value, error) {
|
func (cfg unmarshalConfig) mapSpecValueTo(val *commonv1.ModuleSpec_Value, targetType reflect.Type) (reflect.Value, error) {
|
||||||
switch val.Type {
|
switch val.Type {
|
||||||
case rpcv1.ModuleSpec_ValueTypeUnknown:
|
case commonv1.ModuleSpec_ValueTypeUnknown:
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected %s", ErrUnmatchingType, targetType.String())
|
return reflect.Value{}, fmt.Errorf("%w: expected %s", ErrUnmatchingType, targetType.String())
|
||||||
case rpcv1.ModuleSpec_ValueTypeObject:
|
case commonv1.ModuleSpec_ValueTypeObject:
|
||||||
if targetType.Kind() == reflect.Struct {
|
if targetType.Kind() == reflect.Struct {
|
||||||
structVal := reflect.New(targetType)
|
structVal := reflect.New(targetType)
|
||||||
if err := cfg.unmarshal(val.ComplexValue, structVal, targetType); err != nil {
|
if err := cfg.unmarshal(val.ComplexValue, structVal, targetType); err != nil {
|
||||||
|
@ -104,7 +104,7 @@ func (cfg unmarshalConfig) mapSpecValueTo(val *rpcv1.ModuleSpec_Value, targetTyp
|
||||||
} else {
|
} else {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected struct, got %s", ErrUnmatchingType, val.Type)
|
return reflect.Value{}, fmt.Errorf("%w: expected struct, got %s", ErrUnmatchingType, val.Type)
|
||||||
}
|
}
|
||||||
case rpcv1.ModuleSpec_ValueTypeMap:
|
case commonv1.ModuleSpec_ValueTypeMap:
|
||||||
if targetType.Kind() != reflect.Map {
|
if targetType.Kind() != reflect.Map {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected map, got %v", ErrUnmatchingType, targetType)
|
return reflect.Value{}, fmt.Errorf("%w: expected map, got %v", ErrUnmatchingType, targetType)
|
||||||
}
|
}
|
||||||
|
@ -121,44 +121,44 @@ func (cfg unmarshalConfig) mapSpecValueTo(val *rpcv1.ModuleSpec_Value, targetTyp
|
||||||
|
|
||||||
return mapVal, nil
|
return mapVal, nil
|
||||||
|
|
||||||
case rpcv1.ModuleSpec_ValueTypeSingle:
|
case commonv1.ModuleSpec_ValueTypeSingle:
|
||||||
switch sv := val.SingleValue.(type) {
|
switch sv := val.SingleValue.(type) {
|
||||||
case *rpcv1.ModuleSpec_Value_BoolValue:
|
case *commonv1.ModuleSpec_Value_BoolValue:
|
||||||
if targetType.Kind() != reflect.Bool {
|
if targetType.Kind() != reflect.Bool {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected bool, got %v", ErrUnmatchingType, targetType)
|
return reflect.Value{}, fmt.Errorf("%w: expected bool, got %v", ErrUnmatchingType, targetType)
|
||||||
}
|
}
|
||||||
return reflect.ValueOf(sv.BoolValue), nil
|
return reflect.ValueOf(sv.BoolValue), nil
|
||||||
case *rpcv1.ModuleSpec_Value_StringValue:
|
case *commonv1.ModuleSpec_Value_StringValue:
|
||||||
if targetType.Kind() != reflect.String {
|
if targetType.Kind() != reflect.String {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected string, got %v", ErrUnmatchingType, targetType)
|
return reflect.Value{}, fmt.Errorf("%w: expected string, got %v", ErrUnmatchingType, targetType)
|
||||||
}
|
}
|
||||||
return reflect.ValueOf(sv.StringValue), nil
|
return reflect.ValueOf(sv.StringValue), nil
|
||||||
case *rpcv1.ModuleSpec_Value_IntValue:
|
case *commonv1.ModuleSpec_Value_IntValue:
|
||||||
if targetType.Kind() != reflect.Int {
|
if targetType.Kind() != reflect.Int {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected int, got %v", ErrUnmatchingType, targetType)
|
return reflect.Value{}, fmt.Errorf("%w: expected int, got %v", ErrUnmatchingType, targetType)
|
||||||
}
|
}
|
||||||
return reflect.ValueOf(int(sv.IntValue)), nil
|
return reflect.ValueOf(int(sv.IntValue)), nil
|
||||||
case *rpcv1.ModuleSpec_Value_DoubleValue:
|
case *commonv1.ModuleSpec_Value_DoubleValue:
|
||||||
if targetType.Kind() != reflect.Float64 {
|
if targetType.Kind() != reflect.Float64 {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected float64, got %v", ErrUnmatchingType, targetType)
|
return reflect.Value{}, fmt.Errorf("%w: expected float64, got %v", ErrUnmatchingType, targetType)
|
||||||
}
|
}
|
||||||
return reflect.ValueOf(sv.DoubleValue), nil
|
return reflect.ValueOf(sv.DoubleValue), nil
|
||||||
}
|
}
|
||||||
case rpcv1.ModuleSpec_ValueTypeBoolSlice:
|
case commonv1.ModuleSpec_ValueTypeBoolSlice:
|
||||||
if targetType.Kind() != reflect.Slice {
|
if targetType.Kind() != reflect.Slice {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType)
|
return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType)
|
||||||
} else if targetType.Elem().Kind() != reflect.Bool {
|
} else if targetType.Elem().Kind() != reflect.Bool {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected bool, got %v", ErrUnmatchingType, targetType.Elem())
|
return reflect.Value{}, fmt.Errorf("%w: expected bool, got %v", ErrUnmatchingType, targetType.Elem())
|
||||||
}
|
}
|
||||||
return reflect.ValueOf(val.BoolValues), nil
|
return reflect.ValueOf(val.BoolValues), nil
|
||||||
case rpcv1.ModuleSpec_ValueTypeStringSlice:
|
case commonv1.ModuleSpec_ValueTypeStringSlice:
|
||||||
if targetType.Kind() != reflect.Slice {
|
if targetType.Kind() != reflect.Slice {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType)
|
return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType)
|
||||||
} else if targetType.Elem().Kind() != reflect.String {
|
} else if targetType.Elem().Kind() != reflect.String {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected string, got %v", ErrUnmatchingType, targetType.Elem())
|
return reflect.Value{}, fmt.Errorf("%w: expected string, got %v", ErrUnmatchingType, targetType.Elem())
|
||||||
}
|
}
|
||||||
return reflect.ValueOf(val.StringValues), nil
|
return reflect.ValueOf(val.StringValues), nil
|
||||||
case rpcv1.ModuleSpec_ValueTypeIntSlice:
|
case commonv1.ModuleSpec_ValueTypeIntSlice:
|
||||||
if targetType.Kind() != reflect.Slice {
|
if targetType.Kind() != reflect.Slice {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType)
|
return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType)
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ func (cfg unmarshalConfig) mapSpecValueTo(val *rpcv1.ModuleSpec_Value, targetTyp
|
||||||
default:
|
default:
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected int, got %v", ErrUnmatchingType, targetType.Elem())
|
return reflect.Value{}, fmt.Errorf("%w: expected int, got %v", ErrUnmatchingType, targetType.Elem())
|
||||||
}
|
}
|
||||||
case rpcv1.ModuleSpec_ValueTypeDoubleSlice:
|
case commonv1.ModuleSpec_ValueTypeDoubleSlice:
|
||||||
if targetType.Kind() != reflect.Slice {
|
if targetType.Kind() != reflect.Slice {
|
||||||
return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType)
|
return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package protocol_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
rpcv1 "code.icb4dc0.de/buildr/api/generated/rpc/v1"
|
commonv1 "code.icb4dc0.de/buildr/api/generated/common/v1"
|
||||||
"code.icb4dc0.de/buildr/common/protocol"
|
"code.icb4dc0.de/buildr/common/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@ func TestUnmarshal_Bool_Success(t *testing.T) {
|
||||||
Delete bool
|
Delete bool
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"delete": {
|
"delete": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_BoolValue{
|
SingleValue: &commonv1.ModuleSpec_Value_BoolValue{
|
||||||
BoolValue: true,
|
BoolValue: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -37,11 +37,11 @@ func TestUnmarshal_Bool_Err(t *testing.T) {
|
||||||
Delete string
|
Delete string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"delete": {
|
"delete": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_BoolValue{
|
SingleValue: &commonv1.ModuleSpec_Value_BoolValue{
|
||||||
BoolValue: true,
|
BoolValue: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -60,10 +60,10 @@ func TestUnmarshal_Bool_Slice_Success(t *testing.T) {
|
||||||
Delete []bool
|
Delete []bool
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"delete": {
|
"delete": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeBoolSlice,
|
Type: commonv1.ModuleSpec_ValueTypeBoolSlice,
|
||||||
BoolValues: []bool{true},
|
BoolValues: []bool{true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -85,10 +85,10 @@ func TestUnmarshal_Bool_Slice_Err(t *testing.T) {
|
||||||
Delete []string
|
Delete []string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"delete": {
|
"delete": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeBoolSlice,
|
Type: commonv1.ModuleSpec_ValueTypeBoolSlice,
|
||||||
BoolValues: []bool{true},
|
BoolValues: []bool{true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -106,11 +106,11 @@ func TestUnmarshal_String_Success(t *testing.T) {
|
||||||
Name string
|
Name string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"name": {
|
"name": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_StringValue{
|
SingleValue: &commonv1.ModuleSpec_Value_StringValue{
|
||||||
StringValue: "Ted",
|
StringValue: "Ted",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -131,11 +131,11 @@ func TestUnmarshal_String_Err(t *testing.T) {
|
||||||
Name int
|
Name int
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"name": {
|
"name": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_StringValue{
|
SingleValue: &commonv1.ModuleSpec_Value_StringValue{
|
||||||
StringValue: "Ted",
|
StringValue: "Ted",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -154,10 +154,10 @@ func TestUnmarshal_String_Slice_Success(t *testing.T) {
|
||||||
Names []string
|
Names []string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"names": {
|
"names": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeStringSlice,
|
Type: commonv1.ModuleSpec_ValueTypeStringSlice,
|
||||||
StringValues: []string{"Ted"},
|
StringValues: []string{"Ted"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -179,10 +179,10 @@ func TestUnmarshal_String_Slice_Err(t *testing.T) {
|
||||||
Names []int
|
Names []int
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"names": {
|
"names": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeStringSlice,
|
Type: commonv1.ModuleSpec_ValueTypeStringSlice,
|
||||||
StringValues: []string{"Ted"},
|
StringValues: []string{"Ted"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -200,11 +200,11 @@ func TestUnmarshal_Int_Success(t *testing.T) {
|
||||||
Age int
|
Age int
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"age": {
|
"age": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_IntValue{
|
SingleValue: &commonv1.ModuleSpec_Value_IntValue{
|
||||||
IntValue: 42,
|
IntValue: 42,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -225,11 +225,11 @@ func TestUnmarshal_Int_Err(t *testing.T) {
|
||||||
Age string
|
Age string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"age": {
|
"age": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_IntValue{
|
SingleValue: &commonv1.ModuleSpec_Value_IntValue{
|
||||||
IntValue: 42,
|
IntValue: 42,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -248,10 +248,10 @@ func TestUnmarshal_Int_Slice_Success(t *testing.T) {
|
||||||
Ages []int
|
Ages []int
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"ages": {
|
"ages": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeIntSlice,
|
Type: commonv1.ModuleSpec_ValueTypeIntSlice,
|
||||||
IntValues: []int64{42},
|
IntValues: []int64{42},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -273,10 +273,10 @@ func TestUnmarshal_Int_Slice_Err(t *testing.T) {
|
||||||
Ages []string
|
Ages []string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"ages": {
|
"ages": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeIntSlice,
|
Type: commonv1.ModuleSpec_ValueTypeIntSlice,
|
||||||
IntValues: []int64{42},
|
IntValues: []int64{42},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -294,11 +294,11 @@ func TestUnmarshal_Double_Success(t *testing.T) {
|
||||||
Pi float64
|
Pi float64
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"Pi": {
|
"Pi": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_DoubleValue{
|
SingleValue: &commonv1.ModuleSpec_Value_DoubleValue{
|
||||||
DoubleValue: 3.14,
|
DoubleValue: 3.14,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -319,11 +319,11 @@ func TestUnmarshal_Double_Err(t *testing.T) {
|
||||||
Pi string
|
Pi string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"pi": {
|
"pi": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_DoubleValue{
|
SingleValue: &commonv1.ModuleSpec_Value_DoubleValue{
|
||||||
DoubleValue: 3.14,
|
DoubleValue: 3.14,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -342,10 +342,10 @@ func TestUnmarshal_Double_Slice_Success(t *testing.T) {
|
||||||
Pis []float64
|
Pis []float64
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"pis": {
|
"pis": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeDoubleSlice,
|
Type: commonv1.ModuleSpec_ValueTypeDoubleSlice,
|
||||||
DoubleValues: []float64{3.14},
|
DoubleValues: []float64{3.14},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -367,10 +367,10 @@ func TestUnmarshal_Double_Slice_Err(t *testing.T) {
|
||||||
Pis []string
|
Pis []string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"pis": {
|
"pis": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeDoubleSlice,
|
Type: commonv1.ModuleSpec_ValueTypeDoubleSlice,
|
||||||
DoubleValues: []float64{3.14},
|
DoubleValues: []float64{3.14},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -390,14 +390,14 @@ func TestUnmarshal_NestedStruct_Success(t *testing.T) {
|
||||||
}
|
}
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"address": {
|
"address": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeObject,
|
Type: commonv1.ModuleSpec_ValueTypeObject,
|
||||||
ComplexValue: map[string]*rpcv1.ModuleSpec_Value{
|
ComplexValue: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"city": {
|
"city": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_StringValue{
|
SingleValue: &commonv1.ModuleSpec_Value_StringValue{
|
||||||
StringValue: "New York",
|
StringValue: "New York",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -422,14 +422,14 @@ func TestUnmarshal_NestedStructPointer_Success(t *testing.T) {
|
||||||
}
|
}
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"address": {
|
"address": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeObject,
|
Type: commonv1.ModuleSpec_ValueTypeObject,
|
||||||
ComplexValue: map[string]*rpcv1.ModuleSpec_Value{
|
ComplexValue: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"city": {
|
"city": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_StringValue{
|
SingleValue: &commonv1.ModuleSpec_Value_StringValue{
|
||||||
StringValue: "New York",
|
StringValue: "New York",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -452,14 +452,14 @@ func TestUnmarshal_Map_Success(t *testing.T) {
|
||||||
Values map[string]string
|
Values map[string]string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"values": {
|
"values": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeMap,
|
Type: commonv1.ModuleSpec_ValueTypeMap,
|
||||||
ComplexValue: map[string]*rpcv1.ModuleSpec_Value{
|
ComplexValue: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"City": {
|
"City": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_StringValue{
|
SingleValue: &commonv1.ModuleSpec_Value_StringValue{
|
||||||
StringValue: "New York",
|
StringValue: "New York",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -484,17 +484,17 @@ func TestUnmarshal_NestedMap_Success(t *testing.T) {
|
||||||
}
|
}
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
spec := &rpcv1.ModuleSpec{
|
spec := &commonv1.ModuleSpec{
|
||||||
Values: map[string]*rpcv1.ModuleSpec_Value{
|
Values: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"city": {
|
"city": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeObject,
|
Type: commonv1.ModuleSpec_ValueTypeObject,
|
||||||
ComplexValue: map[string]*rpcv1.ModuleSpec_Value{
|
ComplexValue: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"labels": {
|
"labels": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeMap,
|
Type: commonv1.ModuleSpec_ValueTypeMap,
|
||||||
ComplexValue: map[string]*rpcv1.ModuleSpec_Value{
|
ComplexValue: map[string]*commonv1.ModuleSpec_Value{
|
||||||
"Region": {
|
"Region": {
|
||||||
Type: rpcv1.ModuleSpec_ValueTypeSingle,
|
Type: commonv1.ModuleSpec_ValueTypeSingle,
|
||||||
SingleValue: &rpcv1.ModuleSpec_Value_StringValue{
|
SingleValue: &commonv1.ModuleSpec_Value_StringValue{
|
||||||
StringValue: "west",
|
StringValue: "west",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue