diff --git a/client/config/config_ce.go b/client/config/config_ce.go index 67165531756..10fd2b910db 100644 --- a/client/config/config_ce.go +++ b/client/config/config_ce.go @@ -7,6 +7,7 @@ package config import ( "github.com/hashicorp/go-hclog" + "github.com/hashicorp/nomad/nomad/structs/config" structsc "github.com/hashicorp/nomad/nomad/structs/config" ) @@ -23,3 +24,17 @@ func (c *Config) GetVaultConfigs(logger hclog.Logger) map[string]*structsc.Vault return map[string]*structsc.VaultConfig{"default": c.VaultConfig} } + +// GetConsulConfigs returns the set of Consul configurations the fingerprint needs +// to check. In Nomad CE we only check the default Consul. +func (c *Config) GetConsulConfigs(logger hclog.Logger) map[string]*structsc.ConsulConfig { + if c.ConsulConfig == nil { + return nil + } + + if len(c.ConsulConfigs) > 1 { + logger.Warn("multiple Consul configurations are only supported in Nomad Enterprise") + } + + return map[string]*config.ConsulConfig{"default": c.ConsulConfig} +} diff --git a/client/fingerprint/consul.go b/client/fingerprint/consul.go index f0ee976bb86..2051df6ddf0 100644 --- a/client/fingerprint/consul.go +++ b/client/fingerprint/consul.go @@ -58,7 +58,8 @@ func NewConsulFingerprint(logger log.Logger) Fingerprint { func (f *ConsulFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error { var mErr *multierror.Error - for _, cfg := range f.consulConfigs(req) { + consulConfigs := req.Config.GetConsulConfigs(f.logger) + for _, cfg := range consulConfigs { err := f.fingerprintImpl(cfg, resp) if err != nil { mErr = multierror.Append(mErr, err) diff --git a/client/fingerprint/consul_ce.go b/client/fingerprint/consul_ce.go deleted file mode 100644 index d73121465d1..00000000000 --- a/client/fingerprint/consul_ce.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: BUSL-1.1 - -//go:build !ent - -package fingerprint - -import "github.com/hashicorp/nomad/nomad/structs/config" - -// consulConfigs returns the set of Consul configurations the fingerprint needs -// to check. In Nomad CE we only check the default Consul. -func (f *ConsulFingerprint) consulConfigs(req *FingerprintRequest) map[string]*config.ConsulConfig { - agentCfg := req.Config - if agentCfg.ConsulConfig == nil { - return nil - } - - if len(req.Config.ConsulConfigs) > 1 { - f.logger.Warn("multiple Consul configurations are only supported in Nomad Enterprise") - } - - return map[string]*config.ConsulConfig{"default": agentCfg.ConsulConfig} -}