github.com/hernad/nomad@v1.6.112/nomad/structs/config/ui.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package config 5 6 // UIConfig contains the operator configuration of the web UI 7 // Note: 8 // before extending this configuration, consider reviewing NMD-125 9 type UIConfig struct { 10 11 // Enabled is used to enable the web UI 12 Enabled bool `hcl:"enabled"` 13 14 // Consul configures deep links for Consul UI 15 Consul *ConsulUIConfig `hcl:"consul"` 16 17 // Vault configures deep links for Vault UI 18 Vault *VaultUIConfig `hcl:"vault"` 19 20 // Label configures UI label styles 21 Label *LabelUIConfig `hcl:"label"` 22 } 23 24 // ConsulUIConfig configures deep links to this cluster's Consul 25 type ConsulUIConfig struct { 26 27 // BaseUIURL provides the full base URL to the UI, ex: 28 // https://consul.example.com:8500/ui/ 29 BaseUIURL string `hcl:"ui_url"` 30 } 31 32 // VaultUIConfig configures deep links to this cluster's Vault 33 type VaultUIConfig struct { 34 // BaseUIURL provides the full base URL to the UI, ex: 35 // https://vault.example.com:8200/ui/ 36 BaseUIURL string `hcl:"ui_url"` 37 } 38 39 // Label configures UI label styles 40 type LabelUIConfig struct { 41 Text string `hcl:"text"` 42 BackgroundColor string `hcl:"background_color"` 43 TextColor string `hcl:"text_color"` 44 } 45 46 // DefaultUIConfig returns the canonical defaults for the Nomad 47 // `ui` configuration. 48 func DefaultUIConfig() *UIConfig { 49 return &UIConfig{ 50 Enabled: true, 51 Consul: &ConsulUIConfig{}, 52 Vault: &VaultUIConfig{}, 53 Label: &LabelUIConfig{}, 54 } 55 } 56 57 // Copy returns a copy of this UI config. 58 func (old *UIConfig) Copy() *UIConfig { 59 if old == nil { 60 return nil 61 } 62 63 nc := new(UIConfig) 64 *nc = *old 65 66 if old.Consul != nil { 67 nc.Consul = old.Consul.Copy() 68 } 69 if old.Vault != nil { 70 nc.Vault = old.Vault.Copy() 71 } 72 return nc 73 } 74 75 // Merge returns a new UI configuration by merging another UI 76 // configuration into this one 77 func (old *UIConfig) Merge(other *UIConfig) *UIConfig { 78 result := old.Copy() 79 if other == nil { 80 return result 81 } 82 83 result.Enabled = other.Enabled 84 result.Consul = result.Consul.Merge(other.Consul) 85 result.Vault = result.Vault.Merge(other.Vault) 86 result.Label = result.Label.Merge(other.Label) 87 88 return result 89 } 90 91 // Copy returns a copy of this Consul UI config. 92 func (old *ConsulUIConfig) Copy() *ConsulUIConfig { 93 if old == nil { 94 return nil 95 } 96 97 nc := new(ConsulUIConfig) 98 *nc = *old 99 return nc 100 } 101 102 // Merge returns a new Consul UI configuration by merging another Consul UI 103 // configuration into this one 104 func (old *ConsulUIConfig) Merge(other *ConsulUIConfig) *ConsulUIConfig { 105 result := old.Copy() 106 if result == nil { 107 result = &ConsulUIConfig{} 108 } 109 if other == nil { 110 return result 111 } 112 113 if other.BaseUIURL != "" { 114 result.BaseUIURL = other.BaseUIURL 115 } 116 return result 117 } 118 119 // Copy returns a copy of this Vault UI config. 120 func (old *VaultUIConfig) Copy() *VaultUIConfig { 121 if old == nil { 122 return nil 123 } 124 125 nc := new(VaultUIConfig) 126 *nc = *old 127 return nc 128 } 129 130 // Merge returns a new Vault UI configuration by merging another Vault UI 131 // configuration into this one 132 func (old *VaultUIConfig) Merge(other *VaultUIConfig) *VaultUIConfig { 133 result := old.Copy() 134 if result == nil { 135 result = &VaultUIConfig{} 136 } 137 if other == nil { 138 return result 139 } 140 141 if other.BaseUIURL != "" { 142 result.BaseUIURL = other.BaseUIURL 143 } 144 return result 145 } 146 147 // Copy returns a copy of this Label UI config. 148 func (old *LabelUIConfig) Copy() *LabelUIConfig { 149 if old == nil { 150 return nil 151 } 152 153 nc := new(LabelUIConfig) 154 *nc = *old 155 return nc 156 } 157 158 // Merge returns a new Label UI configuration by merging another Label UI 159 // configuration into this one 160 func (old *LabelUIConfig) Merge(other *LabelUIConfig) *LabelUIConfig { 161 result := old.Copy() 162 if result == nil { 163 result = &LabelUIConfig{} 164 } 165 if other == nil { 166 return result 167 } 168 169 if other.Text != "" { 170 result.Text = other.Text 171 } 172 if other.BackgroundColor != "" { 173 result.BackgroundColor = other.BackgroundColor 174 } 175 if other.TextColor != "" { 176 result.TextColor = other.TextColor 177 } 178 return result 179 }