Merge pull request #98 from spotify/blam/options
Notify the Inventory Service when a new Component is created
This commit is contained in:
+1
-1
@@ -31,6 +31,6 @@ CMD ["./service"]
|
||||
### Scaffolder Stage
|
||||
### needs extra cookiecutter
|
||||
FROM default AS scaffolder
|
||||
RUN apt-get update && apt-get install -y python-pip
|
||||
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
|
||||
|
||||
@@ -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,15 @@ 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 +101,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(ctx, &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
|
||||
|
||||
Reference in New Issue
Block a user