mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 10:55:42 +03:00
config: move Consul getter out of fingerprinter (#18556)
This commit is contained in:
@@ -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}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
Reference in New Issue
Block a user