Skip to content

Commit

Permalink
config: move Consul getter out of fingerprinter (#18556)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Sep 22, 2023
1 parent 7bd5c6e commit 20eadc7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
15 changes: 15 additions & 0 deletions client/config/config_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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}
}
3 changes: 2 additions & 1 deletion client/fingerprint/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 0 additions & 23 deletions client/fingerprint/consul_ce.go

This file was deleted.

0 comments on commit 20eadc7

Please sign in to comment.