From 1a08e8c0f139664cb3c6052b38d12ee1eb21f6c3 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Fri, 2 Feb 2018 17:29:34 -0800 Subject: [PATCH] Changes "TLS" to "GRPCUseTLS" since it only applies to GRPC checks. --- agent/agent.go | 2 +- agent/config/builder.go | 2 +- agent/config/config.go | 2 +- agent/config/runtime_test.go | 10 +++++----- agent/structs/check_definition.go | 4 ++-- agent/structs/check_type.go | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index d6b78292d..a64b52985 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -1766,7 +1766,7 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *structs.CheckType, } var tlsClientConfig *tls.Config - if chkType.TLS { + if chkType.GRPCUseTLS { var err error tlsClientConfig, err = a.setupTLSClientConfig(chkType.TLSSkipVerify) if err != nil { diff --git a/agent/config/builder.go b/agent/config/builder.go index e67b79292..e4193925f 100644 --- a/agent/config/builder.go +++ b/agent/config/builder.go @@ -946,7 +946,7 @@ func (b *Builder) checkVal(v *CheckDefinition) *structs.CheckDefinition { DockerContainerID: b.stringVal(v.DockerContainerID), Shell: b.stringVal(v.Shell), GRPC: b.stringVal(v.GRPC), - TLS: b.boolVal(v.TLS), + GRPCUseTLS: b.boolVal(v.GRPCUseTLS), TLSSkipVerify: b.boolVal(v.TLSSkipVerify), Timeout: b.durationVal(fmt.Sprintf("check[%s].timeout", id), v.Timeout), TTL: b.durationVal(fmt.Sprintf("check[%s].ttl", id), v.TTL), diff --git a/agent/config/config.go b/agent/config/config.go index 242639737..ac9bcd494 100644 --- a/agent/config/config.go +++ b/agent/config/config.go @@ -342,7 +342,7 @@ type CheckDefinition struct { DockerContainerID *string `json:"docker_container_id,omitempty" hcl:"docker_container_id" mapstructure:"docker_container_id"` Shell *string `json:"shell,omitempty" hcl:"shell" mapstructure:"shell"` GRPC *string `json:"grpc,omitempty" hcl:"grpc" mapstructure:"grpc"` - TLS *bool `json:"tls,omitempty" hcl:"tls" mapstructure:"tls"` + GRPCUseTLS *bool `json:"grpc_use_tls,omitempty" hcl:"grpc_use_tls" mapstructure:"grpc_use_tls"` TLSSkipVerify *bool `json:"tls_skip_verify,omitempty" hcl:"tls_skip_verify" mapstructure:"tls_skip_verify"` Timeout *string `json:"timeout,omitempty" hcl:"timeout" mapstructure:"timeout"` TTL *string `json:"ttl,omitempty" hcl:"ttl" mapstructure:"ttl"` diff --git a/agent/config/runtime_test.go b/agent/config/runtime_test.go index fbf32c39c..66590190a 100644 --- a/agent/config/runtime_test.go +++ b/agent/config/runtime_test.go @@ -1868,14 +1868,14 @@ func TestConfigFlagsAndEdgecases(t *testing.T) { `-data-dir=` + dataDir, }, json: []string{ - `{ "check": { "name": "a", "grpc": "localhost:12345/foo" } }`, + `{ "check": { "name": "a", "grpc": "localhost:12345/foo", "grpc_use_tls": true } }`, }, hcl: []string{ - `check = { name = "a" grpc = "localhost:12345/foo" }`, + `check = { name = "a" grpc = "localhost:12345/foo", grpc_use_tls = true }`, }, patch: func(rt *RuntimeConfig) { rt.Checks = []*structs.CheckDefinition{ - &structs.CheckDefinition{Name: "a", GRPC: "localhost:12345/foo"}, + &structs.CheckDefinition{Name: "a", GRPC: "localhost:12345/foo", GRPCUseTLS: true}, } rt.DataDir = dataDir }, @@ -3906,6 +3906,7 @@ func TestSanitize(t *testing.T) { "DeregisterCriticalServiceAfter": "0s", "DockerContainerID": "", "GRPC": "", + "GRPCUseTLS": false, "HTTP": "", "Header": {}, "ID": "", @@ -3919,7 +3920,6 @@ func TestSanitize(t *testing.T) { "Shell": "", "Status": "", "TCP": "", - "TLS": false, "TLSSkipVerify": false, "TTL": "0s", "Timeout": "0s", @@ -4037,6 +4037,7 @@ func TestSanitize(t *testing.T) { "DeregisterCriticalServiceAfter": "0s", "DockerContainerID": "", "GRPC": "", + "GRPCUseTLS": false, "HTTP": "", "Header": {}, "Interval": "0s", @@ -4048,7 +4049,6 @@ func TestSanitize(t *testing.T) { "Shell": "", "Status": "", "TCP": "", - "TLS": false, "TLSSkipVerify": false, "TTL": "0s", "Timeout": "0s" diff --git a/agent/structs/check_definition.go b/agent/structs/check_definition.go index 36deb02c8..364c6b3d6 100644 --- a/agent/structs/check_definition.go +++ b/agent/structs/check_definition.go @@ -31,7 +31,7 @@ type CheckDefinition struct { DockerContainerID string Shell string GRPC string - TLS bool + GRPCUseTLS bool TLSSkipVerify bool Timeout time.Duration TTL time.Duration @@ -67,13 +67,13 @@ func (c *CheckDefinition) CheckType() *CheckType { ScriptArgs: c.ScriptArgs, HTTP: c.HTTP, GRPC: c.GRPC, + GRPCUseTLS: c.GRPCUseTLS, Header: c.Header, Method: c.Method, TCP: c.TCP, Interval: c.Interval, DockerContainerID: c.DockerContainerID, Shell: c.Shell, - TLS: c.TLS, TLSSkipVerify: c.TLSSkipVerify, Timeout: c.Timeout, TTL: c.TTL, diff --git a/agent/structs/check_type.go b/agent/structs/check_type.go index 835fc2d6f..ea5b10aa0 100644 --- a/agent/structs/check_type.go +++ b/agent/structs/check_type.go @@ -35,7 +35,7 @@ type CheckType struct { DockerContainerID string Shell string GRPC string - TLS bool + GRPCUseTLS bool TLSSkipVerify bool Timeout time.Duration TTL time.Duration