diff --git a/cmd/server/handlers.go b/cmd/server/handlers.go index e55133b..9374ecd 100644 --- a/cmd/server/handlers.go +++ b/cmd/server/handlers.go @@ -13,7 +13,7 @@ import ( var ( contractAccessor *contract.Accessor - infoClient *gc.InfoClient + cspInfoClient *gc.CspInfoServiceClient ) // CreateContract implements pbgo.ContractService.CreateContract gRPC @@ -31,7 +31,7 @@ func (s *server) CreateContract(ctx context.Context, in *pb.CreateContractReques return &res, err } // Create New CSP Info - res, err := infoClient.CreateCSPInfo(ctx, contractID.String(), in.GetCspName(), in.GetCspAuth()) + res, err := cspInfoClient.CreateCSPInfo(ctx, contractID.String(), in.GetCspName(), in.GetCspAuth()) log.Info("newly created CSP ID:", res.GetId()) if err != nil || res.GetCode() != pb.Code_OK_UNSPECIFIED { res := pb.CreateContractResponse{ diff --git a/cmd/server/handlers_test.go b/cmd/server/handlers_test.go index e2f0819..f530c9a 100644 --- a/cmd/server/handlers_test.go +++ b/cmd/server/handlers_test.go @@ -33,8 +33,8 @@ func TestCreateContract(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() ctx, cancel := context.WithCancel(context.Background()) - mockInfoClient := mock.NewMockInfoServiceClient(ctrl) - infoClient = gc.New(nil, mockInfoClient) + mockInfoClient := mock.NewMockCspInfoServiceClient(ctrl) + cspInfoClient = gc.NewCspInfoServiceClient(nil, mockInfoClient) contractAccessor, err = getAccessor() if err != nil { t.Errorf("unexpected error %s", err) diff --git a/cmd/server/main.go b/cmd/server/main.go index 390161c..20174cc 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -59,11 +59,11 @@ func main() { log.Fatal("failed to listen:", err) } cc, sc, err := gcInfo.CreateClientsObject(infoServiceAddress, infoServicePort, false, "") - infoClient = gcInfo.New(cc, sc) + cspInfoClient = gcInfo.NewCspInfoServiceClient(cc, sc) if err != nil { log.Error() } - defer infoClient.Close() + defer cspInfoClient.Close() s := grpc.NewServer() pb.RegisterContractServiceServer(s, &server{}) diff --git a/go.mod b/go.mod index 276854a..216090e 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,12 @@ go 1.16 require ( github.com/DATA-DOG/go-sqlmock v1.5.0 - github.com/golang/mock v1.5.0 + github.com/golang/mock v1.6.0 github.com/google/uuid v1.2.0 github.com/jackc/pgproto3/v2 v2.0.7 // indirect github.com/lib/pq v1.10.2 github.com/sirupsen/logrus v1.8.1 - github.com/sktelecom/tks-proto v0.0.4-0.20210525114302-5f344854a6d3 + github.com/sktelecom/tks-proto v0.0.6-0.20210622012523-ded9f951101f github.com/stretchr/testify v1.7.0 // indirect golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect diff --git a/go.sum b/go.sum index 3c5f6af..f51f251 100644 --- a/go.sum +++ b/go.sum @@ -82,6 +82,8 @@ github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4er github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -327,6 +329,10 @@ github.com/sktelecom/tks-proto v0.0.4-0.20210525084545-97b649fb981e h1:HIueftEPa github.com/sktelecom/tks-proto v0.0.4-0.20210525084545-97b649fb981e/go.mod h1:nANHsxkA1W4AXgTUcjn+svFnPF1W2biVN2EIwhH976w= github.com/sktelecom/tks-proto v0.0.4-0.20210525114302-5f344854a6d3 h1:99a484xUu7eusoyye0fpHNNbvDtowZOZzIN7RDks538= github.com/sktelecom/tks-proto v0.0.4-0.20210525114302-5f344854a6d3/go.mod h1:nANHsxkA1W4AXgTUcjn+svFnPF1W2biVN2EIwhH976w= +github.com/sktelecom/tks-proto v0.0.6-0.20210616081514-805158493f44 h1:6EDDbM9U/RmJ5JJ45Niz4vYX8rlI7hDlEJGU1UOuA70= +github.com/sktelecom/tks-proto v0.0.6-0.20210616081514-805158493f44/go.mod h1:nANHsxkA1W4AXgTUcjn+svFnPF1W2biVN2EIwhH976w= +github.com/sktelecom/tks-proto v0.0.6-0.20210622012523-ded9f951101f h1:G0rsoWD34PlWh5pCAvrcCcS8WTbzEPpnTodJ435oF+k= +github.com/sktelecom/tks-proto v0.0.6-0.20210622012523-ded9f951101f/go.mod h1:nviaEDJn6wwQPiPogs2EBw3L/6HTkyyXIRkwyjH0pgY= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -349,6 +355,7 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= @@ -390,6 +397,7 @@ golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -409,6 +417,7 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -420,6 +429,7 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -446,7 +456,9 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210521203332-0cec03c779c1 h1:lCnv+lfrU9FRPGf8NeRuWAAPjNnema5WtBinMgs1fD8= golang.org/x/sys v0.0.0-20210521203332-0cec03c779c1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -476,6 +488,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/grpc-client/info.go b/pkg/grpc-client/cspinfo.go similarity index 72% rename from pkg/grpc-client/info.go rename to pkg/grpc-client/cspinfo.go index 9344a46..9ca97cd 100644 --- a/pkg/grpc-client/info.go +++ b/pkg/grpc-client/cspinfo.go @@ -11,19 +11,19 @@ import ( pb "github.com/sktelecom/tks-proto/pbgo" ) -type InfoClient struct { +type CspInfoServiceClient struct { cc *grpc.ClientConn - sc pb.InfoServiceClient + sc pb.CspInfoServiceClient } -func New(cc *grpc.ClientConn, sc pb.InfoServiceClient) *InfoClient { - return &InfoClient{ +func NewCspInfoServiceClient(cc *grpc.ClientConn, sc pb.CspInfoServiceClient) *CspInfoServiceClient { + return &CspInfoServiceClient{ cc: cc, sc: sc, } } -func CreateClientsObject(address string, port int, tls bool, caFile string) (*grpc.ClientConn, pb.InfoServiceClient, error) { +func CreateClientsObject(address string, port int, tls bool, caFile string) (*grpc.ClientConn, pb.CspInfoServiceClient, error) { opts := grpc.WithInsecure() if tls { if caFile == "" { @@ -44,11 +44,11 @@ func CreateClientsObject(address string, port int, tls bool, caFile string) (*gr log.Fatal("Could not connect to gRPC server", err) return nil, nil, err } - sc := pb.NewInfoServiceClient(cc) + sc := pb.NewCspInfoServiceClient(cc) return cc, sc, nil } -func (c *InfoClient) CreateCSPInfo(ctx context.Context, contractId string, +func (c *CspInfoServiceClient) CreateCSPInfo(ctx context.Context, contractId string, cspName string, auth string) (*pb.IDResponse, error) { return c.sc.CreateCSPInfo(ctx, &pb.CreateCSPInfoRequest{ ContractId: contractId, @@ -57,6 +57,6 @@ func (c *InfoClient) CreateCSPInfo(ctx context.Context, contractId string, }) } -func (c *InfoClient) Close() error { +func (c *CspInfoServiceClient) Close() error { return c.cc.Close() }