From 32d1eae28bfd0a5e72e02e4f6a4c040154dcc31d Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Tue, 24 Apr 2018 17:14:30 -0700 Subject: [PATCH] Move ConsulCAProviderConfig into structs package --- agent/consul/connect_ca_provider.go | 12 +++--------- agent/consul/connect_ca_provider_test.go | 4 +--- agent/structs/connect_ca.go | 6 ++++++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/agent/consul/connect_ca_provider.go b/agent/consul/connect_ca_provider.go index d7d76f88ee..1dbe884c79 100644 --- a/agent/consul/connect_ca_provider.go +++ b/agent/consul/connect_ca_provider.go @@ -19,14 +19,8 @@ import ( "github.com/mitchellh/mapstructure" ) -type ConsulCAProviderConfig struct { - PrivateKey string - RootCert string - RotationPeriod time.Duration -} - type ConsulCAProvider struct { - config *ConsulCAProviderConfig + config *structs.ConsulCAProviderConfig id string srv *Server @@ -122,8 +116,8 @@ func NewConsulCAProvider(rawConfig map[string]interface{}, srv *Server) (*Consul return provider, nil } -func decodeConfig(raw map[string]interface{}) (*ConsulCAProviderConfig, error) { - var config *ConsulCAProviderConfig +func decodeConfig(raw map[string]interface{}) (*structs.ConsulCAProviderConfig, error) { + var config *structs.ConsulCAProviderConfig if err := mapstructure.WeakDecode(raw, &config); err != nil { return nil, fmt.Errorf("error decoding config: %s", err) } diff --git a/agent/consul/connect_ca_provider_test.go b/agent/consul/connect_ca_provider_test.go index adad3acba0..583f91722d 100644 --- a/agent/consul/connect_ca_provider_test.go +++ b/agent/consul/connect_ca_provider_test.go @@ -28,7 +28,5 @@ func TestCAProvider_Bootstrap(t *testing.T) { state := s1.fsm.State() _, activeRoot, err := state.CARootActive(nil) assert.NoError(err) - assert.Equal(root.ID, activeRoot.ID) - assert.Equal(root.Name, activeRoot.Name) - assert.Equal(root.RootCert, activeRoot.RootCert) + assert.Equal(root, activeRoot.RootCert) } diff --git a/agent/structs/connect_ca.go b/agent/structs/connect_ca.go index 4562fc1ea8..c46db703a8 100644 --- a/agent/structs/connect_ca.go +++ b/agent/structs/connect_ca.go @@ -160,6 +160,12 @@ type CAConfiguration struct { RaftIndex } +type ConsulCAProviderConfig struct { + PrivateKey string + RootCert string + RotationPeriod time.Duration +} + // CAConsulProviderState is used to track the built-in Consul CA provider's state. type CAConsulProviderState struct { ID string