chore(scaffolder): moving around some files and bringing the project more in line with the inventory service
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/spotify/backstage/scaffolder/repository"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
pb "github.com/spotify/backstage/proto/scaffolder/v1"
|
||||
)
|
||||
|
||||
// Server is the inventory Grpc server
|
||||
type Server struct {
|
||||
Repository *repsoitory.Repository
|
||||
}
|
||||
|
||||
// GetAllTemplates returns the local templatess
|
||||
func (s *server) GetAllTemplates(ctx context.Context, req *pb.Empty) (*pb.GetAllTemplatesResponse, error) {
|
||||
err, localTemplates := s.repostiory.Load()
|
||||
template := &pb.Template{
|
||||
Id: "react-ssr-template",
|
||||
Name: "React SSR Template",
|
||||
User: &identity.User{
|
||||
Id: "spotify",
|
||||
Name: "Spotify",
|
||||
},
|
||||
}
|
||||
|
||||
templates := []*pb.Template{template}
|
||||
|
||||
return &pb.GetAllTemplatesResponse{
|
||||
Templates: templates,
|
||||
}, nil
|
||||
}
|
||||
@@ -5,8 +5,7 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
|
||||
identity "github.com/spotify/backstage/backend/proto/identity/v1"
|
||||
pb "github.com/spotify/backstage/backend/proto/scaffolder/v1"
|
||||
"github.com/spotify/backstage/scaffolder/app"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@@ -21,33 +20,7 @@ func main() {
|
||||
}
|
||||
|
||||
grpcServer := grpc.NewServer()
|
||||
pb.RegisterScaffolderServer(grpcServer, &server{})
|
||||
|
||||
pb.RegisterScaffolderServer(grpcServer, &app.Server{})
|
||||
log.Println("Serving Scaffolder Service")
|
||||
grpcServer.Serve(lis)
|
||||
}
|
||||
|
||||
// LocalTemplate json representation
|
||||
type LocalTemplate struct {
|
||||
ID string
|
||||
Name string
|
||||
}
|
||||
|
||||
type server struct{}
|
||||
|
||||
func (s *server) GetAllTemplates(ctx context.Context, req *pb.Empty) (*pb.GetAllTemplatesResponse, error) {
|
||||
template := &pb.Template{
|
||||
Id: "react-ssr-template",
|
||||
Name: "React SSR Template",
|
||||
User: &identity.User{
|
||||
Id: "spotify",
|
||||
Name: "Spotify",
|
||||
},
|
||||
}
|
||||
|
||||
templates := []*pb.Template{template}
|
||||
|
||||
return &pb.GetAllTemplatesResponse{
|
||||
Templates: templates,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Local Repository
|
||||
type Local struct{}
|
||||
|
||||
// TemplateDefinition maps to whats stored in the repo
|
||||
type TemplateDefinition struct {
|
||||
ID string
|
||||
Name string
|
||||
Description string
|
||||
OwnerID string
|
||||
}
|
||||
|
||||
// Load will return all the local templates
|
||||
func (s *Local) Load() ([]*TemplateDefinition, error) {
|
||||
matches, err := filepath.Glob("templates/**/template-info.json")
|
||||
fmt.Println(matches)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"id": "react-ssr-template",
|
||||
"name": "React SSR",
|
||||
"description": "Next.js application skeleton for creating isomorphic web applications.",
|
||||
"ownerId": "ownerId"
|
||||
}
|
||||
Reference in New Issue
Block a user