Skip to content

Commit

Permalink
move plugingen stubs out of proto/spire
Browse files Browse the repository at this point in the history
The plugin/service/hostservice stub code depends on the SPIRE codebase.
Keeping it under the github.com/spiffe/spire/proto/spire causes a cyclic
dependency, which is gross.

This change moves the stub code out of proto/spire into the respective
pkg/{server,agent,common}/plugin/* packages.

Plugin authors will need to continue depending on SPIRE.

API consumers only will only need to depend on
github.com/spiffe/spire/proto/spire.

Signed-off-by: Andrew Harding <[email protected]>
  • Loading branch information
azdagron committed Dec 27, 2019
1 parent ae4d345 commit 62e723f
Show file tree
Hide file tree
Showing 156 changed files with 711 additions and 719 deletions.
53 changes: 27 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,40 +151,40 @@ protodocs := \
# The following three variables define the plugin, service, and hostservice
# interfaces. The syntax of each entry is as follows:
#
# proto-path,interface-name[,shared]
# proto-path,out-path,interface-name[,shared]
#
# "shared" means that the interface shares a package with other interfaces, which
# impacts the code generation (adds stutter to disambiguate names)
plugingen_plugins = \
proto/spire/server/notifier/notifier.proto,Notifier \
proto/spire/server/nodeattestor/nodeattestor.proto,NodeAttestor \
proto/spire/server/datastore/datastore.proto,DataStore \
proto/spire/server/upstreamca/upstreamca.proto,UpstreamCA \
proto/spire/server/noderesolver/noderesolver.proto,NodeResolver \
proto/spire/server/keymanager/keymanager.proto,KeyManager \
proto/spire/agent/nodeattestor/nodeattestor.proto,NodeAttestor \
proto/spire/agent/workloadattestor/workloadattestor.proto,WorkloadAttestor \
proto/spire/agent/keymanager/keymanager.proto,KeyManager \
pkg/common/catalog/test/test.proto,Plugin,shared \
proto/spire/server/notifier/notifier.proto,pkg/server/plugin/notifier,Notifier \
proto/spire/server/nodeattestor/nodeattestor.proto,pkg/server/plugin/nodeattestor,NodeAttestor \
proto/spire/server/datastore/datastore.proto,pkg/server/plugin/datastore,DataStore \
proto/spire/server/upstreamca/upstreamca.proto,pkg/server/plugin/upstreamca,UpstreamCA \
proto/spire/server/noderesolver/noderesolver.proto,pkg/server/plugin/noderesolver,NodeResolver \
proto/spire/server/keymanager/keymanager.proto,pkg/server/plugin/keymanager,KeyManager \
proto/spire/agent/nodeattestor/nodeattestor.proto,pkg/agent/plugin/nodeattestor,NodeAttestor \
proto/spire/agent/workloadattestor/workloadattestor.proto,pkg/agent/plugin/workloadattestor,WorkloadAttestor \
proto/spire/agent/keymanager/keymanager.proto,pkg/agent/plugin/keymanager,KeyManager \
pkg/common/catalog/test/test.proto,pkg/common/catalog/test,Plugin,shared \

plugingen_services = \
pkg/common/catalog/test/test.proto,Service,shared \
pkg/common/catalog/test/test.proto,pkg/common/catalog/test,Service,shared \

plugingen_hostservices = \
proto/spire/server/hostservices/identityprovider.proto,IdentityProvider,shared \
proto/spire/server/hostservices/agentstore.proto,AgentStore,shared \
proto/spire/common/hostservices/metricsservice.proto,MetricsService,shared \
pkg/common/catalog/test/test.proto,HostService,shared \
proto/spire/server/hostservices/identityprovider.proto,pkg/server/plugin/hostservices,IdentityProvider,shared \
proto/spire/server/hostservices/agentstore.proto,pkg/server/plugin/hostservices,AgentStore,shared \
proto/spire/common/hostservices/metricsservice.proto,pkg/common/plugin/hostservices,MetricsService,shared \
pkg/common/catalog/test/test.proto,pkg/common/catalog/test,HostService,shared \

# The following are the mock interfaces generated by mockgen. The syntax of each
# entry is as follows:
# mock-destination-pkg,src-go-pkg,interface[,additional interfaces]
mockgen_mocks = \
test/mock/proto/server/upstreamca,github.com/spiffe/spire/proto/spire/server/upstreamca,UpstreamCA,UpstreamCAServer \
test/mock/proto/agent/nodeattestor,github.com/spiffe/spire/proto/spire/agent/nodeattestor,NodeAttestor,NodeAttestorServer,NodeAttestor_FetchAttestationDataClient \
test/mock/proto/agent/workloadattestor,github.com/spiffe/spire/proto/spire/agent/workloadattestor,WorkloadAttestor,WorkloadAttestorServer \
test/mock/proto/agent/keymanager,github.com/spiffe/spire/proto/spire/agent/keymanager,KeyManager,KeyManagerServer \
test/mock/proto/common/hostservices,github.com/spiffe/spire/proto/spire/common/hostservices,MetricsService \
test/mock/plugin/server/upstreamca,github.com/spiffe/spire/pkg/server/plugin/upstreamca,UpstreamCA,UpstreamCAServer \
test/mock/plugin/agent/nodeattestor,github.com/spiffe/spire/pkg/agent/plugin/nodeattestor,NodeAttestor,NodeAttestorServer,NodeAttestor_FetchAttestationDataClient \
test/mock/plugin/agent/workloadattestor,github.com/spiffe/spire/pkg/agent/plugin/workloadattestor,WorkloadAttestor,WorkloadAttestorServer \
test/mock/plugin/agent/keymanager,github.com/spiffe/spire/pkg/agent/plugin/keymanager,KeyManager,KeyManagerServer \
test/mock/plugin/common/hostservices,github.com/spiffe/spire/pkg/common/plugin/hostservices,MetricsService \
test/mock/proto/api/registration,github.com/spiffe/spire/proto/spire/api/registration,RegistrationClient,RegistrationServer \
test/mock/proto/api/workload,github.com/spiffe/go-spiffe/proto/spiffe/workload,SpiffeWorkloadAPIClient,SpiffeWorkloadAPIServer,SpiffeWorkloadAPI_FetchX509SVIDClient,SpiffeWorkloadAPI_FetchX509SVIDServer,SpiffeWorkloadAPI_FetchJWTBundlesServer \
test/mock/proto/api/node,github.com/spiffe/spire/proto/spire/api/node,NodeClient,Node_AttestClient,Node_AttestServer,Node_FetchX509SVIDClient,NodeServer,Node_FetchX509SVIDServer \
Expand Down Expand Up @@ -392,17 +392,18 @@ $(foreach doc,$(protodocs),$(eval $(call protodoc-rule,$(doc))))

plugingen-proto = $(word 1,$(subst $(comma),$(space),$1))
plugingen-pbgo = $(subst .proto,.pb.go,$(call plugingen-proto,$1))
plugingen-dir = $(dir $(call plugingen-proto, $1))
plugingen-type = $(word 2,$(subst $(comma),$(space),$1))
plugingen-shared = $(word 3,$(subst $(comma),$(space),$1))
plugingen-proto-dir = $(dir $(call plugingen-proto, $1))
plugingen-out-dir = $(word 2,$(subst $(comma),$(space),$1))
plugingen-type = $(word 3,$(subst $(comma),$(space),$1))
plugingen-shared = $(word 4,$(subst $(comma),$(space),$1))
plugingen-shared-opt = $(subst shared,-shared,$(call plugingen-shared,$1))
plugingen-out = $(call plugingen-dir,$1)$(call tolower,$(call plugingen-type,$1)).go
plugingen-out = $(call plugingen-out-dir,$1)/$(call tolower,$(call plugingen-type,$1)).go

# plugingen-rule is a template for invoking spire-plugingen and is invoked with a plugingen_* entry
define plugingen-rule
$(call plugingen-out,$1): $(call plugingen-pbgo,$1) | bin/spire-plugingen
@echo "($2) generating $$@..."
@cd $(call plugingen-dir,$1) && PATH=$$(go_bin_dir):$$(PATH) $$(DIR)/bin/spire-plugingen $(call plugingen-shared-opt,$1) -mode $2 . $(call plugingen-type,$1)
@PATH=$$(go_bin_dir):$$(PATH) $$(DIR)/bin/spire-plugingen $(call plugingen-shared-opt,$1) -mode $2 -out $(call plugingen-out-dir,$1) $(call plugingen-proto-dir,$1) $(call plugingen-type,$1)
endef

# generate rules for plugins
Expand Down
2 changes: 1 addition & 1 deletion cmd/spire-server/cli/bundle/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/mitchellh/cli"
"github.com/spiffe/spire/pkg/common/pemutil"
"github.com/spiffe/spire/pkg/server/plugin/datastore"
"github.com/spiffe/spire/proto/spire/common"
"github.com/spiffe/spire/proto/spire/server/datastore"
"github.com/spiffe/spire/test/fakes/fakedatastore"
"github.com/spiffe/spire/test/fakes/fakeregistrationclient"
"github.com/stretchr/testify/suite"
Expand Down
2 changes: 1 addition & 1 deletion cmd/spire-server/cli/bundle/experimental_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/mitchellh/cli"
"github.com/spiffe/spire/pkg/common/pemutil"
"github.com/spiffe/spire/pkg/server/plugin/datastore"
"github.com/spiffe/spire/proto/spire/common"
"github.com/spiffe/spire/proto/spire/server/datastore"
"github.com/spiffe/spire/test/fakes/fakedatastore"
"github.com/spiffe/spire/test/fakes/fakeregistrationclient"
"github.com/stretchr/testify/suite"
Expand Down
4 changes: 2 additions & 2 deletions cmd/spire-server/cli/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/spiffe/spire/pkg/server"
bundleClient "github.com/spiffe/spire/pkg/server/bundle/client"
"github.com/spiffe/spire/pkg/server/endpoints/bundle"
"github.com/spiffe/spire/proto/spire/server/keymanager"
"github.com/spiffe/spire/proto/spire/server/upstreamca"
"github.com/spiffe/spire/pkg/server/plugin/keymanager"
"github.com/spiffe/spire/pkg/server/plugin/upstreamca"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/spire-server/cli/run/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/spiffe/spire/pkg/common/catalog"
"github.com/spiffe/spire/pkg/common/log"
"github.com/spiffe/spire/pkg/server"
"github.com/spiffe/spire/proto/spire/server/keymanager"
"github.com/spiffe/spire/pkg/server/plugin/keymanager"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/plugins/agent-node-attestor/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/hcl"
"github.com/spiffe/spire/pkg/common/catalog"
"github.com/spiffe/spire/proto/spire/agent/nodeattestor"
"github.com/spiffe/spire/pkg/agent/plugin/nodeattestor"
"github.com/spiffe/spire/proto/spire/common"
"github.com/spiffe/spire/proto/spire/common/plugin"
"github.com/zeebo/errs"
Expand Down
2 changes: 1 addition & 1 deletion examples/plugins/server-node-attestor/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
nodeattestorbase "github.com/spiffe/spire/pkg/server/plugin/nodeattestor/base"
"github.com/spiffe/spire/proto/spire/common"
"github.com/spiffe/spire/proto/spire/common/plugin"
"github.com/spiffe/spire/proto/spire/server/nodeattestor"
"github.com/spiffe/spire/pkg/server/plugin/nodeattestor"
"github.com/zeebo/errs"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/plugins/upstreamca/upstreamca.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/hcl"
spi "github.com/spiffe/spire/proto/spire/common/plugin"
"github.com/spiffe/spire/proto/spire/server/upstreamca"
"github.com/spiffe/spire/pkg/server/plugin/upstreamca"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down
16 changes: 16 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Azure/go-autorest/autorest v0.9.0
github.com/Azure/go-autorest/autorest/azure/auth v0.1.0
github.com/Azure/go-autorest/autorest/to v0.3.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect
// version 1.14
github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20190405210948-c70a36b8193f
github.com/InVisionApp/go-health v2.1.0+incompatible
Expand All @@ -21,15 +23,22 @@ require (
github.com/aws/aws-sdk-go v1.21.7
github.com/blang/semver v3.5.1+incompatible
github.com/cenkalti/backoff/v3 v3.0.0
github.com/containerd/containerd v1.3.2 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v1.4.2-0.20191008235115-448db5a783a0
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/envoyproxy/go-control-plane v0.9.0
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-sql-driver/mysql v1.4.1
github.com/gofrs/uuid v3.2.0+incompatible
github.com/gogo/protobuf v1.2.1
github.com/golang/mock v1.3.1
github.com/golang/protobuf v1.3.2
github.com/google/gofuzz v1.0.0 // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
github.com/hashicorp/go-hclog v0.9.2
github.com/hashicorp/go-plugin v1.0.1
Expand All @@ -39,10 +48,14 @@ require (
github.com/jinzhu/gorm v1.9.9
github.com/mitchellh/cli v1.0.0
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/prometheus/client_golang v1.0.0
github.com/shirou/gopsutil v2.18.12+incompatible
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/spf13/pflag v1.0.5 // indirect
github.com/spiffe/go-spiffe v0.0.0-20190717182101-d8657cb50cae
github.com/spiffe/spire/proto/spire v0.0.0-20190723205943-8d4a2538e330
github.com/stretchr/testify v1.4.0
Expand All @@ -59,10 +72,13 @@ require (
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55
google.golang.org/grpc v1.24.0
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/square/go-jose.v2 v2.3.1
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637
gotest.tools v2.2.0+incompatible
k8s.io/api v0.0.0-20190222213804-5cb15d344471
k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628
k8s.io/client-go v10.0.0+incompatible
k8s.io/klog v1.0.0 // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
)
Loading

0 comments on commit 62e723f

Please sign in to comment.