From 5a5fab320953a0f8690f6e87a952ce1bd613690a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jefferson=20Gir=C3=A3o?= Date: Mon, 3 Feb 2020 16:59:44 +0100 Subject: [PATCH 1/5] feat: skeleton inventory service --- backend/inventory/gen-pb.sh | 2 + backend/inventory/go.mod | 11 + backend/inventory/go.sum | 46 ++++ backend/inventory/main.go | 31 +++ backend/inventory/protos/inventory.pb.go | 324 +++++++++++++++++++++++ 5 files changed, 414 insertions(+) create mode 100755 backend/inventory/gen-pb.sh create mode 100644 backend/inventory/go.mod create mode 100644 backend/inventory/go.sum create mode 100644 backend/inventory/main.go create mode 100644 backend/inventory/protos/inventory.pb.go diff --git a/backend/inventory/gen-pb.sh b/backend/inventory/gen-pb.sh new file mode 100755 index 0000000000..6f46277f8e --- /dev/null +++ b/backend/inventory/gen-pb.sh @@ -0,0 +1,2 @@ +#!/bin/bash +protoc -I ../../ protos/inventory.proto --go_out=plugins=grpc:. diff --git a/backend/inventory/go.mod b/backend/inventory/go.mod new file mode 100644 index 0000000000..383c0ca350 --- /dev/null +++ b/backend/inventory/go.mod @@ -0,0 +1,11 @@ +module github.com/spotify/backstage/inventory + +go 1.12 + +require ( + github.com/golang/protobuf v1.3.2 + golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect + golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 // indirect + google.golang.org/grpc v1.27.0 + honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect +) diff --git a/backend/inventory/go.sum b/backend/inventory/go.sum new file mode 100644 index 0000000000..cc82527f48 --- /dev/null +++ b/backend/inventory/go.sum @@ -0,0 +1,46 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/backend/inventory/main.go b/backend/inventory/main.go new file mode 100644 index 0000000000..98c6641bb1 --- /dev/null +++ b/backend/inventory/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "context" + "log" + "net" + + pb "github.com/spotify/backstage/inventory/protos" + "google.golang.org/grpc" +) + +const ( + port = ":50051" +) + +type inventoryServer struct { +} + +func (s *inventoryServer) GetEntity(ctx context.Context, req *pb.GetEntityRequest) (*pb.GetEntityReply, error) { + return &pb.GetEntityReply{}, nil +} + +func main() { + lis, err := net.Listen("tcp", port) + if err != nil { + log.Fatalf("failed to listen: %v", err) + } + grpcServer := grpc.NewServer() + pb.RegisterInventoryServer(grpcServer, &inventoryServer{}) + grpcServer.Serve(lis) +} diff --git a/backend/inventory/protos/inventory.pb.go b/backend/inventory/protos/inventory.pb.go new file mode 100644 index 0000000000..d7c5e7bfe8 --- /dev/null +++ b/backend/inventory/protos/inventory.pb.go @@ -0,0 +1,324 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: protos/inventory.proto + +package spotify_backstage_inventory_v1alpha1 + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type GetEntityRequest struct { + Entity *Entity `protobuf:"bytes,1,opt,name=entity,proto3" json:"entity,omitempty"` + IncludeFacts []string `protobuf:"bytes,2,rep,name=include_facts,json=includeFacts,proto3" json:"include_facts,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetEntityRequest) Reset() { *m = GetEntityRequest{} } +func (m *GetEntityRequest) String() string { return proto.CompactTextString(m) } +func (*GetEntityRequest) ProtoMessage() {} +func (*GetEntityRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1a8706afd37ce83a, []int{0} +} + +func (m *GetEntityRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetEntityRequest.Unmarshal(m, b) +} +func (m *GetEntityRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetEntityRequest.Marshal(b, m, deterministic) +} +func (m *GetEntityRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetEntityRequest.Merge(m, src) +} +func (m *GetEntityRequest) XXX_Size() int { + return xxx_messageInfo_GetEntityRequest.Size(m) +} +func (m *GetEntityRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetEntityRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetEntityRequest proto.InternalMessageInfo + +func (m *GetEntityRequest) GetEntity() *Entity { + if m != nil { + return m.Entity + } + return nil +} + +func (m *GetEntityRequest) GetIncludeFacts() []string { + if m != nil { + return m.IncludeFacts + } + return nil +} + +type GetEntityReply struct { + Entity *Entity `protobuf:"bytes,1,opt,name=entity,proto3" json:"entity,omitempty"` + Facts []*Fact `protobuf:"bytes,2,rep,name=facts,proto3" json:"facts,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetEntityReply) Reset() { *m = GetEntityReply{} } +func (m *GetEntityReply) String() string { return proto.CompactTextString(m) } +func (*GetEntityReply) ProtoMessage() {} +func (*GetEntityReply) Descriptor() ([]byte, []int) { + return fileDescriptor_1a8706afd37ce83a, []int{1} +} + +func (m *GetEntityReply) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetEntityReply.Unmarshal(m, b) +} +func (m *GetEntityReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetEntityReply.Marshal(b, m, deterministic) +} +func (m *GetEntityReply) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetEntityReply.Merge(m, src) +} +func (m *GetEntityReply) XXX_Size() int { + return xxx_messageInfo_GetEntityReply.Size(m) +} +func (m *GetEntityReply) XXX_DiscardUnknown() { + xxx_messageInfo_GetEntityReply.DiscardUnknown(m) +} + +var xxx_messageInfo_GetEntityReply proto.InternalMessageInfo + +func (m *GetEntityReply) GetEntity() *Entity { + if m != nil { + return m.Entity + } + return nil +} + +func (m *GetEntityReply) GetFacts() []*Fact { + if m != nil { + return m.Facts + } + return nil +} + +type Entity struct { + Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +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_1a8706afd37ce83a, []int{2} +} + +func (m *Entity) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Entity.Unmarshal(m, b) +} +func (m *Entity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Entity.Marshal(b, m, deterministic) +} +func (m *Entity) XXX_Merge(src proto.Message) { + xxx_messageInfo_Entity.Merge(m, src) +} +func (m *Entity) XXX_Size() int { + return xxx_messageInfo_Entity.Size(m) +} +func (m *Entity) XXX_DiscardUnknown() { + xxx_messageInfo_Entity.DiscardUnknown(m) +} + +var xxx_messageInfo_Entity proto.InternalMessageInfo + +func (m *Entity) GetKind() string { + if m != nil { + return m.Kind + } + return "" +} + +func (m *Entity) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +type Fact struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +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_1a8706afd37ce83a, []int{3} +} + +func (m *Fact) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Fact.Unmarshal(m, b) +} +func (m *Fact) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Fact.Marshal(b, m, deterministic) +} +func (m *Fact) XXX_Merge(src proto.Message) { + xxx_messageInfo_Fact.Merge(m, src) +} +func (m *Fact) XXX_Size() int { + return xxx_messageInfo_Fact.Size(m) +} +func (m *Fact) XXX_DiscardUnknown() { + xxx_messageInfo_Fact.DiscardUnknown(m) +} + +var xxx_messageInfo_Fact proto.InternalMessageInfo + +func (m *Fact) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Fact) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +func init() { + proto.RegisterType((*GetEntityRequest)(nil), "spotify.backstage.inventory.v1alpha1.GetEntityRequest") + proto.RegisterType((*GetEntityReply)(nil), "spotify.backstage.inventory.v1alpha1.GetEntityReply") + proto.RegisterType((*Entity)(nil), "spotify.backstage.inventory.v1alpha1.Entity") + proto.RegisterType((*Fact)(nil), "spotify.backstage.inventory.v1alpha1.Fact") +} + +func init() { proto.RegisterFile("protos/inventory.proto", fileDescriptor_1a8706afd37ce83a) } + +var fileDescriptor_1a8706afd37ce83a = []byte{ + // 273 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x2f, 0xd6, 0xcf, 0xcc, 0x2b, 0x4b, 0xcd, 0x2b, 0xc9, 0x2f, 0xaa, 0xd4, 0x03, 0x0b, 0x08, + 0xa9, 0x14, 0x17, 0xe4, 0x97, 0x64, 0xa6, 0x55, 0xea, 0x25, 0x25, 0x26, 0x67, 0x17, 0x97, 0x24, + 0xa6, 0xa7, 0xea, 0x21, 0x94, 0x94, 0x19, 0x26, 0xe6, 0x14, 0x64, 0x24, 0x1a, 0x2a, 0xd5, 0x72, + 0x09, 0xb8, 0xa7, 0x96, 0xb8, 0xe6, 0x95, 0x64, 0x96, 0x54, 0x06, 0xa5, 0x16, 0x96, 0xa6, 0x16, + 0x97, 0x08, 0xb9, 0x70, 0xb1, 0xa5, 0x82, 0x05, 0x24, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x74, + 0xf4, 0x88, 0x31, 0x4a, 0x0f, 0x6a, 0x08, 0x54, 0xaf, 0x90, 0x32, 0x17, 0x6f, 0x66, 0x5e, 0x72, + 0x4e, 0x69, 0x4a, 0x6a, 0x7c, 0x5a, 0x62, 0x72, 0x49, 0xb1, 0x04, 0x93, 0x02, 0xb3, 0x06, 0x67, + 0x10, 0x0f, 0x54, 0xd0, 0x0d, 0x24, 0xa6, 0x34, 0x83, 0x91, 0x8b, 0x0f, 0xc9, 0xfe, 0x82, 0x9c, + 0x4a, 0x2a, 0xd9, 0xee, 0xc0, 0xc5, 0x8a, 0xb0, 0x95, 0xdb, 0x48, 0x8b, 0x38, 0x43, 0x40, 0x8e, + 0x0a, 0x82, 0x68, 0x54, 0xd2, 0xe1, 0x62, 0x83, 0x98, 0x29, 0x24, 0xc4, 0xc5, 0x92, 0x9d, 0x99, + 0x97, 0x02, 0x76, 0x0f, 0x67, 0x10, 0x98, 0x2d, 0xc4, 0xc7, 0xc5, 0x94, 0x99, 0x22, 0xc1, 0x04, + 0x16, 0x61, 0xca, 0x4c, 0x51, 0x32, 0xe0, 0x62, 0x01, 0x69, 0x06, 0xa9, 0xcd, 0x4b, 0xcc, 0x4d, + 0x85, 0xa9, 0x05, 0xb1, 0x85, 0x44, 0xb8, 0x58, 0xcb, 0x12, 0x73, 0x4a, 0x53, 0xa1, 0xca, 0x21, + 0x1c, 0xa3, 0x36, 0x46, 0x2e, 0x4e, 0x4f, 0x98, 0x13, 0x84, 0x2a, 0xb9, 0x38, 0xe1, 0xe1, 0x20, + 0x64, 0x46, 0x9c, 0x6b, 0xd1, 0x23, 0x4e, 0xca, 0x84, 0x64, 0x7d, 0x05, 0x39, 0x95, 0x49, 0x6c, + 0xe0, 0xf4, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x66, 0x0d, 0x53, 0x49, 0x02, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// InventoryClient is the client API for Inventory service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type InventoryClient interface { + GetEntity(ctx context.Context, in *GetEntityRequest, opts ...grpc.CallOption) (*GetEntityReply, error) +} + +type inventoryClient struct { + cc grpc.ClientConnInterface +} + +func NewInventoryClient(cc grpc.ClientConnInterface) InventoryClient { + return &inventoryClient{cc} +} + +func (c *inventoryClient) GetEntity(ctx context.Context, in *GetEntityRequest, opts ...grpc.CallOption) (*GetEntityReply, error) { + out := new(GetEntityReply) + err := c.cc.Invoke(ctx, "/spotify.backstage.inventory.v1alpha1.Inventory/GetEntity", 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) +} + +// UnimplementedInventoryServer can be embedded to have forward compatible implementations. +type UnimplementedInventoryServer struct { +} + +func (*UnimplementedInventoryServer) GetEntity(ctx context.Context, req *GetEntityRequest) (*GetEntityReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetEntity not implemented") +} + +func RegisterInventoryServer(s *grpc.Server, srv InventoryServer) { + s.RegisterService(&_Inventory_serviceDesc, srv) +} + +func _Inventory_GetEntity_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetEntityRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InventoryServer).GetEntity(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/spotify.backstage.inventory.v1alpha1.Inventory/GetEntity", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InventoryServer).GetEntity(ctx, req.(*GetEntityRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Inventory_serviceDesc = grpc.ServiceDesc{ + ServiceName: "spotify.backstage.inventory.v1alpha1.Inventory", + HandlerType: (*InventoryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetEntity", + Handler: _Inventory_GetEntity_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "protos/inventory.proto", +} From 2d4672433830ed9b59ea35b78a60b18ddd4b373f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 3 Feb 2020 19:21:28 +0100 Subject: [PATCH 2/5] frontend: add grpc-web script, lint fixes, hello world --- frontend/.eslintrc.js | 2 + frontend/packages/app/.eslintrc.js | 2 + frontend/packages/app/package.json | 8 +- .../packages/plugins/hello-world/package.json | 11 +- .../components/MyComponent/MyComponent.tsx | 44 ++- .../src/proto/hello_grpc_web_pb.d.ts | 32 ++ .../src/proto/hello_grpc_web_pb.js | 153 +++++++++ .../hello-world/src/proto/hello_pb.d.ts | 38 +++ .../plugins/hello-world/src/proto/hello_pb.js | 308 ++++++++++++++++++ frontend/scripts/gen-proto.sh | 8 + frontend/yarn.lock | 92 ++---- 11 files changed, 610 insertions(+), 88 deletions(-) create mode 100644 frontend/packages/plugins/hello-world/src/proto/hello_grpc_web_pb.d.ts create mode 100644 frontend/packages/plugins/hello-world/src/proto/hello_grpc_web_pb.js create mode 100644 frontend/packages/plugins/hello-world/src/proto/hello_pb.d.ts create mode 100644 frontend/packages/plugins/hello-world/src/proto/hello_pb.js create mode 100755 frontend/scripts/gen-proto.sh diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index e8ef5b8243..23f1cddc23 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -21,4 +21,6 @@ module.exports = { version: 'detect', }, }, + // Adding this to .eslintignore just doesn't even, let me know if you can make it work ._. + ignorePatterns: ['**/*_pb.js', '**/*_pb.d.ts'], }; diff --git a/frontend/packages/app/.eslintrc.js b/frontend/packages/app/.eslintrc.js index 170d387d07..e44ceef6ec 100644 --- a/frontend/packages/app/.eslintrc.js +++ b/frontend/packages/app/.eslintrc.js @@ -23,4 +23,6 @@ module.exports = { version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use }, }, + // Adding this to .eslintignore just doesn't even, let me know if you can make it work ._. + ignorePatterns: ['**/*_pb.js', '**/*_pb.d.ts'], }; diff --git a/frontend/packages/app/package.json b/frontend/packages/app/package.json index 865fc12a96..03a809c0d8 100644 --- a/frontend/packages/app/package.json +++ b/frontend/packages/app/package.json @@ -23,10 +23,10 @@ ] }, "scripts": { - "start": "cross-env SKIP_PREFLIGHT_CHECK=true react-scripts start", - "build": "cross-env SKIP_PREFLIGHT_CHECK=true react-scripts build", - "test": "cross-env SKIP_PREFLIGHT_CHECK=true react-scripts test", - "lint": "eslint ./src/**/*.{ts,tsx} --max-warnings=0 --format=codeframe" + "start": "cross-env EXTEND_ESLINT=true SKIP_PREFLIGHT_CHECK=true react-scripts start", + "build": "cross-env EXTEND_ESLINT=true SKIP_PREFLIGHT_CHECK=true react-scripts build", + "test": "cross-env EXTEND_ESLINT=true SKIP_PREFLIGHT_CHECK=true react-scripts test", + "lint": "cross-env EXTEND_ESLINT=true eslint ./src/**/*.{ts,tsx} --max-warnings=0 --format=codeframe" }, "eslintConfig": { "extends": "react-app" diff --git a/frontend/packages/plugins/hello-world/package.json b/frontend/packages/plugins/hello-world/package.json index 9bcc5247ad..d63c6f3d7a 100644 --- a/frontend/packages/plugins/hello-world/package.json +++ b/frontend/packages/plugins/hello-world/package.json @@ -5,6 +5,8 @@ "main:src": "src/index.ts", "devDependencies": { "@backstage/core": "0.0.0", + "@material-ui/core": "^4.9.1", + "@material-ui/icons": "^4.9.1", "@spotify/web-scripts": "^6.0.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", @@ -13,14 +15,15 @@ "@types/node": "^12.0.0", "@types/react": "^16.9.0", "@types/react-dom": "^16.9.0", + "google-protobuf": "^3.11.2", + "grpc-web": "^1.0.7", "react": "^16.12.0", - "react-dom": "^16.12.0", - "@material-ui/core": "^4.9.1", - "@material-ui/icons": "^4.9.1" + "react-dom": "^16.12.0" }, "scripts": { "lint": "web-scripts lint", - "test": "web-scripts test" + "test": "web-scripts test", + "proto": "../../../scripts/gen-proto.sh hello.proto" }, "license": "Apache-2.0" } diff --git a/frontend/packages/plugins/hello-world/src/components/MyComponent/MyComponent.tsx b/frontend/packages/plugins/hello-world/src/components/MyComponent/MyComponent.tsx index 95a8ec28ab..ec28306367 100644 --- a/frontend/packages/plugins/hello-world/src/components/MyComponent/MyComponent.tsx +++ b/frontend/packages/plugins/hello-world/src/components/MyComponent/MyComponent.tsx @@ -1,15 +1,43 @@ -import React, { FC } from 'react'; +import React, { FC, useState, useEffect } from 'react'; import Button from '@material-ui/core/Button'; +import { HelloPromiseClient } from '../../proto/hello_grpc_web_pb'; +import { HelloRequest } from '../../proto/hello_pb'; +import { Paper, Typography } from '@material-ui/core'; const MyComponent: FC<{}> = () => { + const [message, setMessage] = useState(''); + const [error, setError] = useState(); + + useEffect(() => { + const client = new HelloPromiseClient('http://localhost:8080'); + + const request = new HelloRequest(); + request.setName('Spotify'); + + client.hello(request).then( + reply => { + setMessage(reply.getMessage() ?? ''); + }, + err => { + setError(err.message); + }, + ); + }, []); + return ( - + + {message} + + {error} + + + ); }; diff --git a/frontend/packages/plugins/hello-world/src/proto/hello_grpc_web_pb.d.ts b/frontend/packages/plugins/hello-world/src/proto/hello_grpc_web_pb.d.ts new file mode 100644 index 0000000000..1831161b3b --- /dev/null +++ b/frontend/packages/plugins/hello-world/src/proto/hello_grpc_web_pb.d.ts @@ -0,0 +1,32 @@ +import * as grpcWeb from 'grpc-web'; + +import { + HelloReply, + HelloRequest} from './hello_pb'; + +export class HelloClient { + constructor (hostname: string, + credentials?: null | { [index: string]: string; }, + options?: null | { [index: string]: string; }); + + hello( + request: HelloRequest, + metadata: grpcWeb.Metadata | undefined, + callback: (err: grpcWeb.Error, + response: HelloReply) => void + ): grpcWeb.ClientReadableStream; + +} + +export class HelloPromiseClient { + constructor (hostname: string, + credentials?: null | { [index: string]: string; }, + options?: null | { [index: string]: string; }); + + hello( + request: HelloRequest, + metadata?: grpcWeb.Metadata + ): Promise; + +} + diff --git a/frontend/packages/plugins/hello-world/src/proto/hello_grpc_web_pb.js b/frontend/packages/plugins/hello-world/src/proto/hello_grpc_web_pb.js new file mode 100644 index 0000000000..6c34f67199 --- /dev/null +++ b/frontend/packages/plugins/hello-world/src/proto/hello_grpc_web_pb.js @@ -0,0 +1,153 @@ +/** + * @fileoverview gRPC-Web generated client stub for spotify.backstage.hello.v1alpha1 + * @enhanceable + * @public + */ + +// GENERATED CODE -- DO NOT EDIT! + + + +const grpc = {}; +grpc.web = require('grpc-web'); + +const proto = {}; +proto.spotify = {}; +proto.spotify.backstage = {}; +proto.spotify.backstage.hello = {}; +proto.spotify.backstage.hello.v1alpha1 = require('./hello_pb.js'); + +/** + * @param {string} hostname + * @param {?Object} credentials + * @param {?Object} options + * @constructor + * @struct + * @final + */ +proto.spotify.backstage.hello.v1alpha1.HelloClient = + function(hostname, credentials, options) { + if (!options) options = {}; + options['format'] = 'text'; + + /** + * @private @const {!grpc.web.GrpcWebClientBase} The client + */ + this.client_ = new grpc.web.GrpcWebClientBase(options); + + /** + * @private @const {string} The hostname + */ + this.hostname_ = hostname; + +}; + + +/** + * @param {string} hostname + * @param {?Object} credentials + * @param {?Object} options + * @constructor + * @struct + * @final + */ +proto.spotify.backstage.hello.v1alpha1.HelloPromiseClient = + function(hostname, credentials, options) { + if (!options) options = {}; + options['format'] = 'text'; + + /** + * @private @const {!grpc.web.GrpcWebClientBase} The client + */ + this.client_ = new grpc.web.GrpcWebClientBase(options); + + /** + * @private @const {string} The hostname + */ + this.hostname_ = hostname; + +}; + + +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.spotify.backstage.hello.v1alpha1.HelloRequest, + * !proto.spotify.backstage.hello.v1alpha1.HelloReply>} + */ +const methodDescriptor_Hello_Hello = new grpc.web.MethodDescriptor( + '/spotify.backstage.hello.v1alpha1.Hello/Hello', + grpc.web.MethodType.UNARY, + proto.spotify.backstage.hello.v1alpha1.HelloRequest, + proto.spotify.backstage.hello.v1alpha1.HelloReply, + /** + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.spotify.backstage.hello.v1alpha1.HelloReply.deserializeBinary +); + + +/** + * @const + * @type {!grpc.web.AbstractClientBase.MethodInfo< + * !proto.spotify.backstage.hello.v1alpha1.HelloRequest, + * !proto.spotify.backstage.hello.v1alpha1.HelloReply>} + */ +const methodInfo_Hello_Hello = new grpc.web.AbstractClientBase.MethodInfo( + proto.spotify.backstage.hello.v1alpha1.HelloReply, + /** + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.spotify.backstage.hello.v1alpha1.HelloReply.deserializeBinary +); + + +/** + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.Error, ?proto.spotify.backstage.hello.v1alpha1.HelloReply)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.spotify.backstage.hello.v1alpha1.HelloClient.prototype.hello = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/spotify.backstage.hello.v1alpha1.Hello/Hello', + request, + metadata || {}, + methodDescriptor_Hello_Hello, + callback); +}; + + +/** + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @return {!Promise} + * A native promise that resolves to the response + */ +proto.spotify.backstage.hello.v1alpha1.HelloPromiseClient.prototype.hello = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/spotify.backstage.hello.v1alpha1.Hello/Hello', + request, + metadata || {}, + methodDescriptor_Hello_Hello); +}; + + +module.exports = proto.spotify.backstage.hello.v1alpha1; + diff --git a/frontend/packages/plugins/hello-world/src/proto/hello_pb.d.ts b/frontend/packages/plugins/hello-world/src/proto/hello_pb.d.ts new file mode 100644 index 0000000000..a31b66ae91 --- /dev/null +++ b/frontend/packages/plugins/hello-world/src/proto/hello_pb.d.ts @@ -0,0 +1,38 @@ +import * as jspb from "google-protobuf" + +export class HelloRequest extends jspb.Message { + getName(): string; + setName(value: string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): HelloRequest.AsObject; + static toObject(includeInstance: boolean, msg: HelloRequest): HelloRequest.AsObject; + static serializeBinaryToWriter(message: HelloRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): HelloRequest; + static deserializeBinaryFromReader(message: HelloRequest, reader: jspb.BinaryReader): HelloRequest; +} + +export namespace HelloRequest { + export type AsObject = { + name: string, + } +} + +export class HelloReply extends jspb.Message { + getMessage(): string; + setMessage(value: string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): HelloReply.AsObject; + static toObject(includeInstance: boolean, msg: HelloReply): HelloReply.AsObject; + static serializeBinaryToWriter(message: HelloReply, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): HelloReply; + static deserializeBinaryFromReader(message: HelloReply, reader: jspb.BinaryReader): HelloReply; +} + +export namespace HelloReply { + export type AsObject = { + message: string, + } +} + diff --git a/frontend/packages/plugins/hello-world/src/proto/hello_pb.js b/frontend/packages/plugins/hello-world/src/proto/hello_pb.js new file mode 100644 index 0000000000..57ad1c7fc9 --- /dev/null +++ b/frontend/packages/plugins/hello-world/src/proto/hello_pb.js @@ -0,0 +1,308 @@ +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +goog.exportSymbol('proto.spotify.backstage.hello.v1alpha1.HelloReply', null, global); +goog.exportSymbol('proto.spotify.backstage.hello.v1alpha1.HelloRequest', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spotify.backstage.hello.v1alpha1.HelloRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spotify.backstage.hello.v1alpha1.HelloRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spotify.backstage.hello.v1alpha1.HelloRequest.displayName = 'proto.spotify.backstage.hello.v1alpha1.HelloRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.spotify.backstage.hello.v1alpha1.HelloReply = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.spotify.backstage.hello.v1alpha1.HelloReply, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.spotify.backstage.hello.v1alpha1.HelloReply.displayName = 'proto.spotify.backstage.hello.v1alpha1.HelloReply'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.spotify.backstage.hello.v1alpha1.HelloRequest.prototype.toObject = function(opt_includeInstance) { + return proto.spotify.backstage.hello.v1alpha1.HelloRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spotify.backstage.hello.v1alpha1.HelloRequest.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spotify.backstage.hello.v1alpha1.HelloRequest} + */ +proto.spotify.backstage.hello.v1alpha1.HelloRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spotify.backstage.hello.v1alpha1.HelloRequest; + return proto.spotify.backstage.hello.v1alpha1.HelloRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spotify.backstage.hello.v1alpha1.HelloRequest} + */ +proto.spotify.backstage.hello.v1alpha1.HelloRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spotify.backstage.hello.v1alpha1.HelloRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spotify.backstage.hello.v1alpha1.HelloRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spotify.backstage.hello.v1alpha1.HelloRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.spotify.backstage.hello.v1alpha1.HelloRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.spotify.backstage.hello.v1alpha1.HelloRequest.prototype.setName = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.spotify.backstage.hello.v1alpha1.HelloReply.prototype.toObject = function(opt_includeInstance) { + return proto.spotify.backstage.hello.v1alpha1.HelloReply.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloReply} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spotify.backstage.hello.v1alpha1.HelloReply.toObject = function(includeInstance, msg) { + var f, obj = { + message: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.spotify.backstage.hello.v1alpha1.HelloReply} + */ +proto.spotify.backstage.hello.v1alpha1.HelloReply.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.spotify.backstage.hello.v1alpha1.HelloReply; + return proto.spotify.backstage.hello.v1alpha1.HelloReply.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloReply} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.spotify.backstage.hello.v1alpha1.HelloReply} + */ +proto.spotify.backstage.hello.v1alpha1.HelloReply.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.spotify.backstage.hello.v1alpha1.HelloReply.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.spotify.backstage.hello.v1alpha1.HelloReply.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.spotify.backstage.hello.v1alpha1.HelloReply} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.spotify.backstage.hello.v1alpha1.HelloReply.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMessage(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.spotify.backstage.hello.v1alpha1.HelloReply.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.spotify.backstage.hello.v1alpha1.HelloReply.prototype.setMessage = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +goog.object.extend(exports, proto.spotify.backstage.hello.v1alpha1); diff --git a/frontend/scripts/gen-proto.sh b/frontend/scripts/gen-proto.sh new file mode 100755 index 0000000000..eb0618ca83 --- /dev/null +++ b/frontend/scripts/gen-proto.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +OUT='src/proto' + +mkdir -p "$OUT" + +exec protoc -I="$DIR/../../protos" --js_out=import_style=commonjs:"$OUT" --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:"$OUT" "$@" diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 7286a519f5..fc348a1cce 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -5591,14 +5591,14 @@ debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: dependencies: ms "^2.1.1" -debug@^3.0.0, debug@^3.1.0, debug@^3.1.1, debug@^3.2.5, debug@^3.2.6: +debug@^3.0.0, debug@^3.1.0, debug@^3.1.1, debug@^3.2.5: version "3.2.6" resolved "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== dependencies: ms "^2.1.1" -debuglog@*, debuglog@^1.0.1: +debuglog@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= @@ -5753,11 +5753,6 @@ detect-indent@^5.0.0, detect-indent@~5.0.0: resolved "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d" integrity sha1-OHHMCmoALow+Wzz38zYmRnXwa50= -detect-libc@^1.0.2: - version "1.0.3" - resolved "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - detect-newline@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2" @@ -7472,6 +7467,11 @@ globby@^9.2.0: pify "^4.0.1" slash "^2.0.0" +google-protobuf@^3.11.2: + version "3.11.2" + resolved "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.11.2.tgz#43272974521a5cec35a21f62730cf517a5a8e38c" + integrity sha512-T4fin7lcYLUPj2ChUZ4DvfuuHtg3xi1621qeRZt2J7SvOQusOzq+sDT4vbotWTCjUXJoR36CA016LlhtPy80uQ== + got@^6.7.1: version "6.7.1" resolved "https://registry.npmjs.org/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" @@ -7499,6 +7499,11 @@ growly@^1.3.0: resolved "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= +grpc-web@^1.0.7: + version "1.0.7" + resolved "https://registry.npmjs.org/grpc-web/-/grpc-web-1.0.7.tgz#9e4fbcf63d3734515332ab59e42baa7d0d290015" + integrity sha512-Fkbz1nyvvt6GC6ODcxh9Fen6LLB3OTCgGHzHwM2Eni44SUhzqPz1UQgFp9sfBEfInOhx3yBdwo9ZLjZAmJ+TtA== + gzip-size@5.1.1: version "5.1.1" resolved "https://registry.npmjs.org/gzip-size/-/gzip-size-5.1.1.tgz#cb9bee692f87c0612b232840a873904e4c135274" @@ -7880,7 +7885,7 @@ hyphenate-style-name@^1.0.3: resolved "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.3.tgz#097bb7fa0b8f1a9cf0bd5c734cf95899981a9b48" integrity sha512-EcuixamT82oplpoJ2XU4pDtKGWQ7b00CD9f1ug9IaQ3p1bkHMiKCZ9ut9QDI6qsa6cpUuB+A/I+zLtdNK4n2DQ== -iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13: +iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@~0.4.13: version "0.4.24" resolved "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -8001,7 +8006,7 @@ import-local@^3.0.2: pkg-dir "^4.2.0" resolve-cwd "^3.0.0" -imurmurhash@*, imurmurhash@^0.1.4: +imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= @@ -10184,11 +10189,6 @@ lockfile@^1.0.4: dependencies: signal-exit "^3.0.2" -lodash._baseindexof@*: - version "3.1.0" - resolved "https://registry.npmjs.org/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c" - integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw= - lodash._baseuniq@~4.6.0: version "4.6.0" resolved "https://registry.npmjs.org/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" @@ -10197,33 +10197,11 @@ lodash._baseuniq@~4.6.0: lodash._createset "~4.0.0" lodash._root "~3.0.0" -lodash._bindcallback@*: - version "3.0.1" - resolved "https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" - integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4= - -lodash._cacheindexof@*: - version "3.0.2" - resolved "https://registry.npmjs.org/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92" - integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI= - -lodash._createcache@*: - version "3.1.2" - resolved "https://registry.npmjs.org/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093" - integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM= - dependencies: - lodash._getnative "^3.0.0" - lodash._createset@~4.0.0: version "4.0.3" resolved "https://registry.npmjs.org/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY= -lodash._getnative@*, lodash._getnative@^3.0.0: - version "3.9.1" - resolved "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" - integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U= - lodash._reinterpolate@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" @@ -10279,11 +10257,6 @@ lodash.memoize@4.x, lodash.memoize@^4.1.2: resolved "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= -lodash.restparam@*: - version "3.6.1" - resolved "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" - integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU= - lodash.set@^4.3.2: version "4.3.2" resolved "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" @@ -10984,15 +10957,6 @@ natural-compare@^1.4.0: resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= -needle@^2.2.1: - version "2.4.0" - resolved "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz#6833e74975c444642590e15a750288c5f939b57c" - integrity sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg== - dependencies: - debug "^3.2.6" - iconv-lite "^0.4.4" - sax "^1.2.4" - negotiator@0.6.2: version "0.6.2" resolved "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" @@ -11129,22 +11093,6 @@ node-notifier@^6.0.0: shellwords "^0.1.1" which "^1.3.1" -node-pre-gyp@*: - version "0.14.0" - resolved "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz#9a0596533b877289bcad4e143982ca3d904ddc83" - integrity sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.1" - needle "^2.2.1" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4.4.2" - node-releases@^1.1.47: version "1.1.47" resolved "https://registry.npmjs.org/node-releases/-/node-releases-1.1.47.tgz#c59ef739a1fd7ecbd9f0b7cf5b7871e8a8b591e4" @@ -11273,7 +11221,7 @@ npm-normalize-package-bin@^1.0.0, npm-normalize-package-bin@^1.0.1: semver "^5.6.0" validate-npm-package-name "^3.0.0" -npm-packlist@^1.1.12, npm-packlist@^1.1.6, npm-packlist@^1.4.4, npm-packlist@^1.4.7: +npm-packlist@^1.1.12, npm-packlist@^1.4.4, npm-packlist@^1.4.7: version "1.4.8" resolved "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.8.tgz#56ee6cc135b9f98ad3d51c1c95da22bbb9b2ef3e" integrity sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A== @@ -11453,7 +11401,7 @@ npm@^6.10.3: worker-farm "^1.7.0" write-file-atomic "^2.4.3" -npmlog@^4.0.2, npmlog@^4.1.2, npmlog@~4.1.2: +npmlog@^4.1.2, npmlog@~4.1.2: version "4.1.2" resolved "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== @@ -13234,7 +13182,7 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -rc@^1.0.1, rc@^1.1.6, rc@^1.2.7, rc@^1.2.8: +rc@^1.0.1, rc@^1.1.6, rc@^1.2.8: version "1.2.8" resolved "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== @@ -13928,7 +13876,7 @@ rimraf@2.6.3: dependencies: glob "^7.1.3" -rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@^2.7.1: +rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@^2.7.1: version "2.7.1" resolved "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== @@ -14141,7 +14089,7 @@ semver-regex@^2.0.0: resolved "https://registry.npmjs.org/semver-regex/-/semver-regex-2.0.0.tgz#a93c2c5844539a770233379107b38c7b4ac9d338" integrity sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw== -"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", "semver@^2.3.0 || 3.x || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0, semver@^5.7.1: +"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", "semver@^2.3.0 || 3.x || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.4.1, semver@^5.5, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0, semver@^5.7.1: version "5.7.1" resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -15049,7 +14997,7 @@ tapable@^1.0.0, tapable@^1.1.0, tapable@^1.1.3: resolved "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== -tar@^4.4.10, tar@^4.4.12, tar@^4.4.13, tar@^4.4.2, tar@^4.4.8: +tar@^4.4.10, tar@^4.4.12, tar@^4.4.13, tar@^4.4.8: version "4.4.13" resolved "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== From 44ee4fa030478237b9e1ae65f23dafb8325fad06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jefferson=20Gir=C3=A3o?= Date: Tue, 4 Feb 2020 09:20:15 +0100 Subject: [PATCH 3/5] chore: add CI worflow for inventory backend --- .github/workflows/inventory.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/inventory.yml diff --git a/.github/workflows/inventory.yml b/.github/workflows/inventory.yml new file mode 100644 index 0000000000..79d0dfb59a --- /dev/null +++ b/.github/workflows/inventory.yml @@ -0,0 +1,29 @@ +name: Inventory CI + +on: + push: + paths: + - 'backend/inventory/**' + - '.github/workflows/inventory.yml' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.12 + - name: checkout code + uses: actions/checkout@v1 + - name: setup env + run: | + echo "::set-env name=GOPATH::$(go env GOPATH)" + echo "::add-path::$(go env GOPATH)/bin" + shell: bash + - name: build + run: go build -v ./... + working-directory: ./backend/inventory + - name: test + run: go test ./... -short + working-directory: ./backend/inventory \ No newline at end of file From 751586c38ad116db02fc0f5a04a3a441611f6622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jefferson=20Gir=C3=A3o?= Date: Tue, 4 Feb 2020 09:22:21 +0100 Subject: [PATCH 4/5] chore: restrict frontend ci to its workflow --- .github/workflows/frontend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index caf26c9803..cf22a5b4c5 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -4,7 +4,7 @@ on: push: paths: - 'frontend/**' - - '.github/**' + - '.github/workflows/frontend.yml' jobs: build: From b22636bcd658b6dbecaa10da9022f67103130691 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 4 Feb 2020 10:33:36 +0100 Subject: [PATCH 5/5] Fix broken test on master for /frontend --- frontend/packages/app/src/App.test.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/packages/app/src/App.test.tsx b/frontend/packages/app/src/App.test.tsx index b795396d0c..a4b304af28 100644 --- a/frontend/packages/app/src/App.test.tsx +++ b/frontend/packages/app/src/App.test.tsx @@ -5,7 +5,8 @@ import App from './App'; describe('App', () => { it('renders learn react link', () => { const rendered = render(); - rendered.getByText('This is Backstage with plugin hello-world'); - rendered.getByText('Hello!'); + rendered.getByText('This is Backstage!'); + rendered.getByText('Backstage is an open platform for building developer portals'); + rendered.getByText('…with plugin hello-world:'); }); });