From 7d770ef150ca5db366a1c41d451afb0434e21b7a Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 10 Jul 2019 22:33:22 -0400 Subject: [PATCH] Move service related filed to services folder --- Dockerfile => services/Dockerfile | 4 ++-- Makefile => services/Makefile | 0 README.md => services/README.md | 0 {cli => services/cli}/commands/decrypt.go | 4 ++-- {cli => services/cli}/commands/decrypt_cfg.go | 2 +- {cli => services/cli}/commands/encrypt.go | 4 ++-- {cli => services/cli}/commands/init.go | 2 +- {cli => services/cli}/commands/root.go | 10 +++++----- {cli => services/cli}/repositories/config.go | 4 ++-- {cli => services/cli}/types/types.go | 0 {cmd => services/cmd}/server/server.go | 12 ++++++------ {cmd => services/cmd}/spc/main.go | 2 +- .../credentials}/commands/commands.go | 2 +- .../credentials}/commands/create.go | 6 +++--- .../credentials}/commands/delete.go | 0 .../credentials}/commands/gcm-to-cbc.go | 6 +++--- .../credentials}/commands/get.go | 4 ++-- .../credentials}/commands/list.go | 2 +- .../credentials}/commands/update.go | 6 +++--- .../credentials}/endpoints/endpoints.go | 2 +- .../credentials}/middleware/logger.go | 2 +- .../credentials}/protobuf/service.pb.go | 0 .../credentials}/protobuf/service.proto | 0 .../credentials}/repositories/grpc_client.go | 8 ++++---- .../credentials}/repositories/redis.go | 2 +- .../credentials}/service/service.go | 2 +- .../credentials}/transport/encoding.go | 6 +++--- .../credentials}/transport/grpc_server.go | 6 +++--- .../credentials}/types/credential.go | 0 .../credentials}/types/error_prefixes.go | 0 .../credentials}/types/interfaces.go | 0 {crypto => services/crypto}/cbc.go | 0 {crypto => services/crypto}/gcm.go | 0 {crypto => services/crypto}/helpers.go | 0 {crypto => services/crypto}/pbkdf2.go | 0 .../docker-compose.prod.yml | 0 docker-compose.yml => services/docker-compose.yml | 0 gen_certs_go.sh => services/gen_certs_go.sh | 0 go.mod => services/go.mod | 2 +- go.sum => services/go.sum | 0 redis.conf => services/redis.conf | 0 41 files changed, 50 insertions(+), 50 deletions(-) rename Dockerfile => services/Dockerfile (63%) rename Makefile => services/Makefile (100%) rename README.md => services/README.md (100%) rename {cli => services/cli}/commands/decrypt.go (91%) rename {cli => services/cli}/commands/decrypt_cfg.go (91%) rename {cli => services/cli}/commands/encrypt.go (90%) rename {cli => services/cli}/commands/init.go (97%) rename {cli => services/cli}/commands/root.go (83%) rename {cli => services/cli}/repositories/config.go (97%) rename {cli => services/cli}/types/types.go (100%) rename {cmd => services/cmd}/server/server.go (85%) rename {cmd => services/cmd}/spc/main.go (53%) rename {credentials => services/credentials}/commands/commands.go (96%) rename {credentials => services/credentials}/commands/create.go (95%) rename {credentials => services/credentials}/commands/delete.go (100%) rename {credentials => services/credentials}/commands/gcm-to-cbc.go (93%) rename {credentials => services/credentials}/commands/get.go (95%) rename {credentials => services/credentials}/commands/list.go (96%) rename {credentials => services/credentials}/commands/update.go (96%) rename {credentials => services/credentials}/endpoints/endpoints.go (96%) rename {credentials => services/credentials}/middleware/logger.go (97%) rename {credentials => services/credentials}/protobuf/service.pb.go (100%) rename {credentials => services/credentials}/protobuf/service.proto (100%) rename {credentials => services/credentials}/repositories/grpc_client.go (92%) rename {credentials => services/credentials}/repositories/redis.go (96%) rename {credentials => services/credentials}/service/service.go (97%) rename {credentials => services/credentials}/transport/encoding.go (96%) rename {credentials => services/credentials}/transport/grpc_server.go (95%) rename {credentials => services/credentials}/types/credential.go (100%) rename {credentials => services/credentials}/types/error_prefixes.go (100%) rename {credentials => services/credentials}/types/interfaces.go (100%) rename {crypto => services/crypto}/cbc.go (100%) rename {crypto => services/crypto}/gcm.go (100%) rename {crypto => services/crypto}/helpers.go (100%) rename {crypto => services/crypto}/pbkdf2.go (100%) rename docker-compose.prod.yml => services/docker-compose.prod.yml (100%) rename docker-compose.yml => services/docker-compose.yml (100%) rename gen_certs_go.sh => services/gen_certs_go.sh (100%) rename go.mod => services/go.mod (95%) rename go.sum => services/go.sum (100%) rename redis.conf => services/redis.conf (100%) diff --git a/Dockerfile b/services/Dockerfile similarity index 63% rename from Dockerfile rename to services/Dockerfile index 04c7c5f..cd48a45 100644 --- a/Dockerfile +++ b/services/Dockerfile @@ -1,11 +1,11 @@ FROM golang:1.11.5 as build -WORKDIR /go/src/github.com/mitchell/selfpass +WORKDIR /go/src/github.com/mitchell/selfpass/services COPY . . ENV GO111MODULE on RUN make build FROM debian:stable-20190506-slim -COPY --from=build /go/src/github.com/mitchell/selfpass/bin/server /usr/bin/server +COPY --from=build /go/src/github.com/mitchell/selfpass/services/bin/server /usr/bin/server RUN groupadd -r selfpass && useradd --no-log-init -r -g selfpass selfpass USER selfpass WORKDIR /home/selfpass diff --git a/Makefile b/services/Makefile similarity index 100% rename from Makefile rename to services/Makefile diff --git a/README.md b/services/README.md similarity index 100% rename from README.md rename to services/README.md diff --git a/cli/commands/decrypt.go b/services/cli/commands/decrypt.go similarity index 91% rename from cli/commands/decrypt.go rename to services/cli/commands/decrypt.go index 76f008c..41dc213 100644 --- a/cli/commands/decrypt.go +++ b/services/cli/commands/decrypt.go @@ -7,8 +7,8 @@ import ( "github.com/spf13/cobra" - "github.com/mitchell/selfpass/cli/types" - "github.com/mitchell/selfpass/crypto" + "github.com/mitchell/selfpass/services/cli/types" + "github.com/mitchell/selfpass/services/crypto" ) func makeDecrypt(repo types.ConfigRepo) *cobra.Command { diff --git a/cli/commands/decrypt_cfg.go b/services/cli/commands/decrypt_cfg.go similarity index 91% rename from cli/commands/decrypt_cfg.go rename to services/cli/commands/decrypt_cfg.go index e0663a7..110b590 100644 --- a/cli/commands/decrypt_cfg.go +++ b/services/cli/commands/decrypt_cfg.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/cobra" - "github.com/mitchell/selfpass/cli/types" + "github.com/mitchell/selfpass/services/cli/types" ) func makeDecryptCfg(repo types.ConfigRepo) *cobra.Command { diff --git a/cli/commands/encrypt.go b/services/cli/commands/encrypt.go similarity index 90% rename from cli/commands/encrypt.go rename to services/cli/commands/encrypt.go index 046a88f..851bf05 100644 --- a/cli/commands/encrypt.go +++ b/services/cli/commands/encrypt.go @@ -7,8 +7,8 @@ import ( "github.com/spf13/cobra" - "github.com/mitchell/selfpass/cli/types" - "github.com/mitchell/selfpass/crypto" + "github.com/mitchell/selfpass/services/cli/types" + "github.com/mitchell/selfpass/services/crypto" ) func makeEncrypt(repo types.ConfigRepo) *cobra.Command { diff --git a/cli/commands/init.go b/services/cli/commands/init.go similarity index 97% rename from cli/commands/init.go rename to services/cli/commands/init.go index 774bae1..53c16c4 100644 --- a/cli/commands/init.go +++ b/services/cli/commands/init.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" "gopkg.in/AlecAivazis/survey.v1" - "github.com/mitchell/selfpass/cli/types" + "github.com/mitchell/selfpass/services/cli/types" ) func makeInit(repo types.ConfigRepo) *cobra.Command { diff --git a/cli/commands/root.go b/services/cli/commands/root.go similarity index 83% rename from cli/commands/root.go rename to services/cli/commands/root.go index 597af2e..665471f 100644 --- a/cli/commands/root.go +++ b/services/cli/commands/root.go @@ -7,11 +7,11 @@ import ( "github.com/spf13/cobra" - "github.com/mitchell/selfpass/cli/repositories" - "github.com/mitchell/selfpass/cli/types" - "github.com/mitchell/selfpass/credentials/commands" - credrepos "github.com/mitchell/selfpass/credentials/repositories" - credtypes "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/cli/repositories" + "github.com/mitchell/selfpass/services/cli/types" + "github.com/mitchell/selfpass/services/credentials/commands" + credrepos "github.com/mitchell/selfpass/services/credentials/repositories" + credtypes "github.com/mitchell/selfpass/services/credentials/types" ) func Execute() { diff --git a/cli/repositories/config.go b/services/cli/repositories/config.go similarity index 97% rename from cli/repositories/config.go rename to services/cli/repositories/config.go index 9a8fe47..edead04 100644 --- a/cli/repositories/config.go +++ b/services/cli/repositories/config.go @@ -13,8 +13,8 @@ import ( "github.com/spf13/viper" "gopkg.in/AlecAivazis/survey.v1" - "github.com/mitchell/selfpass/cli/types" - "github.com/mitchell/selfpass/crypto" + "github.com/mitchell/selfpass/services/cli/types" + "github.com/mitchell/selfpass/services/crypto" ) func NewConfigManager(cfgFile *string) *ConfigManager { diff --git a/cli/types/types.go b/services/cli/types/types.go similarity index 100% rename from cli/types/types.go rename to services/cli/types/types.go diff --git a/cmd/server/server.go b/services/cmd/server/server.go similarity index 85% rename from cmd/server/server.go rename to services/cmd/server/server.go index 4f07fbf..122d9a6 100644 --- a/cmd/server/server.go +++ b/services/cmd/server/server.go @@ -15,12 +15,12 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" - "github.com/mitchell/selfpass/credentials/middleware" - "github.com/mitchell/selfpass/credentials/protobuf" - "github.com/mitchell/selfpass/credentials/repositories" - "github.com/mitchell/selfpass/credentials/service" - "github.com/mitchell/selfpass/credentials/transport" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/middleware" + "github.com/mitchell/selfpass/services/credentials/protobuf" + "github.com/mitchell/selfpass/services/credentials/repositories" + "github.com/mitchell/selfpass/services/credentials/service" + "github.com/mitchell/selfpass/services/credentials/transport" + "github.com/mitchell/selfpass/services/credentials/types" ) var logger log.Logger diff --git a/cmd/spc/main.go b/services/cmd/spc/main.go similarity index 53% rename from cmd/spc/main.go rename to services/cmd/spc/main.go index d7061fe..e2ec57e 100644 --- a/cmd/spc/main.go +++ b/services/cmd/spc/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/mitchell/selfpass/cli/commands" + "github.com/mitchell/selfpass/services/cli/commands" ) func main() { diff --git a/credentials/commands/commands.go b/services/credentials/commands/commands.go similarity index 96% rename from credentials/commands/commands.go rename to services/credentials/commands/commands.go index 2e252f1..f5ff5f5 100644 --- a/credentials/commands/commands.go +++ b/services/credentials/commands/commands.go @@ -9,7 +9,7 @@ import ( "gopkg.in/AlecAivazis/survey.v1" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/types" ) type CredentialClientInit func(ctx context.Context) (c types.CredentialClient) diff --git a/credentials/commands/create.go b/services/credentials/commands/create.go similarity index 95% rename from credentials/commands/create.go rename to services/credentials/commands/create.go index cacb0dd..c835c50 100644 --- a/credentials/commands/create.go +++ b/services/credentials/commands/create.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/cobra" "gopkg.in/AlecAivazis/survey.v1" - clitypes "github.com/mitchell/selfpass/cli/types" - "github.com/mitchell/selfpass/credentials/types" - "github.com/mitchell/selfpass/crypto" + clitypes "github.com/mitchell/selfpass/services/cli/types" + "github.com/mitchell/selfpass/services/credentials/types" + "github.com/mitchell/selfpass/services/crypto" ) func MakeCreate(repo clitypes.ConfigRepo, initClient CredentialClientInit) *cobra.Command { diff --git a/credentials/commands/delete.go b/services/credentials/commands/delete.go similarity index 100% rename from credentials/commands/delete.go rename to services/credentials/commands/delete.go diff --git a/credentials/commands/gcm-to-cbc.go b/services/credentials/commands/gcm-to-cbc.go similarity index 93% rename from credentials/commands/gcm-to-cbc.go rename to services/credentials/commands/gcm-to-cbc.go index 42e1c06..1056fc0 100644 --- a/credentials/commands/gcm-to-cbc.go +++ b/services/credentials/commands/gcm-to-cbc.go @@ -7,9 +7,9 @@ import ( "fmt" "time" - clitypes "github.com/mitchell/selfpass/cli/types" - "github.com/mitchell/selfpass/credentials/types" - "github.com/mitchell/selfpass/crypto" + clitypes "github.com/mitchell/selfpass/services/cli/types" + "github.com/mitchell/selfpass/services/credentials/types" + "github.com/mitchell/selfpass/services/crypto" "github.com/spf13/cobra" ) diff --git a/credentials/commands/get.go b/services/credentials/commands/get.go similarity index 95% rename from credentials/commands/get.go rename to services/credentials/commands/get.go index 2dbafb6..4c6bd31 100644 --- a/credentials/commands/get.go +++ b/services/credentials/commands/get.go @@ -11,8 +11,8 @@ import ( "github.com/spf13/cobra" "gopkg.in/AlecAivazis/survey.v1" - clitypes "github.com/mitchell/selfpass/cli/types" - "github.com/mitchell/selfpass/crypto" + clitypes "github.com/mitchell/selfpass/services/cli/types" + "github.com/mitchell/selfpass/services/crypto" ) func MakeGet(repo clitypes.ConfigRepo, initClient CredentialClientInit) *cobra.Command { diff --git a/credentials/commands/list.go b/services/credentials/commands/list.go similarity index 96% rename from credentials/commands/list.go rename to services/credentials/commands/list.go index 2fc3073..60e6054 100644 --- a/credentials/commands/list.go +++ b/services/credentials/commands/list.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" "gopkg.in/AlecAivazis/survey.v1" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/types" ) func MakeList(initClient CredentialClientInit) *cobra.Command { diff --git a/credentials/commands/update.go b/services/credentials/commands/update.go similarity index 96% rename from credentials/commands/update.go rename to services/credentials/commands/update.go index 75706d9..80010e8 100644 --- a/credentials/commands/update.go +++ b/services/credentials/commands/update.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/cobra" "gopkg.in/AlecAivazis/survey.v1" - clitypes "github.com/mitchell/selfpass/cli/types" - "github.com/mitchell/selfpass/credentials/types" - "github.com/mitchell/selfpass/crypto" + clitypes "github.com/mitchell/selfpass/services/cli/types" + "github.com/mitchell/selfpass/services/credentials/types" + "github.com/mitchell/selfpass/services/crypto" ) func MakeUpdate(repo clitypes.ConfigRepo, initClient CredentialClientInit) *cobra.Command { diff --git a/credentials/endpoints/endpoints.go b/services/credentials/endpoints/endpoints.go similarity index 96% rename from credentials/endpoints/endpoints.go rename to services/credentials/endpoints/endpoints.go index 3711c6b..3622767 100644 --- a/credentials/endpoints/endpoints.go +++ b/services/credentials/endpoints/endpoints.go @@ -4,7 +4,7 @@ import ( "context" "github.com/go-kit/kit/endpoint" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/types" ) func MakeCreateEndpoint(svc types.Service) endpoint.Endpoint { diff --git a/credentials/middleware/logger.go b/services/credentials/middleware/logger.go similarity index 97% rename from credentials/middleware/logger.go rename to services/credentials/middleware/logger.go index b976e72..07471bd 100644 --- a/credentials/middleware/logger.go +++ b/services/credentials/middleware/logger.go @@ -5,7 +5,7 @@ import ( "time" "github.com/go-kit/kit/log" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/types" ) func NewServiceLogger(l log.Logger, next types.Service) ServiceLogger { diff --git a/credentials/protobuf/service.pb.go b/services/credentials/protobuf/service.pb.go similarity index 100% rename from credentials/protobuf/service.pb.go rename to services/credentials/protobuf/service.pb.go diff --git a/credentials/protobuf/service.proto b/services/credentials/protobuf/service.proto similarity index 100% rename from credentials/protobuf/service.proto rename to services/credentials/protobuf/service.proto diff --git a/credentials/repositories/grpc_client.go b/services/credentials/repositories/grpc_client.go similarity index 92% rename from credentials/repositories/grpc_client.go rename to services/credentials/repositories/grpc_client.go index 2dde63b..c6c7885 100644 --- a/credentials/repositories/grpc_client.go +++ b/services/credentials/repositories/grpc_client.go @@ -10,10 +10,10 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" - "github.com/mitchell/selfpass/credentials/endpoints" - "github.com/mitchell/selfpass/credentials/protobuf" - "github.com/mitchell/selfpass/credentials/transport" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/endpoints" + "github.com/mitchell/selfpass/services/credentials/protobuf" + "github.com/mitchell/selfpass/services/credentials/transport" + "github.com/mitchell/selfpass/services/credentials/types" ) func NewCredentialServiceClient(ctx context.Context, target, ca, cert, key string) (types.CredentialClient, error) { diff --git a/credentials/repositories/redis.go b/services/credentials/repositories/redis.go similarity index 96% rename from credentials/repositories/redis.go rename to services/credentials/repositories/redis.go index 65806d8..9370e2c 100644 --- a/credentials/repositories/redis.go +++ b/services/credentials/repositories/redis.go @@ -4,7 +4,7 @@ import ( "context" "github.com/mediocregopher/radix/v3" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/types" ) func NewRedisConn(networkType, address string, connCount uint, options ...radix.PoolOpt) (c RedisConn, err error) { diff --git a/credentials/service/service.go b/services/credentials/service/service.go similarity index 97% rename from credentials/service/service.go rename to services/credentials/service/service.go index d3ad4b9..13fae5d 100644 --- a/credentials/service/service.go +++ b/services/credentials/service/service.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/types" ) func NewCredentials(repo types.CredentialRepo) Credentials { diff --git a/credentials/transport/encoding.go b/services/credentials/transport/encoding.go similarity index 96% rename from credentials/transport/encoding.go rename to services/credentials/transport/encoding.go index 8dd733f..9a2858c 100644 --- a/credentials/transport/encoding.go +++ b/services/credentials/transport/encoding.go @@ -5,9 +5,9 @@ import ( "github.com/golang/protobuf/ptypes" - "github.com/mitchell/selfpass/credentials/endpoints" - "github.com/mitchell/selfpass/credentials/protobuf" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/endpoints" + "github.com/mitchell/selfpass/services/credentials/protobuf" + "github.com/mitchell/selfpass/services/credentials/types" ) func decodeGetAllMetadataRequest(ctx context.Context, request interface{}) (interface{}, error) { diff --git a/credentials/transport/grpc_server.go b/services/credentials/transport/grpc_server.go similarity index 95% rename from credentials/transport/grpc_server.go rename to services/credentials/transport/grpc_server.go index 2acd9ae..0b49fb8 100644 --- a/credentials/transport/grpc_server.go +++ b/services/credentials/transport/grpc_server.go @@ -9,9 +9,9 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/mitchell/selfpass/credentials/endpoints" - "github.com/mitchell/selfpass/credentials/protobuf" - "github.com/mitchell/selfpass/credentials/types" + "github.com/mitchell/selfpass/services/credentials/endpoints" + "github.com/mitchell/selfpass/services/credentials/protobuf" + "github.com/mitchell/selfpass/services/credentials/types" ) func NewGRPCServer(svc types.Service, logger log.Logger) GRPCServer { diff --git a/credentials/types/credential.go b/services/credentials/types/credential.go similarity index 100% rename from credentials/types/credential.go rename to services/credentials/types/credential.go diff --git a/credentials/types/error_prefixes.go b/services/credentials/types/error_prefixes.go similarity index 100% rename from credentials/types/error_prefixes.go rename to services/credentials/types/error_prefixes.go diff --git a/credentials/types/interfaces.go b/services/credentials/types/interfaces.go similarity index 100% rename from credentials/types/interfaces.go rename to services/credentials/types/interfaces.go diff --git a/crypto/cbc.go b/services/crypto/cbc.go similarity index 100% rename from crypto/cbc.go rename to services/crypto/cbc.go diff --git a/crypto/gcm.go b/services/crypto/gcm.go similarity index 100% rename from crypto/gcm.go rename to services/crypto/gcm.go diff --git a/crypto/helpers.go b/services/crypto/helpers.go similarity index 100% rename from crypto/helpers.go rename to services/crypto/helpers.go diff --git a/crypto/pbkdf2.go b/services/crypto/pbkdf2.go similarity index 100% rename from crypto/pbkdf2.go rename to services/crypto/pbkdf2.go diff --git a/docker-compose.prod.yml b/services/docker-compose.prod.yml similarity index 100% rename from docker-compose.prod.yml rename to services/docker-compose.prod.yml diff --git a/docker-compose.yml b/services/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to services/docker-compose.yml diff --git a/gen_certs_go.sh b/services/gen_certs_go.sh similarity index 100% rename from gen_certs_go.sh rename to services/gen_certs_go.sh diff --git a/go.mod b/services/go.mod similarity index 95% rename from go.mod rename to services/go.mod index fff3cad..5e84c19 100644 --- a/go.mod +++ b/services/go.mod @@ -1,4 +1,4 @@ -module github.com/mitchell/selfpass +module github.com/mitchell/selfpass/services go 1.12 diff --git a/go.sum b/services/go.sum similarity index 100% rename from go.sum rename to services/go.sum diff --git a/redis.conf b/services/redis.conf similarity index 100% rename from redis.conf rename to services/redis.conf