ui: change Consul/Vault base URL field name (#11589)

Give ourselves some room for extension in the UI configuration block
by naming the field `ui_url`, which will let us have an `api_url`.
Fix the template path to ensure we're getting the right value from the
API.
This commit is contained in:
Tim Gross 2021-11-30 13:20:29 -05:00 committed by GitHub
parent e34bb8ab1d
commit 39acac33a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 26 deletions

View File

@ -15,19 +15,19 @@ type UIConfig struct {
Vault *VaultUIConfig `hcl:"vault"`
}
// ConsulUIConfig configures deep links to this cluster's Consul UI
// ConsulUIConfig configures deep links to this cluster's Consul
type ConsulUIConfig struct {
// BaseURL provides the full base URL, ex:
// BaseUIURL provides the full base URL to the UI, ex:
// https://consul.example.com:8500/ui/
BaseURL string `hcl:"base_url"`
BaseUIURL string `hcl:"ui_url"`
}
// VaultUIConfig configures deep links to this cluster's Vault UI
// VaultUIConfig configures deep links to this cluster's Vault
type VaultUIConfig struct {
// BaseURL provides the full base URL, ex:
// BaseUIURL provides the full base URL to the UI, ex:
// https://vault.example.com:8200/ui/
BaseURL string `hcl:"base_url"`
BaseUIURL string `hcl:"ui_url"`
}
// DefaultUIConfig returns the canonical defaults for the Nomad
@ -95,8 +95,8 @@ func (this *ConsulUIConfig) Merge(other *ConsulUIConfig) *ConsulUIConfig {
return result
}
if other.BaseURL != "" {
result.BaseURL = other.BaseURL
if other.BaseUIURL != "" {
result.BaseUIURL = other.BaseUIURL
}
return result
}
@ -123,8 +123,8 @@ func (this *VaultUIConfig) Merge(other *VaultUIConfig) *VaultUIConfig {
return result
}
if other.BaseURL != "" {
result.BaseURL = other.BaseURL
if other.BaseUIURL != "" {
result.BaseUIURL = other.BaseUIURL
}
return result
}

View File

@ -11,10 +11,10 @@ func TestUIConfig_Merge(t *testing.T) {
fullConfig := &UIConfig{
Enabled: true,
Consul: &ConsulUIConfig{
BaseURL: "http://consul.example.com:8500",
BaseUIURL: "http://consul.example.com:8500",
},
Vault: &VaultUIConfig{
BaseURL: "http://vault.example.com:8200",
BaseUIURL: "http://vault.example.com:8200",
},
}
@ -41,7 +41,7 @@ func TestUIConfig_Merge(t *testing.T) {
left: &UIConfig{
Enabled: false,
Consul: &ConsulUIConfig{
BaseURL: "http://consul-other.example.com:8500",
BaseUIURL: "http://consul-other.example.com:8500",
},
},
right: fullConfig,
@ -52,14 +52,14 @@ func TestUIConfig_Merge(t *testing.T) {
left: &UIConfig{
Enabled: true,
Consul: &ConsulUIConfig{
BaseURL: "http://consul-other.example.com:8500",
BaseUIURL: "http://consul-other.example.com:8500",
},
},
right: &UIConfig{},
expect: &UIConfig{
Enabled: false,
Consul: &ConsulUIConfig{
BaseURL: "http://consul-other.example.com:8500",
BaseUIURL: "http://consul-other.example.com:8500",
},
Vault: &VaultUIConfig{},
},

View File

@ -23,13 +23,13 @@
Storybook
</a>
{{/if}}
{{#if this.agent.config.UI.Consul.BaseUrl}}
<a href={{this.agent.config.UI.Consul.BaseUrl}} class="navbar-item">
{{#if this.system.agent.config.UI.Consul.BaseUIURL}}
<a href={{this.system.agent.config.UI.Consul.BaseUIURL}} class="navbar-item">
Consul
</a>
{{/if}}
{{#if this.agent.config.UI.Vault.BaseUrl}}
<a href={{this.agent.config.UI.Vault.BaseUrl}} class="navbar-item">
{{#if this.system.agent.config.UI.Vault.BaseUIURL}}
<a href={{this.system.agent.config.UI.Vault.BaseUIURL}} class="navbar-item">
Vault
</a>
{{/if}}
@ -50,4 +50,4 @@
{{yield}}
</ul>
</nav>
</div>
</div>

View File

@ -17,11 +17,11 @@ ui {
enabled = true
consul {
base_url = "https://consul.example.com:8500/ui"
ui_url = "https://consul.example.com:8500/ui"
}
vault {
base_url = "https://vault.example.com:8200/ui"
ui_url = "https://vault.example.com:8200/ui"
}
}
```
@ -41,24 +41,24 @@ and the configuration is individual to each agent.
## `consul` Parameters
- `base_url` `(string: "")` - Specifies the full base URL to a Consul
- `ui_url` `(string: "")` - Specifies the full base URL to a Consul
web UI (for example: `https://consul.example.com:8500/ui`. This URL
is used to build links from the Nomad web UI to a Consul web
UI. Note that this URL will not typically be the same one used for
the agent's [`consul.address`]; the `consul.address` is the URL used
by the Nomad to communicate with Consul, whereas the
`ui.consul.base_url` is the URL you'll visit in your browser. If
`ui.consul.ui_url` is the URL you'll visit in your browser. If
this field is omitted, this integration will be disabled.
## `vault` Parameters
- `base_url` `(string: "")` - Specifies the full base URL to a Vault
- `ui_url` `(string: "")` - Specifies the full base URL to a Vault
web UI (for example: `https://vault.example.com:8200/ui`. This URL
is used to build links from the Nomad web UI to a Vault web
UI. Note that this URL will not typically be the same one used for
the agent's [`vault.address`]; the `vault.address` is the URL used
by the Nomad to communicate with Vault, whereas the
`ui.vault.base_url` is the URL you'll visit in your browser. If
`ui.vault.ui_url` is the URL you'll visit in your browser. If
this field is omitted, this integration will be disabled.