Merge pull request #97 from spotify/blam/options
Pushing the correct folder to Github
This commit is contained in:
@@ -6,6 +6,9 @@ import (
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
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"
|
||||
@@ -21,10 +24,18 @@ type Server struct {
|
||||
fs *fs.Filesystem
|
||||
cookie *lib.Cutter
|
||||
git *lib.Git
|
||||
inventory inventory.InventoryClient
|
||||
}
|
||||
|
||||
// NewServer creates a new server for with all the things
|
||||
func NewServer() *Server {
|
||||
// conn, errc := grpc.Dial("http://inventory:50051")
|
||||
|
||||
// if err != nil {
|
||||
// log.Fatal("Cannot connect to inventory service")
|
||||
// }
|
||||
|
||||
//inventory: inventory.NewInventoryClient(conn),
|
||||
return &Server{
|
||||
github: lib.NewGithubClient(),
|
||||
}
|
||||
@@ -39,8 +50,9 @@ func (s *Server) Create(ctx context.Context, req *pb.CreateRequest) (*pb.CreateR
|
||||
Org: req.Org,
|
||||
Private: req.Private,
|
||||
}
|
||||
|
||||
if _, err := s.github.CreateRepository(repo); err != nil {
|
||||
return nil, status.Error(codes.Internal, fmt.Sprintf("Could not create repository %s/%s", req.Org, req.ComponentId))
|
||||
return nil, status.Error(codes.Internal, fmt.Sprintf("Could not create repository %s/%s %s", req.Org, req.ComponentId, err))
|
||||
}
|
||||
|
||||
// move the template into a temporary directory
|
||||
@@ -51,7 +63,7 @@ func (s *Server) Create(ctx context.Context, req *pb.CreateRequest) (*pb.CreateR
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, "Could not prepare the template")
|
||||
return nil, status.Error(codes.Internal, fmt.Sprintf("Could not prepare the template %s", err))
|
||||
}
|
||||
|
||||
// get the optional metadatafields from the json
|
||||
@@ -59,7 +71,7 @@ func (s *Server) Create(ctx context.Context, req *pb.CreateRequest) (*pb.CreateR
|
||||
cutterMetadata, err := marshaler.MarshalToString(req.Metadata)
|
||||
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, "Could not marshal the cookiecutter metadata")
|
||||
return nil, status.Error(codes.Internal, fmt.Sprintf("Could not marshal the cookiecutter metadata %s", err))
|
||||
}
|
||||
|
||||
cookieTemplate := lib.CookieCutterTemplate{
|
||||
@@ -86,7 +98,7 @@ func (s *Server) Create(ctx context.Context, req *pb.CreateRequest) (*pb.CreateR
|
||||
}
|
||||
|
||||
if err := s.git.Push(pushOptions); err != nil {
|
||||
return nil, status.Error(codes.Internal, "Failed to push the repository to Github")
|
||||
return nil, status.Error(codes.Internal, fmt.Sprintf("Failed to push the repository to Github %s", err))
|
||||
}
|
||||
|
||||
return &pb.CreateReply{
|
||||
|
||||
@@ -23,7 +23,11 @@ type PushRepositoryOptions struct {
|
||||
// Push will push the repository to github
|
||||
func (g *Git) Push(options PushRepositoryOptions) error {
|
||||
// use git bindings to add the remote with access token and push to the directory
|
||||
repo, err := git.PlainInit(options.TempFolder, false)
|
||||
repo, err := git.PlainInit(
|
||||
fmt.Sprintf("%s/%s", options.TempFolder, options.ComponentID),
|
||||
false,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Failed to init the git repository")
|
||||
return err
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"id": "android-kotlin-module",
|
||||
"name": "Kotlin Module",
|
||||
"description": "Kotlin module sample",
|
||||
"ownerId": "ownerId"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"id": "ios-swift-app-template",
|
||||
"name": "Swift App",
|
||||
"description": "The a sample swift app",
|
||||
"ownerId": "ownerId"
|
||||
}
|
||||
@@ -2,22 +2,5 @@
|
||||
"id": "react-ssr-template",
|
||||
"name": "React SSR",
|
||||
"description": "Next.js application skeleton for creating isomorphic web applications.",
|
||||
"ownerId": "ownerId",
|
||||
"fields": [
|
||||
{
|
||||
"id": "description",
|
||||
"title": "description",
|
||||
"type": "text",
|
||||
"description": "Description of the component",
|
||||
"validators": [
|
||||
{ "type": "required" },
|
||||
{ "type": "string-range", "min": 4, "max": 33 },
|
||||
{
|
||||
"type": "regex",
|
||||
"match": "^[a-z][a-z0-9]+$",
|
||||
"message": "Owner names must consist only of lowercase letters"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"ownerId": "ownerId"
|
||||
}
|
||||
@@ -41,6 +41,10 @@ services:
|
||||
env_file: secrets.env
|
||||
|
||||
scaffolder:
|
||||
depends_on:
|
||||
- inventory
|
||||
links:
|
||||
- inventory
|
||||
container_name: boss-scaffolder
|
||||
build:
|
||||
context: backend
|
||||
|
||||
+3
-3
@@ -9,11 +9,11 @@ NODE_DEBUG=true
|
||||
# This is the full HTTP endpoint to the GraphQL API you'll want to point to.
|
||||
# For example (in development): http://localhost:8080/graphql
|
||||
###
|
||||
REACT_APP_GRAPHQL_API=""
|
||||
REACT_APP_GRAPHQL_API=
|
||||
|
||||
###
|
||||
# A valid GitHub access token. You'll need to give it access to "repo".
|
||||
# To create one, visit https://github.com/settings/tokens in your browser.
|
||||
###
|
||||
BOSS_GH_USERNAME=""
|
||||
BOSS_GH_ACCESS_TOKEN=""
|
||||
BOSS_GH_USERNAME=
|
||||
BOSS_GH_ACCESS_TOKEN=
|
||||
|
||||
Reference in New Issue
Block a user