feat(scaffolder): register with inventory service

This commit is contained in:
blam
2020-02-07 15:33:31 +01:00
parent f44fa8f556
commit f465a5f0d2
2 changed files with 19 additions and 6 deletions
+1
View File
@@ -32,4 +32,5 @@ CMD ["./service"]
### needs extra cookiecutter
FROM default AS scaffolder
RUN apt-get update && apt-get install -y python-pip
RUN apt-get install -y python-backports.functools-lru-cache
RUN pip install cookiecutter==1.7.0 --index-url https://pypi.python.org/simple
+18 -6
View File
@@ -7,11 +7,11 @@ import (
identity "github.com/spotify/backstage/backend/proto/identity/v1"
pb "github.com/spotify/backstage/backend/proto/scaffolder/v1"
// "google.golang.org/grpc"
inventory "github.com/spotify/backstage/backend/proto/inventory/v1"
"github.com/spotify/backstage/scaffolder/fs"
"github.com/spotify/backstage/scaffolder/lib"
"github.com/spotify/backstage/scaffolder/repository"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"log"
@@ -29,15 +29,16 @@ type Server struct {
// NewServer creates a new server for with all the things
func NewServer() *Server {
// conn, errc := grpc.Dial("http://inventory:50051")
conn, err := grpc.Dial("inventory:50051", grpc.WithInsecure())
// if err != nil {
// log.Fatal("Cannot connect to inventory service")
// }
if err != nil {
log.Fatal("Cannot connect to inventory service")
}
//inventory: inventory.NewInventoryClient(conn),
return &Server{
github: lib.NewGithubClient(),
github: lib.NewGithubClient(),
inventory: inventory.NewInventoryClient(conn),
}
}
@@ -101,6 +102,17 @@ func (s *Server) Create(ctx context.Context, req *pb.CreateRequest) (*pb.CreateR
return nil, status.Error(codes.Internal, fmt.Sprintf("Failed to push the repository to Github %s", err))
}
// notify the inventory service
_, err = s.inventory.CreateEntity(context.Background(), &inventory.CreateEntityRequest{
Entity: &inventory.Entity{
Uri: fmt.Sprintf("boss://service/%s", req.ComponentId),
},
})
if err != nil {
return nil, status.Error(codes.Internal, fmt.Sprintf("Failed to register the entity in the inventory %s", err))
}
return &pb.CreateReply{
ComponentId: req.ComponentId,
}, nil