diff --git a/protocol/api.go b/protocol/api.go index 8275dbf..ec0e959 100644 --- a/protocol/api.go +++ b/protocol/api.go @@ -1,11 +1,11 @@ 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 { - UnmarshalModuleSpec(val *rpcv1.ModuleSpec) error + UnmarshalModuleSpec(val *commonv1.ModuleSpec) error } type SpecValueUnmarshaler interface { - UnmarshalSpecValue(val *rpcv1.ModuleSpec_Value) error + UnmarshalSpecValue(val *commonv1.ModuleSpec_Value) error } diff --git a/protocol/marshal.go b/protocol/marshal.go index 7cb099a..b998f0b 100644 --- a/protocol/marshal.go +++ b/protocol/marshal.go @@ -6,7 +6,8 @@ import ( "reflect" "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") @@ -15,7 +16,7 @@ type marshalConfigOption interface { applyToMarshalConfig(cfg *marshalConfig) } -func Marshal(in any, opts ...marshalConfigOption) (*rpcv1.ModuleSpec, error) { +func Marshal(in any, opts ...marshalConfigOption) (*commonv1.ModuleSpec, error) { cfg := marshalConfig{ protocolConfig: defaultConfig(), } diff --git a/protocol/marshal_test.go b/protocol/marshal_test.go index 5bba671..cf7902a 100644 --- a/protocol/marshal_test.go +++ b/protocol/marshal_test.go @@ -3,7 +3,7 @@ package protocol_test import ( "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" ) @@ -24,11 +24,11 @@ func TestMarshal_Bool_Success(t *testing.T) { 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) } - 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) } else if !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") } - if nameVal.Type != rpcv1.ModuleSpec_ValueTypeBoolSlice { + if nameVal.Type != commonv1.ModuleSpec_ValueTypeBoolSlice { 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") } - if nameVal.Type != rpcv1.ModuleSpec_ValueTypeSingle { + if nameVal.Type != commonv1.ModuleSpec_ValueTypeSingle { 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) } else if s.IntValue != 42 { 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") } - if nameVal.Type != rpcv1.ModuleSpec_ValueTypeIntSlice { + if nameVal.Type != commonv1.ModuleSpec_ValueTypeIntSlice { 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") } - if nameVal.Type != rpcv1.ModuleSpec_ValueTypeSingle { + if nameVal.Type != commonv1.ModuleSpec_ValueTypeSingle { 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) } else if s.StringValue != "John Doe" { 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") } - if nameVal.Type != rpcv1.ModuleSpec_ValueTypeSingle { + if nameVal.Type != commonv1.ModuleSpec_ValueTypeSingle { 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) } else if s.DoubleValue-3.14 > 0.000001 { 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") } - if addressVal.Type != rpcv1.ModuleSpec_ValueTypeObject { + if addressVal.Type != commonv1.ModuleSpec_ValueTypeObject { 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") } - if cityVal.Type != rpcv1.ModuleSpec_ValueTypeSingle { + if cityVal.Type != commonv1.ModuleSpec_ValueTypeSingle { t.Fatalf("Expected single value type, got %v", cityVal.Type) } - if cityVal.SingleValue.(*rpcv1.ModuleSpec_Value_StringValue).StringValue != "New York" { - t.Errorf("Expected string value to be New York, got %s", cityVal.SingleValue.(*rpcv1.ModuleSpec_Value_StringValue).StringValue) + if cityVal.SingleValue.(*commonv1.ModuleSpec_Value_StringValue).StringValue != "New York" { + t.Errorf("Expected string value to be New York, got %s", cityVal.SingleValue.(*commonv1.ModuleSpec_Value_StringValue).StringValue) } } diff --git a/protocol/unmarshal.go b/protocol/unmarshal.go index a1b4948..4e22bdd 100644 --- a/protocol/unmarshal.go +++ b/protocol/unmarshal.go @@ -6,7 +6,7 @@ import ( "reflect" "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") @@ -15,7 +15,7 @@ type unmarshalConfigOption interface { 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 { return u.UnmarshalModuleSpec(input) } @@ -42,7 +42,7 @@ type unmarshalConfig struct { 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++ { tf := intoType.Field(i) if !tf.IsExported() { @@ -82,11 +82,11 @@ func (cfg unmarshalConfig) unmarshal(input map[string]*rpcv1.ModuleSpec_Value, i 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 { - case rpcv1.ModuleSpec_ValueTypeUnknown: + case commonv1.ModuleSpec_ValueTypeUnknown: return reflect.Value{}, fmt.Errorf("%w: expected %s", ErrUnmatchingType, targetType.String()) - case rpcv1.ModuleSpec_ValueTypeObject: + case commonv1.ModuleSpec_ValueTypeObject: if targetType.Kind() == reflect.Struct { structVal := reflect.New(targetType) if err := cfg.unmarshal(val.ComplexValue, structVal, targetType); err != nil { @@ -104,7 +104,7 @@ func (cfg unmarshalConfig) mapSpecValueTo(val *rpcv1.ModuleSpec_Value, targetTyp } else { 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 { 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 - case rpcv1.ModuleSpec_ValueTypeSingle: + case commonv1.ModuleSpec_ValueTypeSingle: switch sv := val.SingleValue.(type) { - case *rpcv1.ModuleSpec_Value_BoolValue: + case *commonv1.ModuleSpec_Value_BoolValue: if targetType.Kind() != reflect.Bool { return reflect.Value{}, fmt.Errorf("%w: expected bool, got %v", ErrUnmatchingType, targetType) } return reflect.ValueOf(sv.BoolValue), nil - case *rpcv1.ModuleSpec_Value_StringValue: + case *commonv1.ModuleSpec_Value_StringValue: if targetType.Kind() != reflect.String { return reflect.Value{}, fmt.Errorf("%w: expected string, got %v", ErrUnmatchingType, targetType) } return reflect.ValueOf(sv.StringValue), nil - case *rpcv1.ModuleSpec_Value_IntValue: + case *commonv1.ModuleSpec_Value_IntValue: if targetType.Kind() != reflect.Int { return reflect.Value{}, fmt.Errorf("%w: expected int, got %v", ErrUnmatchingType, targetType) } return reflect.ValueOf(int(sv.IntValue)), nil - case *rpcv1.ModuleSpec_Value_DoubleValue: + case *commonv1.ModuleSpec_Value_DoubleValue: if targetType.Kind() != reflect.Float64 { return reflect.Value{}, fmt.Errorf("%w: expected float64, got %v", ErrUnmatchingType, targetType) } return reflect.ValueOf(sv.DoubleValue), nil } - case rpcv1.ModuleSpec_ValueTypeBoolSlice: + case commonv1.ModuleSpec_ValueTypeBoolSlice: if targetType.Kind() != reflect.Slice { return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType) } else if targetType.Elem().Kind() != reflect.Bool { return reflect.Value{}, fmt.Errorf("%w: expected bool, got %v", ErrUnmatchingType, targetType.Elem()) } return reflect.ValueOf(val.BoolValues), nil - case rpcv1.ModuleSpec_ValueTypeStringSlice: + case commonv1.ModuleSpec_ValueTypeStringSlice: if targetType.Kind() != reflect.Slice { return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType) } else if targetType.Elem().Kind() != reflect.String { return reflect.Value{}, fmt.Errorf("%w: expected string, got %v", ErrUnmatchingType, targetType.Elem()) } return reflect.ValueOf(val.StringValues), nil - case rpcv1.ModuleSpec_ValueTypeIntSlice: + case commonv1.ModuleSpec_ValueTypeIntSlice: if targetType.Kind() != reflect.Slice { 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: 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 { return reflect.Value{}, fmt.Errorf("%w: expected slice, got %v", ErrUnmatchingType, targetType) } diff --git a/protocol/unmarshal_test.go b/protocol/unmarshal_test.go index 1f1369c..3446e42 100644 --- a/protocol/unmarshal_test.go +++ b/protocol/unmarshal_test.go @@ -3,7 +3,7 @@ package protocol_test import ( "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" ) @@ -12,11 +12,11 @@ func TestUnmarshal_Bool_Success(t *testing.T) { Delete bool }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "delete": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_BoolValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_BoolValue{ BoolValue: true, }, }, @@ -37,11 +37,11 @@ func TestUnmarshal_Bool_Err(t *testing.T) { Delete string }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "delete": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_BoolValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_BoolValue{ BoolValue: true, }, }, @@ -60,10 +60,10 @@ func TestUnmarshal_Bool_Slice_Success(t *testing.T) { Delete []bool }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "delete": { - Type: rpcv1.ModuleSpec_ValueTypeBoolSlice, + Type: commonv1.ModuleSpec_ValueTypeBoolSlice, BoolValues: []bool{true}, }, }, @@ -85,10 +85,10 @@ func TestUnmarshal_Bool_Slice_Err(t *testing.T) { Delete []string }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "delete": { - Type: rpcv1.ModuleSpec_ValueTypeBoolSlice, + Type: commonv1.ModuleSpec_ValueTypeBoolSlice, BoolValues: []bool{true}, }, }, @@ -106,11 +106,11 @@ func TestUnmarshal_String_Success(t *testing.T) { Name string }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "name": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_StringValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_StringValue{ StringValue: "Ted", }, }, @@ -131,11 +131,11 @@ func TestUnmarshal_String_Err(t *testing.T) { Name int }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "name": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_StringValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_StringValue{ StringValue: "Ted", }, }, @@ -154,10 +154,10 @@ func TestUnmarshal_String_Slice_Success(t *testing.T) { Names []string }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "names": { - Type: rpcv1.ModuleSpec_ValueTypeStringSlice, + Type: commonv1.ModuleSpec_ValueTypeStringSlice, StringValues: []string{"Ted"}, }, }, @@ -179,10 +179,10 @@ func TestUnmarshal_String_Slice_Err(t *testing.T) { Names []int }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "names": { - Type: rpcv1.ModuleSpec_ValueTypeStringSlice, + Type: commonv1.ModuleSpec_ValueTypeStringSlice, StringValues: []string{"Ted"}, }, }, @@ -200,11 +200,11 @@ func TestUnmarshal_Int_Success(t *testing.T) { Age int }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "age": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_IntValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_IntValue{ IntValue: 42, }, }, @@ -225,11 +225,11 @@ func TestUnmarshal_Int_Err(t *testing.T) { Age string }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "age": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_IntValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_IntValue{ IntValue: 42, }, }, @@ -248,10 +248,10 @@ func TestUnmarshal_Int_Slice_Success(t *testing.T) { Ages []int }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "ages": { - Type: rpcv1.ModuleSpec_ValueTypeIntSlice, + Type: commonv1.ModuleSpec_ValueTypeIntSlice, IntValues: []int64{42}, }, }, @@ -273,10 +273,10 @@ func TestUnmarshal_Int_Slice_Err(t *testing.T) { Ages []string }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "ages": { - Type: rpcv1.ModuleSpec_ValueTypeIntSlice, + Type: commonv1.ModuleSpec_ValueTypeIntSlice, IntValues: []int64{42}, }, }, @@ -294,11 +294,11 @@ func TestUnmarshal_Double_Success(t *testing.T) { Pi float64 }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "Pi": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_DoubleValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_DoubleValue{ DoubleValue: 3.14, }, }, @@ -319,11 +319,11 @@ func TestUnmarshal_Double_Err(t *testing.T) { Pi string }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "pi": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_DoubleValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_DoubleValue{ DoubleValue: 3.14, }, }, @@ -342,10 +342,10 @@ func TestUnmarshal_Double_Slice_Success(t *testing.T) { Pis []float64 }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "pis": { - Type: rpcv1.ModuleSpec_ValueTypeDoubleSlice, + Type: commonv1.ModuleSpec_ValueTypeDoubleSlice, DoubleValues: []float64{3.14}, }, }, @@ -367,10 +367,10 @@ func TestUnmarshal_Double_Slice_Err(t *testing.T) { Pis []string }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "pis": { - Type: rpcv1.ModuleSpec_ValueTypeDoubleSlice, + Type: commonv1.ModuleSpec_ValueTypeDoubleSlice, DoubleValues: []float64{3.14}, }, }, @@ -390,14 +390,14 @@ func TestUnmarshal_NestedStruct_Success(t *testing.T) { } }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "address": { - Type: rpcv1.ModuleSpec_ValueTypeObject, - ComplexValue: map[string]*rpcv1.ModuleSpec_Value{ + Type: commonv1.ModuleSpec_ValueTypeObject, + ComplexValue: map[string]*commonv1.ModuleSpec_Value{ "city": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_StringValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_StringValue{ StringValue: "New York", }, }, @@ -422,14 +422,14 @@ func TestUnmarshal_NestedStructPointer_Success(t *testing.T) { } }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "address": { - Type: rpcv1.ModuleSpec_ValueTypeObject, - ComplexValue: map[string]*rpcv1.ModuleSpec_Value{ + Type: commonv1.ModuleSpec_ValueTypeObject, + ComplexValue: map[string]*commonv1.ModuleSpec_Value{ "city": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_StringValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_StringValue{ StringValue: "New York", }, }, @@ -452,14 +452,14 @@ func TestUnmarshal_Map_Success(t *testing.T) { Values map[string]string }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "values": { - Type: rpcv1.ModuleSpec_ValueTypeMap, - ComplexValue: map[string]*rpcv1.ModuleSpec_Value{ + Type: commonv1.ModuleSpec_ValueTypeMap, + ComplexValue: map[string]*commonv1.ModuleSpec_Value{ "City": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_StringValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_StringValue{ StringValue: "New York", }, }, @@ -484,17 +484,17 @@ func TestUnmarshal_NestedMap_Success(t *testing.T) { } }{} - spec := &rpcv1.ModuleSpec{ - Values: map[string]*rpcv1.ModuleSpec_Value{ + spec := &commonv1.ModuleSpec{ + Values: map[string]*commonv1.ModuleSpec_Value{ "city": { - Type: rpcv1.ModuleSpec_ValueTypeObject, - ComplexValue: map[string]*rpcv1.ModuleSpec_Value{ + Type: commonv1.ModuleSpec_ValueTypeObject, + ComplexValue: map[string]*commonv1.ModuleSpec_Value{ "labels": { - Type: rpcv1.ModuleSpec_ValueTypeMap, - ComplexValue: map[string]*rpcv1.ModuleSpec_Value{ + Type: commonv1.ModuleSpec_ValueTypeMap, + ComplexValue: map[string]*commonv1.ModuleSpec_Value{ "Region": { - Type: rpcv1.ModuleSpec_ValueTypeSingle, - SingleValue: &rpcv1.ModuleSpec_Value_StringValue{ + Type: commonv1.ModuleSpec_ValueTypeSingle, + SingleValue: &commonv1.ModuleSpec_Value_StringValue{ StringValue: "west", }, },