Migrate all components to new svcname convention
This commit is contained in:
Родитель
92e523bb18
Коммит
86968f8cb5
|
@ -10,7 +10,7 @@ package echo;
|
|||
|
||||
import "github.com/TuneLab/go-genproto/googleapis/api/serviceconfig/annotations.proto";
|
||||
|
||||
service Echo {
|
||||
service BounceEcho {
|
||||
// Echo "echos" the incoming string
|
||||
rpc Echo (EchoRequest) returns (EchoResponse) {
|
||||
option (google.api.http) = {
|
||||
|
|
|
@ -14,8 +14,8 @@ in a sane way, even for requests not made with the generated HTTP client.
|
|||
|
||||
The test harness works as follows:
|
||||
|
||||
- Runs truss against `transport/transport-test.proto`, which generates `transport/transport-service`
|
||||
- Copy `transport/handlers` into `transport/transport-service`
|
||||
- Runs truss against `transport/transport-test.proto`, which generates `transport/TransportPermutations-service`
|
||||
- Copy `transport/handlers` into `transport/TransportPermutations-service`
|
||||
- Run `go test -v`
|
||||
- Runs truss again against `transport/transport-test.proto` (for regeneration tests)
|
||||
- Run `go test -v`
|
||||
|
|
|
@ -14,7 +14,7 @@ all: test
|
|||
test:
|
||||
@echo -e '$(TRUSS_MSG)'
|
||||
truss transport-test.proto
|
||||
cp -r handlers transport-service
|
||||
cp -r handlers TransportPermutations-service
|
||||
@echo -e '$(TEST_RUNNING_MSG)'
|
||||
go test -v
|
||||
@echo -e '$(TRUSS_AGAIN_MSG)'
|
||||
|
@ -24,4 +24,4 @@ test:
|
|||
$(MAKE) clean
|
||||
|
||||
clean:
|
||||
rm -rf transport-service
|
||||
rm -rf TransportPermutations-service
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
pb "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/transport-service"
|
||||
grpcclient "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/transport-service/generated/client/grpc"
|
||||
pb "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/TransportPermutations-service"
|
||||
grpcclient "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/TransportPermutations-service/generated/client/grpc"
|
||||
)
|
||||
|
||||
var grpcAddr string
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
pb "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/transport-service"
|
||||
pb "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/TransportPermutations-service"
|
||||
)
|
||||
|
||||
// NewService returns a naïve, stateless implementation of Service.
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
// 3d Party
|
||||
"golang.org/x/net/context"
|
||||
// This Service
|
||||
pb "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/transport-service"
|
||||
httpclient "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/transport-service/generated/client/http"
|
||||
pb "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/TransportPermutations-service"
|
||||
httpclient "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/TransportPermutations-service/generated/client/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
|
|
@ -14,9 +14,9 @@ import (
|
|||
// Go Kit
|
||||
"github.com/go-kit/kit/log"
|
||||
|
||||
pb "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/transport-service"
|
||||
svc "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/transport-service/generated"
|
||||
handler "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/transport-service/handlers/server"
|
||||
pb "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/TransportPermutations-service"
|
||||
svc "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/TransportPermutations-service/generated"
|
||||
handler "github.com/TuneLab/go-truss/cmd/_integration-tests/transport/TransportPermutations-service/handlers/server"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
|
|
@ -112,6 +112,7 @@ func parseInput() (*truss.Config, error) {
|
|||
|
||||
// Service Path
|
||||
svcName, err := parsesvcname.FromPaths(cfg.GoPath, cfg.DefPaths)
|
||||
svcName = strings.ToLower(svcName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "cannot parse service name from the provided definition files")
|
||||
}
|
||||
|
@ -171,6 +172,8 @@ func parseInput() (*truss.Config, error) {
|
|||
log.WithField("PB Package", cfg.PBPackage).Debug()
|
||||
log.WithField("PB Path", cfg.PBPath).Debug()
|
||||
|
||||
log.Debug(fmt.Sprintf("%#v", cfg))
|
||||
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,17 @@ import (
|
|||
"github.com/TuneLab/go-truss/deftree"
|
||||
)
|
||||
|
||||
func findServiceName(md *deftree.MicroserviceDefinition) string {
|
||||
rv := "default"
|
||||
for _, f := range md.Files {
|
||||
for _, svc := range f.Services {
|
||||
rv = svc.GetName()
|
||||
}
|
||||
}
|
||||
return rv
|
||||
|
||||
}
|
||||
|
||||
// GenerateDocs accepts a deftree that represents an ast of a group of
|
||||
// protofiles and returns map[string]io.Reader that represents a relative
|
||||
// filestructure of generated docs
|
||||
|
@ -23,7 +34,9 @@ func GenerateDocs(dt deftree.Deftree) map[string]io.Reader {
|
|||
}
|
||||
|
||||
files := make(map[string]io.Reader)
|
||||
files[dt.GetName()+"-service/docs/docs.md"] = strings.NewReader(response)
|
||||
md := dt.(*deftree.MicroserviceDefinition)
|
||||
svcname := strings.ToLower(findServiceName(md))
|
||||
files[svcname+"-service/docs/docs.md"] = strings.NewReader(response)
|
||||
|
||||
return files
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ func GenerateGokit(sd *svcdef.Svcdef, conf gengokit.Config) (map[string]io.Reade
|
|||
codeGenFiles := make(map[string]io.Reader)
|
||||
|
||||
for _, templPath := range templFiles.AssetNames() {
|
||||
actualPath := templatePathToActual(templPath, sd.PkgName)
|
||||
actualPath := templatePathToActual(templPath, strings.ToLower(sd.Service.Name))
|
||||
file, err := generateResponseFile(templPath, data, conf.PreviousFiles[actualPath])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "cannot render template")
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// Package parsesvcname will parse the service name of a protobuf package. The name returned will always be camelcased.
|
||||
package parsesvcname
|
||||
|
||||
import (
|
||||
|
|
Загрузка…
Ссылка в новой задаче