adding configuration option cloud.scada_address (#14936)

* adding scada_address

* config tests

* add changelog entry
This commit is contained in:
Hans Hasselberg 2022-10-13 11:31:28 +02:00 committed by GitHub
parent be1a4438a9
commit 56580d6fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 3 deletions

3
.changelog/14936.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
agent: Added configuration option cloud.scada_address.
```

View File

@ -2459,6 +2459,7 @@ func (b *builder) cloudConfigVal(v *CloudConfigRaw) (val hcpconfig.CloudConfig)
val.ClientSecret = stringVal(v.ClientSecret) val.ClientSecret = stringVal(v.ClientSecret)
val.AuthURL = stringVal(v.AuthURL) val.AuthURL = stringVal(v.AuthURL)
val.Hostname = stringVal(v.Hostname) val.Hostname = stringVal(v.Hostname)
val.ScadaAddress = stringVal(v.ScadaAddress)
return val return val
} }

View File

@ -866,6 +866,7 @@ type CloudConfigRaw struct {
ClientSecret *string `mapstructure:"client_secret"` ClientSecret *string `mapstructure:"client_secret"`
Hostname *string `mapstructure:"hostname"` Hostname *string `mapstructure:"hostname"`
AuthURL *string `mapstructure:"auth_url"` AuthURL *string `mapstructure:"auth_url"`
ScadaAddress *string `mapstructure:"scada_address"`
} }
type TLSProtocolConfig struct { type TLSProtocolConfig struct {

View File

@ -5996,6 +5996,7 @@ func TestLoad_FullConfig(t *testing.T) {
ClientSecret: "lCSMHOpB", ClientSecret: "lCSMHOpB",
Hostname: "DH4bh7aC", Hostname: "DH4bh7aC",
AuthURL: "332nCdR2", AuthURL: "332nCdR2",
ScadaAddress: "aoeusth232",
}, },
DNSAddrs: []net.Addr{tcpAddr("93.95.95.81:7001"), udpAddr("93.95.95.81:7001")}, DNSAddrs: []net.Addr{tcpAddr("93.95.95.81:7001"), udpAddr("93.95.95.81:7001")},
DNSARecordLimit: 29907, DNSARecordLimit: 29907,

View File

@ -129,7 +129,8 @@
"ClientID": "id", "ClientID": "id",
"ClientSecret": "hidden", "ClientSecret": "hidden",
"Hostname": "", "Hostname": "",
"ResourceID": "cluster1" "ResourceID": "cluster1",
"ScadaAddress": ""
}, },
"ConfigEntryBootstrap": [], "ConfigEntryBootstrap": [],
"ConnectCAConfig": {}, "ConnectCAConfig": {},
@ -479,4 +480,4 @@
"VersionMetadata": "", "VersionMetadata": "",
"VersionPrerelease": "", "VersionPrerelease": "",
"Watches": [] "Watches": []
} }

View File

@ -207,6 +207,7 @@ cloud {
client_secret = "lCSMHOpB" client_secret = "lCSMHOpB"
hostname = "DH4bh7aC" hostname = "DH4bh7aC"
auth_url = "332nCdR2" auth_url = "332nCdR2"
scada_address = "aoeusth232"
} }
connect { connect {
ca_provider = "consul" ca_provider = "consul"

View File

@ -208,7 +208,8 @@
"client_id": "6WvsDZCP", "client_id": "6WvsDZCP",
"client_secret": "lCSMHOpB", "client_secret": "lCSMHOpB",
"hostname": "DH4bh7aC", "hostname": "DH4bh7aC",
"auth_url": "332nCdR2" "auth_url": "332nCdR2",
"scada_address": "aoeusth232"
}, },
"connect": { "connect": {
"ca_provider": "consul", "ca_provider": "consul",

View File

@ -13,6 +13,7 @@ type CloudConfig struct {
ClientSecret string ClientSecret string
Hostname string Hostname string
AuthURL string AuthURL string
ScadaAddress string
} }
func (c *CloudConfig) HCPConfig(opts ...hcpcfg.HCPConfigOption) (hcpcfg.HCPConfig, error) { func (c *CloudConfig) HCPConfig(opts ...hcpcfg.HCPConfigOption) (hcpcfg.HCPConfig, error) {
@ -25,6 +26,9 @@ func (c *CloudConfig) HCPConfig(opts ...hcpcfg.HCPConfigOption) (hcpcfg.HCPConfi
if c.Hostname != "" { if c.Hostname != "" {
opts = append(opts, hcpcfg.WithAPI(c.Hostname, &tls.Config{})) opts = append(opts, hcpcfg.WithAPI(c.Hostname, &tls.Config{}))
} }
if c.ScadaAddress != "" {
opts = append(opts, hcpcfg.WithSCADA(c.ScadaAddress, &tls.Config{}))
}
opts = append(opts, hcpcfg.FromEnv()) opts = append(opts, hcpcfg.FromEnv())
return hcpcfg.NewHCPConfig(opts...) return hcpcfg.NewHCPConfig(opts...)
} }