Skip to content

Commit

Permalink
Merge pull request #54 from theparanoids/cleanup-protogen
Browse files Browse the repository at this point in the history
simplify protogen process
  • Loading branch information
maditya authored Dec 8, 2020
2 parents 254c77b + e3a05b9 commit ab61c89
Show file tree
Hide file tree
Showing 19 changed files with 504 additions and 72 deletions.
4 changes: 2 additions & 2 deletions api/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
"net/http"
"time"

"github.com/golang/protobuf/ptypes/empty"
"github.com/theparanoids/crypki/config"
"github.com/theparanoids/crypki/proto"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
)

// GetBlobAvailableSigningKeys returns all available keys that can sign
func (s *SigningService) GetBlobAvailableSigningKeys(ctx context.Context, e *empty.Empty) (*proto.KeyMetas, error) {
func (s *SigningService) GetBlobAvailableSigningKeys(ctx context.Context, e *emptypb.Empty) (*proto.KeyMetas, error) {
const methodName = "GetBlobAvailableSigningKeys"
statusCode := http.StatusOK
start := time.Now()
Expand Down
4 changes: 2 additions & 2 deletions api/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"sort"
"testing"

"github.com/golang/protobuf/ptypes/empty"
"github.com/theparanoids/crypki/proto"
"google.golang.org/protobuf/types/known/emptypb"
)

func init() {
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestGetBlobAvailableSigningKeys(t *testing.T) {
mssp := mockSigningServiceParam{KeyUsages: tt.KeyUsages, sendError: false}
ss := initMockSigningService(mssp)
var ctx context.Context
var e *empty.Empty
var e *emptypb.Empty
keyMetas, err := ss.GetBlobAvailableSigningKeys(ctx, e)
if err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions api/sshhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (
"net/http"
"time"

"github.com/golang/protobuf/ptypes/empty"
"github.com/theparanoids/crypki/config"
"github.com/theparanoids/crypki/proto"
"github.com/theparanoids/crypki/sshcert"
"golang.org/x/crypto/ssh"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
)

// GetHostSSHCertificateAvailableSigningKeys returns all available keys that can sign host SSH certificates.
func (s *SigningService) GetHostSSHCertificateAvailableSigningKeys(ctx context.Context, e *empty.Empty) (*proto.KeyMetas, error) {
func (s *SigningService) GetHostSSHCertificateAvailableSigningKeys(ctx context.Context, e *emptypb.Empty) (*proto.KeyMetas, error) {
const methodName = "GetHostSSHCertificateAvailableSigningKeys"
statusCode := http.StatusOK
start := time.Now()
Expand Down
4 changes: 2 additions & 2 deletions api/sshuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (
"net/http"
"time"

"github.com/golang/protobuf/ptypes/empty"
"github.com/theparanoids/crypki/config"
"github.com/theparanoids/crypki/proto"
"github.com/theparanoids/crypki/sshcert"
"golang.org/x/crypto/ssh"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
)

// GetUserSSHCertificateAvailableSigningKeys returns all available keys that can sign user SSH certificates.
func (s *SigningService) GetUserSSHCertificateAvailableSigningKeys(ctx context.Context, e *empty.Empty) (*proto.KeyMetas, error) {
func (s *SigningService) GetUserSSHCertificateAvailableSigningKeys(ctx context.Context, e *emptypb.Empty) (*proto.KeyMetas, error) {
const methodName = "GetUserSSHCertificateAvailableSigningKeys"
statusCode := http.StatusOK
start := time.Now()
Expand Down
4 changes: 2 additions & 2 deletions api/sshuser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"sort"
"testing"

"github.com/golang/protobuf/ptypes/empty"
"github.com/theparanoids/crypki/config"
"github.com/theparanoids/crypki/proto"
"google.golang.org/protobuf/types/known/emptypb"
)

func TestGetUserSSHCertificateAvailableSigningKeys(t *testing.T) {
Expand Down Expand Up @@ -52,7 +52,7 @@ func TestGetUserSSHCertificateAvailableSigningKeys(t *testing.T) {
mssp := mockSigningServiceParam{KeyUsages: tt.KeyUsages, sendError: false}
ss := initMockSigningService(mssp)
var ctx context.Context
var e *empty.Empty
var e *emptypb.Empty
keyMetas, err := ss.GetUserSSHCertificateAvailableSigningKeys(ctx, e)
if err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions api/x509cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import (
"net/http"
"time"

"github.com/golang/protobuf/ptypes/empty"
"github.com/theparanoids/crypki/config"
"github.com/theparanoids/crypki/proto"
"github.com/theparanoids/crypki/x509cert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
)

// GetX509CertificateAvailableSigningKeys returns all available keys that can sign X509 certificates.
func (s *SigningService) GetX509CertificateAvailableSigningKeys(ctx context.Context, e *empty.Empty) (*proto.KeyMetas, error) {
func (s *SigningService) GetX509CertificateAvailableSigningKeys(ctx context.Context, e *emptypb.Empty) (*proto.KeyMetas, error) {
const methodName = "GetX509CertificateAvailableSigningKeys"
statusCode := http.StatusOK
start := time.Now()
Expand Down
4 changes: 2 additions & 2 deletions api/x509cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"sort"
"testing"

"github.com/golang/protobuf/ptypes/empty"
"github.com/theparanoids/crypki/config"
"github.com/theparanoids/crypki/proto"
"google.golang.org/protobuf/types/known/emptypb"
)

func TestGetX509CertificateAvailableSigningKeys(t *testing.T) {
Expand Down Expand Up @@ -52,7 +52,7 @@ func TestGetX509CertificateAvailableSigningKeys(t *testing.T) {
mssp := mockSigningServiceParam{KeyUsages: tt.KeyUsages, sendError: false}
ss := initMockSigningService(mssp)
var ctx context.Context
var e *empty.Empty
var e *emptypb.Empty
keyMetas, err := ss.GetX509CertificateAvailableSigningKeys(ctx, e)
if err != nil {
t.Fatal(err)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a // indirect
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154
google.golang.org/grpc v1.33.1
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.1
google.golang.org/protobuf v1.25.0
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ google.golang.org/grpc v1.33.1 h1:DGeFlSan2f+WEtCERJ4J9GJWk15TxUi8QGagfI87Xyc=
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.0 h1:lQ+dE99pFsb8osbJB3oRfE5eW4Hx6a/lZQr8Jh+eoT4=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.1 h1:M8spwkmx0pHrPq+uMdl22w5CvJ/Y+oAJTIs9oGoCpOE=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.1/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
2 changes: 1 addition & 1 deletion pkcs11/pkcs11.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// PKCS11Ctx interface is added to mock pkcs11.Ctx
// run the following command to generate mock
//go:generate $GOPATH/bin/mockgen -source=pkcs11.go -destination ./mock_pkcs11/mock_pkcs11.go
//go:generate mockgen -source=pkcs11.go -destination ./mock_pkcs11/mock_pkcs11.go
type PKCS11Ctx interface {
GetAttributeValue(p11.SessionHandle, p11.ObjectHandle, []*p11.Attribute) ([]*p11.Attribute, error)
SignInit(p11.SessionHandle, []*p11.Mechanism, p11.ObjectHandle) error
Expand Down
18 changes: 9 additions & 9 deletions proto/mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 4 additions & 10 deletions proto/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
// Package proto contains proto generated code.
package proto

//go:generate protoc -I. -I$GOPATH/pkg/mod -I$GOPATH/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/[email protected]/third_party/googleapis --go_out=. --go-grpc_out=. sign.proto
//go:generate protoc -I. -I$GOPATH/pkg/mod -I$GOPATH/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/[email protected]/third_party/googleapis --grpc-gateway_out=. --grpc-gateway_opt logtostderr=true --grpc-gateway_opt paths=source_relative --grpc-gateway_opt generate_unbound_methods=true sign.proto
// use protoc 3.13.0

// run the following command after generating proto files to generate mock
//go:generate $GOPATH/bin/mockgen -source=./sign_grpc.pb.go -destination=./mock/mock.go -package=mock

// run the following commands to install the gomock
// go get github.com/golang/mock/gomock
// go install github.com/golang/mock/mockgen
// use protoc 3.14.0
//go:generate protoc -I. -I../third_party/googleapis --go_out=. --go-grpc_out=. sign.proto
//go:generate protoc -I. -I../third_party/googleapis --grpc-gateway_out=. --grpc-gateway_opt logtostderr=true --grpc-gateway_opt paths=source_relative --grpc-gateway_opt generate_unbound_methods=true sign.proto
//go:generate mockgen -source=./sign_grpc.pb.go -destination=./mock/mock.go -package=mock
6 changes: 3 additions & 3 deletions proto/sign.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions proto/sign.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ab61c89

Please sign in to comment.