mirror of https://github.com/hashicorp/consul
Browse Source
* Check for ACL write permissions on write Link eventually will be creating a token, so require acl:write. * Convert Run to Start, only allow to start once * Always initialize HCP components at startup * Support for updating config and client * Pass HCP manager to controller * Start HCP manager in link resource Start as part of link creation rather than always starting. Update the HCP manager with values from the link before starting as well. * Fix metrics sink leaked goroutine * Remove the hardcoded disabled hostname prefix The HCP metrics sink will always be enabled, so the length of sinks will always be greater than zero. This also means that we will also always default to prefixing metrics with the hostname, which is what our documentation states is the expected behavior anyway. * Add changelog * Check and set running status in one method * Check for primary datacenter, add back test * Clarify merge reasoning, fix timing issue in test * Add comment about controller placement * Expand on breaking change, fix typo in changelogpull/20379/head
Melissa Kam
10 months ago
committed by
GitHub
22 changed files with 602 additions and 130 deletions
@ -0,0 +1,6 @@
|
||||
```release-note:feature |
||||
cloud: Adds new API/CLI to initiate and manage linking a Consul cluster to HCP Consul Central |
||||
``` |
||||
```release-note:breaking-change |
||||
telemetry: Adds fix to always use the value of `telemetry.disable_hostname` when determining whether to prefix gauge-type metrics with the hostname of the Consul agent. Previously, if only the default metric sink was enabled, this configuration was ignored and always treated as `true`, even though its default value is `false`. |
||||
``` |
@ -0,0 +1,82 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package config |
||||
|
||||
import ( |
||||
"crypto/tls" |
||||
"testing" |
||||
|
||||
"github.com/stretchr/testify/require" |
||||
) |
||||
|
||||
func TestMerge(t *testing.T) { |
||||
oldCfg := CloudConfig{ |
||||
ResourceID: "old-resource-id", |
||||
ClientID: "old-client-id", |
||||
ClientSecret: "old-client-secret", |
||||
Hostname: "old-hostname", |
||||
AuthURL: "old-auth-url", |
||||
ScadaAddress: "old-scada-address", |
||||
ManagementToken: "old-token", |
||||
TLSConfig: &tls.Config{ |
||||
ServerName: "old-server-name", |
||||
}, |
||||
NodeID: "old-node-id", |
||||
NodeName: "old-node-name", |
||||
} |
||||
|
||||
newCfg := CloudConfig{ |
||||
ResourceID: "new-resource-id", |
||||
ClientID: "new-client-id", |
||||
ClientSecret: "new-client-secret", |
||||
Hostname: "new-hostname", |
||||
AuthURL: "new-auth-url", |
||||
ScadaAddress: "new-scada-address", |
||||
ManagementToken: "new-token", |
||||
TLSConfig: &tls.Config{ |
||||
ServerName: "new-server-name", |
||||
}, |
||||
NodeID: "new-node-id", |
||||
NodeName: "new-node-name", |
||||
} |
||||
|
||||
for name, tc := range map[string]struct { |
||||
newCfg CloudConfig |
||||
expectedCfg CloudConfig |
||||
}{ |
||||
"Empty": { |
||||
newCfg: CloudConfig{}, |
||||
expectedCfg: oldCfg, |
||||
}, |
||||
"All": { |
||||
newCfg: newCfg, |
||||
expectedCfg: newCfg, |
||||
}, |
||||
"Partial": { |
||||
newCfg: CloudConfig{ |
||||
ResourceID: newCfg.ResourceID, |
||||
ClientID: newCfg.ClientID, |
||||
ClientSecret: newCfg.ClientSecret, |
||||
ManagementToken: newCfg.ManagementToken, |
||||
}, |
||||
expectedCfg: CloudConfig{ |
||||
ResourceID: newCfg.ResourceID, |
||||
ClientID: newCfg.ClientID, |
||||
ClientSecret: newCfg.ClientSecret, |
||||
ManagementToken: newCfg.ManagementToken, |
||||
Hostname: oldCfg.Hostname, |
||||
AuthURL: oldCfg.AuthURL, |
||||
ScadaAddress: oldCfg.ScadaAddress, |
||||
TLSConfig: oldCfg.TLSConfig, |
||||
NodeID: oldCfg.NodeID, |
||||
NodeName: oldCfg.NodeName, |
||||
}, |
||||
}, |
||||
} { |
||||
t.Run(name, func(t *testing.T) { |
||||
merged := Merge(oldCfg, tc.newCfg) |
||||
require.Equal(t, tc.expectedCfg, merged) |
||||
}) |
||||
} |
||||
} |
Loading…
Reference in new issue