diff --git a/backend/inventory/app/server.go b/backend/inventory/app/server.go index f4ea8d71d6..f1b616041f 100644 --- a/backend/inventory/app/server.go +++ b/backend/inventory/app/server.go @@ -37,5 +37,5 @@ func (s *Server) SetFact(ctx context.Context, req *pb.SetFactRequest) (*pb.SetFa if err != nil { return nil, status.Error(codes.Internal, "could not set fact") } - return &pb.SetFactReply{FactUri: factUri} , nil + return &pb.SetFactReply{Fact: &pb.Fact{Uri: factUri, Value: req.Value}} , nil } diff --git a/backend/inventory/app/server_test.go b/backend/inventory/app/server_test.go index 7829a0e22c..1ac0c292fe 100644 --- a/backend/inventory/app/server_test.go +++ b/backend/inventory/app/server_test.go @@ -6,6 +6,7 @@ import ( "github.com/spotify/backstage/inventory/storage" "io/ioutil" "os" + "reflect" "testing" pb "github.com/spotify/backstage/proto/inventory/v1" @@ -49,6 +50,32 @@ func TestServerGetEntity(t *testing.T) { } } +func TestServerGetEntityWithIncludedFacts(t *testing.T) { + testStorage := NewTestStorage() + defer testStorage.Close() + s := Server{Storage: testStorage.Storage} + + entityUri := "boss://test/test" + setFactReq := &pb.SetFactRequest{EntityUri: entityUri, Name: "test-name", Value: "test-value"} + s.SetFact(context.Background(), setFactReq) + + + entity := &pb.Entity{Uri: entityUri} + req := &pb.GetEntityRequest{Entity: entity, IncludeFacts: []string{"test-name"}} + + resp, err := s.GetEntity(context.Background(), req) + if err != nil { + t.Errorf("ServerTest(GetEntity) got unexpected error %v", err) + } + if resp == nil { + t.Errorf("ServerTest(GetEntity) returned nil") + } + expectedFacts := []*pb.Fact{{Uri: "boss://test/test/test-name", Value: "test-value"}} + if !reflect.DeepEqual(resp.GetFacts(), expectedFacts) { + t.Errorf("ServerTest(GetEntity) got %v, wanted %v", resp.GetFacts(), expectedFacts) + } +} + func TestServerSetFactForExistingEntity(t *testing.T) { testStorage := NewTestStorage() defer testStorage.Close() @@ -66,8 +93,9 @@ func TestServerSetFactForExistingEntity(t *testing.T) { if resp == nil { t.Errorf("ServerTest(SetFact) returned nil") } - if resp.GetFactUri() != entity.GetUri() + "/" + req.Name { - t.Errorf("ServerTest(SetFact) got %v, wanted %v", resp.GetFactUri(), entity.GetUri() + "/" + req.Name) + fact := &pb.Fact{Uri: entity.GetUri() + "/" + req.Name, Value: "test-value"} + if !reflect.DeepEqual(resp.GetFact(), fact) { + t.Errorf("ServerTest(SetFact) got %v, wanted %v", resp.GetFact() , fact) } } @@ -85,8 +113,9 @@ func TestServerSetFactForNonExistingEntity(t *testing.T) { if resp == nil { t.Errorf("ServerTest(SetFact) returned nil") } - if resp.GetFactUri() != entityUri + "/" + req.Name { - t.Errorf("ServerTest(SetFact) got %v, wanted %v", resp.GetFactUri(), entityUri + "/" + req.Name) + fact := &pb.Fact{Uri: entityUri + "/" + req.Name, Value: "test-value"} + if !reflect.DeepEqual(resp.GetFact(), fact) { + t.Errorf("ServerTest(SetFact) got %v, wanted %v", resp.GetFact() , fact) } } diff --git a/backend/proto/inventory/v1/inventory.pb.go b/backend/proto/inventory/v1/inventory.pb.go index 556ca48b82..2c6201e584 100644 --- a/backend/proto/inventory/v1/inventory.pb.go +++ b/backend/proto/inventory/v1/inventory.pb.go @@ -252,7 +252,7 @@ func (m *SetFactRequest) GetValue() string { } type SetFactReply struct { - FactUri string `protobuf:"bytes,1,opt,name=factUri,proto3" json:"factUri,omitempty"` + Fact *Fact `protobuf:"bytes,1,opt,name=fact,proto3" json:"fact,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -283,13 +283,99 @@ func (m *SetFactReply) XXX_DiscardUnknown() { var xxx_messageInfo_SetFactReply proto.InternalMessageInfo -func (m *SetFactReply) GetFactUri() string { +func (m *SetFactReply) GetFact() *Fact { if m != nil { - return m.FactUri + return m.Fact + } + return nil +} + +type GetFactRequest struct { + EntityUri string `protobuf:"bytes,1,opt,name=entityUri,proto3" json:"entityUri,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetFactRequest) Reset() { *m = GetFactRequest{} } +func (m *GetFactRequest) String() string { return proto.CompactTextString(m) } +func (*GetFactRequest) ProtoMessage() {} +func (*GetFactRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_70be9028e322f9d8, []int{6} +} + +func (m *GetFactRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetFactRequest.Unmarshal(m, b) +} +func (m *GetFactRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetFactRequest.Marshal(b, m, deterministic) +} +func (m *GetFactRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetFactRequest.Merge(m, src) +} +func (m *GetFactRequest) XXX_Size() int { + return xxx_messageInfo_GetFactRequest.Size(m) +} +func (m *GetFactRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetFactRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetFactRequest proto.InternalMessageInfo + +func (m *GetFactRequest) GetEntityUri() string { + if m != nil { + return m.EntityUri } return "" } +func (m *GetFactRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +type GetFactReply struct { + Fact *Fact `protobuf:"bytes,1,opt,name=fact,proto3" json:"fact,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetFactReply) Reset() { *m = GetFactReply{} } +func (m *GetFactReply) String() string { return proto.CompactTextString(m) } +func (*GetFactReply) ProtoMessage() {} +func (*GetFactReply) Descriptor() ([]byte, []int) { + return fileDescriptor_70be9028e322f9d8, []int{7} +} + +func (m *GetFactReply) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetFactReply.Unmarshal(m, b) +} +func (m *GetFactReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetFactReply.Marshal(b, m, deterministic) +} +func (m *GetFactReply) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetFactReply.Merge(m, src) +} +func (m *GetFactReply) XXX_Size() int { + return xxx_messageInfo_GetFactReply.Size(m) +} +func (m *GetFactReply) XXX_DiscardUnknown() { + xxx_messageInfo_GetFactReply.DiscardUnknown(m) +} + +var xxx_messageInfo_GetFactReply proto.InternalMessageInfo + +func (m *GetFactReply) GetFact() *Fact { + if m != nil { + return m.Fact + } + return nil +} + type Entity struct { Uri string `protobuf:"bytes,1,opt,name=uri,proto3" json:"uri,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -301,7 +387,7 @@ func (m *Entity) Reset() { *m = Entity{} } func (m *Entity) String() string { return proto.CompactTextString(m) } func (*Entity) ProtoMessage() {} func (*Entity) Descriptor() ([]byte, []int) { - return fileDescriptor_70be9028e322f9d8, []int{6} + return fileDescriptor_70be9028e322f9d8, []int{8} } func (m *Entity) XXX_Unmarshal(b []byte) error { @@ -330,8 +416,7 @@ func (m *Entity) GetUri() string { } type Fact struct { - EntityUri string `protobuf:"bytes,1,opt,name=entityUri,proto3" json:"entityUri,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Uri string `protobuf:"bytes,1,opt,name=uri,proto3" json:"uri,omitempty"` Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -342,7 +427,7 @@ func (m *Fact) Reset() { *m = Fact{} } func (m *Fact) String() string { return proto.CompactTextString(m) } func (*Fact) ProtoMessage() {} func (*Fact) Descriptor() ([]byte, []int) { - return fileDescriptor_70be9028e322f9d8, []int{7} + return fileDescriptor_70be9028e322f9d8, []int{9} } func (m *Fact) XXX_Unmarshal(b []byte) error { @@ -363,16 +448,9 @@ func (m *Fact) XXX_DiscardUnknown() { var xxx_messageInfo_Fact proto.InternalMessageInfo -func (m *Fact) GetEntityUri() string { +func (m *Fact) GetUri() string { if m != nil { - return m.EntityUri - } - return "" -} - -func (m *Fact) GetName() string { - if m != nil { - return m.Name + return m.Uri } return "" } @@ -391,6 +469,8 @@ func init() { proto.RegisterType((*CreateEntityReply)(nil), "spotify.backstage.inventory.v1.CreateEntityReply") proto.RegisterType((*SetFactRequest)(nil), "spotify.backstage.inventory.v1.SetFactRequest") proto.RegisterType((*SetFactReply)(nil), "spotify.backstage.inventory.v1.SetFactReply") + proto.RegisterType((*GetFactRequest)(nil), "spotify.backstage.inventory.v1.GetFactRequest") + proto.RegisterType((*GetFactReply)(nil), "spotify.backstage.inventory.v1.GetFactReply") proto.RegisterType((*Entity)(nil), "spotify.backstage.inventory.v1.Entity") proto.RegisterType((*Fact)(nil), "spotify.backstage.inventory.v1.Fact") } @@ -398,29 +478,32 @@ func init() { func init() { proto.RegisterFile("inventory/v1/inventory.proto", fileDescriptor_70be9028e322f9d8) } var fileDescriptor_70be9028e322f9d8 = []byte{ - // 346 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x4d, 0x4b, 0xc3, 0x40, - 0x10, 0x25, 0xfd, 0x92, 0x4c, 0x3f, 0xa8, 0xab, 0x87, 0x50, 0x8a, 0x94, 0x55, 0xa4, 0xa7, 0xd4, - 0xb4, 0x37, 0x0f, 0x1e, 0x14, 0x15, 0x2f, 0x1e, 0x52, 0x0a, 0xe2, 0x45, 0xb6, 0x75, 0x2a, 0xc1, - 0x34, 0x89, 0xc9, 0x66, 0x25, 0xff, 0xc1, 0x5f, 0xeb, 0x2f, 0x90, 0xdd, 0xa4, 0x49, 0x15, 0xb1, - 0x14, 0x73, 0xdb, 0x79, 0xb3, 0xef, 0xcd, 0xcb, 0xcb, 0x2c, 0xf4, 0x1d, 0x4f, 0xa0, 0xc7, 0xfd, - 0x30, 0x19, 0x09, 0x6b, 0x94, 0x17, 0x66, 0x10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c, - 0xd2, 0x7b, 0xa8, 0x49, 0x89, 0xb2, 0x5c, 0x8d, 0x3f, 0x35, 0xd0, 0xef, 0xd6, 0x79, 0x90, 0x15, - 0xe8, 0xf9, 0xde, 0x90, 0xb3, 0x6d, 0xd1, 0xfd, 0x5c, 0xee, 0x9e, 0xb9, 0x03, 0x43, 0x46, 0x20, - 0xa0, 0xb5, 0xf9, 0x07, 0xc9, 0x64, 0x1b, 0xff, 0x97, 0x35, 0xea, 0x59, 0xbb, 0x91, 0x02, 0x37, - 0xb9, 0x6c, 0x3f, 0x36, 0xf3, 0x1b, 0xc2, 0x9a, 0x37, 0xd4, 0x73, 0x9e, 0x7c, 0x05, 0x00, 0x00, - 0xff, 0xff, 0xae, 0xd9, 0x2b, 0x51, 0xee, 0x03, 0x00, 0x00, + // 386 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4d, 0x4f, 0xc2, 0x40, + 0x10, 0x0d, 0x14, 0x30, 0x1d, 0x3e, 0x82, 0xab, 0x87, 0xa6, 0x21, 0x86, 0xac, 0xc6, 0x70, 0x30, + 0x8b, 0x85, 0x8b, 0xf1, 0xe0, 0x01, 0xa3, 0xd5, 0x6b, 0x09, 0x89, 0xf1, 0x62, 0x0a, 0x2e, 0xa4, + 0x11, 0x5a, 0x6c, 0xb7, 0x35, 0xfd, 0x0f, 0xfe, 0x2c, 0x7f, 0x98, 0xd9, 0xed, 0x5a, 0x40, 0x89, + 0x85, 0xc0, 0x6d, 0x77, 0x66, 0xde, 0xbc, 0xd7, 0xd7, 0xd7, 0x42, 0xc3, 0x71, 0x23, 0xea, 0x32, + 0xcf, 0x8f, 0xdb, 0x91, 0xd1, 0x4e, 0x2f, 0x64, 0xee, 0x7b, 0xcc, 0x43, 0x27, 0xc1, 0xdc, 0x63, + 0xce, 0x38, 0x26, 0x43, 0x7b, 0xf4, 0x16, 0x30, 0x7b, 0x42,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1f, 0x31, 0x81, 0x02, 0x9f, 0xfc, 0xdb, 0x59, 0xef, 0x51, 0xe7, 0x4b, 0x01, 0xf5, 0xf1, 0x87, + 0x07, 0xcd, 0x40, 0x4d, 0x53, 0x8c, 0x2e, 0xb3, 0x24, 0xfd, 0xfe, 0xd4, 0x74, 0xb2, 0x05, 0x82, + 0x5b, 0x10, 0x41, 0x65, 0x39, 0x4f, 0xa8, 0x9b, 0x85, 0x5f, 0x13, 0x6a, 0xdd, 0xd8, 0x0e, 0xc4, + 0x79, 0x27, 0x70, 0x20, 0x83, 0x81, 0x32, 0x25, 0xaf, 0x66, 0x53, 0xbf, 0xd8, 0x78, 0x5e, 0x12, + 0x99, 0x9b, 0x12, 0x99, 0x5b, 0x12, 0x2d, 0x87, 0xa9, 0x57, 0x7d, 0x2e, 0xa7, 0xcd, 0xc8, 0x18, + 0x96, 0xc4, 0xef, 0xb2, 0xfb, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x62, 0x7f, 0x29, 0xca, 0x4e, 0x05, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -437,6 +520,8 @@ const _ = grpc.SupportPackageIsVersion6 type InventoryClient interface { GetEntity(ctx context.Context, in *GetEntityRequest, opts ...grpc.CallOption) (*GetEntityReply, error) CreateEntity(ctx context.Context, in *CreateEntityRequest, opts ...grpc.CallOption) (*CreateEntityReply, error) + SetFact(ctx context.Context, in *SetFactRequest, opts ...grpc.CallOption) (*SetFactReply, error) + GetFact(ctx context.Context, in *GetFactRequest, opts ...grpc.CallOption) (*GetFactReply, error) } type inventoryClient struct { @@ -465,10 +550,30 @@ func (c *inventoryClient) CreateEntity(ctx context.Context, in *CreateEntityRequ return out, nil } +func (c *inventoryClient) SetFact(ctx context.Context, in *SetFactRequest, opts ...grpc.CallOption) (*SetFactReply, error) { + out := new(SetFactReply) + err := c.cc.Invoke(ctx, "/spotify.backstage.inventory.v1.Inventory/SetFact", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *inventoryClient) GetFact(ctx context.Context, in *GetFactRequest, opts ...grpc.CallOption) (*GetFactReply, error) { + out := new(GetFactReply) + err := c.cc.Invoke(ctx, "/spotify.backstage.inventory.v1.Inventory/GetFact", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // InventoryServer is the server API for Inventory service. type InventoryServer interface { GetEntity(context.Context, *GetEntityRequest) (*GetEntityReply, error) CreateEntity(context.Context, *CreateEntityRequest) (*CreateEntityReply, error) + SetFact(context.Context, *SetFactRequest) (*SetFactReply, error) + GetFact(context.Context, *GetFactRequest) (*GetFactReply, error) } // UnimplementedInventoryServer can be embedded to have forward compatible implementations. @@ -481,6 +586,12 @@ func (*UnimplementedInventoryServer) GetEntity(ctx context.Context, req *GetEnti func (*UnimplementedInventoryServer) CreateEntity(ctx context.Context, req *CreateEntityRequest) (*CreateEntityReply, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateEntity not implemented") } +func (*UnimplementedInventoryServer) SetFact(ctx context.Context, req *SetFactRequest) (*SetFactReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetFact not implemented") +} +func (*UnimplementedInventoryServer) GetFact(ctx context.Context, req *GetFactRequest) (*GetFactReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetFact not implemented") +} func RegisterInventoryServer(s *grpc.Server, srv InventoryServer) { s.RegisterService(&_Inventory_serviceDesc, srv) @@ -522,6 +633,42 @@ func _Inventory_CreateEntity_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Inventory_SetFact_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetFactRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InventoryServer).SetFact(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/spotify.backstage.inventory.v1.Inventory/SetFact", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InventoryServer).SetFact(ctx, req.(*SetFactRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Inventory_GetFact_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetFactRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InventoryServer).GetFact(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/spotify.backstage.inventory.v1.Inventory/GetFact", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InventoryServer).GetFact(ctx, req.(*GetFactRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Inventory_serviceDesc = grpc.ServiceDesc{ ServiceName: "spotify.backstage.inventory.v1.Inventory", HandlerType: (*InventoryServer)(nil), @@ -534,6 +681,14 @@ var _Inventory_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateEntity", Handler: _Inventory_CreateEntity_Handler, }, + { + MethodName: "SetFact", + Handler: _Inventory_SetFact_Handler, + }, + { + MethodName: "GetFact", + Handler: _Inventory_GetFact_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "inventory/v1/inventory.proto", diff --git a/proto/inventory/v1/inventory.proto b/proto/inventory/v1/inventory.proto index 33a32f8e8f..5d0a3adf93 100644 --- a/proto/inventory/v1/inventory.proto +++ b/proto/inventory/v1/inventory.proto @@ -7,6 +7,8 @@ option go_package = "inventoryv1"; service Inventory { rpc GetEntity(GetEntityRequest) returns (GetEntityReply); rpc CreateEntity(CreateEntityRequest) returns (CreateEntityReply); + rpc SetFact(SetFactRequest) returns (SetFactReply); + rpc GetFact(GetFactRequest) returns (GetFactReply); } message GetEntityRequest { @@ -34,7 +36,16 @@ message SetFactRequest { } message SetFactReply { - string factUri = 1; + Fact fact = 1; +} + +message GetFactRequest { + string entityUri = 1; + string name = 2; +} + +message GetFactReply { + Fact fact = 1; } message Entity { @@ -42,7 +53,6 @@ message Entity { } message Fact { - string entityUri = 1; - string name = 2; + string uri = 1; string value = 3; } \ No newline at end of file