1package config
2
3import (
4	"encoding/json"
5	"fmt"
6	"strings"
7
8	"github.com/hashicorp/consul/lib"
9	"github.com/hashicorp/go-multierror"
10	"github.com/hashicorp/hcl"
11	"github.com/mitchellh/mapstructure"
12)
13
14const (
15	SerfLANKeyring = "serf/local.keyring"
16	SerfWANKeyring = "serf/remote.keyring"
17)
18
19type Source struct {
20	Name   string
21	Format string
22	Data   string
23}
24
25func FormatFrom(name string) string {
26	switch {
27	case strings.HasSuffix(name, ".json"):
28		return "json"
29	case strings.HasSuffix(name, ".hcl"):
30		return "hcl"
31	default:
32		return ""
33	}
34}
35
36// Parse parses a config fragment in either JSON or HCL format.
37func Parse(data string, format string) (c Config, err error) {
38	var raw map[string]interface{}
39	switch format {
40	case "json":
41		err = json.Unmarshal([]byte(data), &raw)
42	case "hcl":
43		err = hcl.Decode(&raw, data)
44	default:
45		err = fmt.Errorf("invalid format: %s", format)
46	}
47	if err != nil {
48		return Config{}, err
49	}
50
51	// We want to be able to report fields which we cannot map as an
52	// error so that users find typos in their configuration quickly. To
53	// achieve this we use the mapstructure library which maps a a raw
54	// map[string]interface{} to a nested structure and reports unused
55	// fields. The input for a mapstructure.Decode expects a
56	// map[string]interface{} as produced by encoding/json.
57	//
58	// The HCL language allows to repeat map keys which forces it to
59	// store nested structs as []map[string]interface{} instead of
60	// map[string]interface{}. This is an ambiguity which makes the
61	// generated structures incompatible with a corresponding JSON
62	// struct. It also does not work well with the mapstructure library.
63	//
64	// In order to still use the mapstructure library to find unused
65	// fields we patch instances of []map[string]interface{} to a
66	// map[string]interface{} before we decode that into a Config
67	// struct.
68	//
69	// However, Config has some fields which are either
70	// []map[string]interface{} or are arrays of structs which
71	// encoding/json will decode to []map[string]interface{}. Therefore,
72	// we need to be able to specify exceptions for this mapping. The
73	// PatchSliceOfMaps() implements that mapping. All fields of type
74	// []map[string]interface{} are mapped to map[string]interface{} if
75	// it contains at most one value. If there is more than one value it
76	// panics. To define exceptions one can specify the nested field
77	// names in dot notation.
78	//
79	// todo(fs): There might be an easier way to achieve the same thing
80	// todo(fs): but this approach works for now.
81	m := lib.PatchSliceOfMaps(raw, []string{
82		"checks",
83		"segments",
84		"service.checks",
85		"services",
86		"services.checks",
87		"watches",
88		"service.connect.proxy.config.upstreams", // Deprecated
89		"services.connect.proxy.config.upstreams", // Deprecated
90		"service.connect.proxy.upstreams",
91		"services.connect.proxy.upstreams",
92		"service.connect.proxy.expose.paths",
93		"services.connect.proxy.expose.paths",
94		"service.proxy.upstreams",
95		"services.proxy.upstreams",
96		"service.proxy.expose.paths",
97		"services.proxy.expose.paths",
98		"acl.tokens.managed_service_provider",
99
100		// Need all the service(s) exceptions also for nested sidecar service.
101		"service.connect.sidecar_service.checks",
102		"services.connect.sidecar_service.checks",
103		"service.connect.sidecar_service.proxy.upstreams",
104		"services.connect.sidecar_service.proxy.upstreams",
105		"service.connect.sidecar_service.proxy.expose.paths",
106		"services.connect.sidecar_service.proxy.expose.paths",
107	}, []string{
108		"config_entries.bootstrap", // completely ignore this tree (fixed elsewhere)
109	})
110
111	// There is a difference of representation of some fields depending on
112	// where they are used. The HTTP API uses CamelCase whereas the config
113	// files use snake_case and between the two there is no automatic mapping.
114	// While the JSON and HCL parsers match keys without case (both `id` and
115	// `ID` are mapped to an ID field) the same thing does not happen between
116	// CamelCase and snake_case. Since changing either format would break
117	// existing setups we have to support both and slowly transition to one of
118	// the formats. Also, there is at least one case where we use the "wrong"
119	// key and want to map that to the new key to support deprecation -
120	// see [GH-3179]. TranslateKeys maps potentially CamelCased values to the
121	// snake_case that is used in the config file parser. If both the CamelCase
122	// and snake_case values are set the snake_case value is used and the other
123	// value is discarded.
124	lib.TranslateKeys(m, map[string]string{
125		"deregistercriticalserviceafter": "deregister_critical_service_after",
126		"dockercontainerid":              "docker_container_id",
127		"scriptargs":                     "args",
128		"serviceid":                      "service_id",
129		"tlsskipverify":                  "tls_skip_verify",
130		"config_entries.bootstrap":       "",
131	})
132
133	var md mapstructure.Metadata
134	d, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
135		Metadata: &md,
136		Result:   &c,
137	})
138	if err != nil {
139		return Config{}, err
140	}
141	if err := d.Decode(m); err != nil {
142		return Config{}, err
143	}
144
145	for _, k := range md.Unused {
146		err = multierror.Append(err, fmt.Errorf("invalid config key %s", k))
147	}
148	return
149}
150
151// Config defines the format of a configuration file in either JSON or
152// HCL format.
153//
154// It must contain only pointer values, slices and maps to support
155// standardized merging of multiple Config structs into one.
156//
157// Since this is the format which users use to specify their
158// configuration it should be treated as an external API which cannot be
159// changed and refactored at will since this will break existing setups.
160type Config struct {
161	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
162	ACLAgentMasterToken *string `json:"acl_agent_master_token,omitempty" hcl:"acl_agent_master_token" mapstructure:"acl_agent_master_token"`
163	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
164	ACLAgentToken *string `json:"acl_agent_token,omitempty" hcl:"acl_agent_token" mapstructure:"acl_agent_token"`
165	// DEPRECATED (ACL-Legacy-Compat) - moved to "primary_datacenter"
166	ACLDatacenter *string `json:"acl_datacenter,omitempty" hcl:"acl_datacenter" mapstructure:"acl_datacenter"`
167	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
168	ACLDefaultPolicy *string `json:"acl_default_policy,omitempty" hcl:"acl_default_policy" mapstructure:"acl_default_policy"`
169	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
170	ACLDownPolicy *string `json:"acl_down_policy,omitempty" hcl:"acl_down_policy" mapstructure:"acl_down_policy"`
171	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
172	ACLEnableKeyListPolicy *bool `json:"acl_enable_key_list_policy,omitempty" hcl:"acl_enable_key_list_policy" mapstructure:"acl_enable_key_list_policy"`
173	// DEPRECATED (ACL-Legacy-Compat) -  pre-version8 enforcement is deprecated.
174	ACLEnforceVersion8 *bool `json:"acl_enforce_version_8,omitempty" hcl:"acl_enforce_version_8" mapstructure:"acl_enforce_version_8"`
175	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
176	ACLMasterToken *string `json:"acl_master_token,omitempty" hcl:"acl_master_token" mapstructure:"acl_master_token"`
177	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
178	ACLReplicationToken *string `json:"acl_replication_token,omitempty" hcl:"acl_replication_token" mapstructure:"acl_replication_token"`
179	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
180	ACLTTL *string `json:"acl_ttl,omitempty" hcl:"acl_ttl" mapstructure:"acl_ttl"`
181	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
182	ACLToken                         *string                  `json:"acl_token,omitempty" hcl:"acl_token" mapstructure:"acl_token"`
183	ACL                              ACL                      `json:"acl,omitempty" hcl:"acl" mapstructure:"acl"`
184	Addresses                        Addresses                `json:"addresses,omitempty" hcl:"addresses" mapstructure:"addresses"`
185	AdvertiseAddrLAN                 *string                  `json:"advertise_addr,omitempty" hcl:"advertise_addr" mapstructure:"advertise_addr"`
186	AdvertiseAddrLANIPv4             *string                  `json:"advertise_addr_ipv4,omitempty" hcl:"advertise_addr_ipv4" mapstructure:"advertise_addr_ipv4"`
187	AdvertiseAddrLANIPv6             *string                  `json:"advertise_addr_ipv6,omitempty" hcl:"advertise_addr_ipv6" mapstructure:"advertise_addr_ipv6"`
188	AdvertiseAddrWAN                 *string                  `json:"advertise_addr_wan,omitempty" hcl:"advertise_addr_wan" mapstructure:"advertise_addr_wan"`
189	AdvertiseAddrWANIPv4             *string                  `json:"advertise_addr_wan_ipv4,omitempty" hcl:"advertise_addr_wan_ipv4" mapstructure:"advertise_addr_wan_ipv4"`
190	AdvertiseAddrWANIPv6             *string                  `json:"advertise_addr_wan_ipv6,omitempty" hcl:"advertise_addr_wan_ipv6" mapstructure:"advertise_addr_ipv6"`
191	Autopilot                        Autopilot                `json:"autopilot,omitempty" hcl:"autopilot" mapstructure:"autopilot"`
192	BindAddr                         *string                  `json:"bind_addr,omitempty" hcl:"bind_addr" mapstructure:"bind_addr"`
193	Bootstrap                        *bool                    `json:"bootstrap,omitempty" hcl:"bootstrap" mapstructure:"bootstrap"`
194	BootstrapExpect                  *int                     `json:"bootstrap_expect,omitempty" hcl:"bootstrap_expect" mapstructure:"bootstrap_expect"`
195	CAFile                           *string                  `json:"ca_file,omitempty" hcl:"ca_file" mapstructure:"ca_file"`
196	CAPath                           *string                  `json:"ca_path,omitempty" hcl:"ca_path" mapstructure:"ca_path"`
197	CertFile                         *string                  `json:"cert_file,omitempty" hcl:"cert_file" mapstructure:"cert_file"`
198	Check                            *CheckDefinition         `json:"check,omitempty" hcl:"check" mapstructure:"check"` // needs to be a pointer to avoid partial merges
199	CheckOutputMaxSize               *int                     `json:"check_output_max_size,omitempty" hcl:"check_output_max_size" mapstructure:"check_output_max_size"`
200	CheckUpdateInterval              *string                  `json:"check_update_interval,omitempty" hcl:"check_update_interval" mapstructure:"check_update_interval"`
201	Checks                           []CheckDefinition        `json:"checks,omitempty" hcl:"checks" mapstructure:"checks"`
202	ClientAddr                       *string                  `json:"client_addr,omitempty" hcl:"client_addr" mapstructure:"client_addr"`
203	ConfigEntries                    ConfigEntries            `json:"config_entries,omitempty" hcl:"config_entries" mapstructure:"config_entries"`
204	AutoEncrypt                      AutoEncrypt              `json:"auto_encrypt,omitempty" hcl:"auto_encrypt" mapstructure:"auto_encrypt"`
205	Connect                          Connect                  `json:"connect,omitempty" hcl:"connect" mapstructure:"connect"`
206	DNS                              DNS                      `json:"dns_config,omitempty" hcl:"dns_config" mapstructure:"dns_config"`
207	DNSDomain                        *string                  `json:"domain,omitempty" hcl:"domain" mapstructure:"domain"`
208	DNSAltDomain                     *string                  `json:"alt_domain,omitempty" hcl:"alt_domain" mapstructure:"alt_domain"`
209	DNSRecursors                     []string                 `json:"recursors,omitempty" hcl:"recursors" mapstructure:"recursors"`
210	DataDir                          *string                  `json:"data_dir,omitempty" hcl:"data_dir" mapstructure:"data_dir"`
211	Datacenter                       *string                  `json:"datacenter,omitempty" hcl:"datacenter" mapstructure:"datacenter"`
212	DefaultQueryTime                 *string                  `json:"default_query_time,omitempty" hcl:"default_query_time" mapstructure:"default_query_time"`
213	DisableAnonymousSignature        *bool                    `json:"disable_anonymous_signature,omitempty" hcl:"disable_anonymous_signature" mapstructure:"disable_anonymous_signature"`
214	DisableCoordinates               *bool                    `json:"disable_coordinates,omitempty" hcl:"disable_coordinates" mapstructure:"disable_coordinates"`
215	DisableHostNodeID                *bool                    `json:"disable_host_node_id,omitempty" hcl:"disable_host_node_id" mapstructure:"disable_host_node_id"`
216	DisableHTTPUnprintableCharFilter *bool                    `json:"disable_http_unprintable_char_filter,omitempty" hcl:"disable_http_unprintable_char_filter" mapstructure:"disable_http_unprintable_char_filter"`
217	DisableKeyringFile               *bool                    `json:"disable_keyring_file,omitempty" hcl:"disable_keyring_file" mapstructure:"disable_keyring_file"`
218	DisableRemoteExec                *bool                    `json:"disable_remote_exec,omitempty" hcl:"disable_remote_exec" mapstructure:"disable_remote_exec"`
219	DisableUpdateCheck               *bool                    `json:"disable_update_check,omitempty" hcl:"disable_update_check" mapstructure:"disable_update_check"`
220	DiscardCheckOutput               *bool                    `json:"discard_check_output" hcl:"discard_check_output" mapstructure:"discard_check_output"`
221	DiscoveryMaxStale                *string                  `json:"discovery_max_stale" hcl:"discovery_max_stale" mapstructure:"discovery_max_stale"`
222	EnableACLReplication             *bool                    `json:"enable_acl_replication,omitempty" hcl:"enable_acl_replication" mapstructure:"enable_acl_replication"`
223	EnableAgentTLSForChecks          *bool                    `json:"enable_agent_tls_for_checks,omitempty" hcl:"enable_agent_tls_for_checks" mapstructure:"enable_agent_tls_for_checks"`
224	EnableCentralServiceConfig       *bool                    `json:"enable_central_service_config,omitempty" hcl:"enable_central_service_config" mapstructure:"enable_central_service_config"`
225	EnableDebug                      *bool                    `json:"enable_debug,omitempty" hcl:"enable_debug" mapstructure:"enable_debug"`
226	EnableScriptChecks               *bool                    `json:"enable_script_checks,omitempty" hcl:"enable_script_checks" mapstructure:"enable_script_checks"`
227	EnableLocalScriptChecks          *bool                    `json:"enable_local_script_checks,omitempty" hcl:"enable_local_script_checks" mapstructure:"enable_local_script_checks"`
228	EnableSyslog                     *bool                    `json:"enable_syslog,omitempty" hcl:"enable_syslog" mapstructure:"enable_syslog"`
229	EncryptKey                       *string                  `json:"encrypt,omitempty" hcl:"encrypt" mapstructure:"encrypt"`
230	EncryptVerifyIncoming            *bool                    `json:"encrypt_verify_incoming,omitempty" hcl:"encrypt_verify_incoming" mapstructure:"encrypt_verify_incoming"`
231	EncryptVerifyOutgoing            *bool                    `json:"encrypt_verify_outgoing,omitempty" hcl:"encrypt_verify_outgoing" mapstructure:"encrypt_verify_outgoing"`
232	GossipLAN                        GossipLANConfig          `json:"gossip_lan,omitempty" hcl:"gossip_lan" mapstructure:"gossip_lan"`
233	GossipWAN                        GossipWANConfig          `json:"gossip_wan,omitempty" hcl:"gossip_wan" mapstructure:"gossip_wan"`
234	HTTPConfig                       HTTPConfig               `json:"http_config,omitempty" hcl:"http_config" mapstructure:"http_config"`
235	KeyFile                          *string                  `json:"key_file,omitempty" hcl:"key_file" mapstructure:"key_file"`
236	LeaveOnTerm                      *bool                    `json:"leave_on_terminate,omitempty" hcl:"leave_on_terminate" mapstructure:"leave_on_terminate"`
237	Limits                           Limits                   `json:"limits,omitempty" hcl:"limits" mapstructure:"limits"`
238	LogLevel                         *string                  `json:"log_level,omitempty" hcl:"log_level" mapstructure:"log_level"`
239	LogJSON                          *bool                    `json:"log_json,omitempty" hcl:"log_json" mapstructure:"log_json"`
240	LogFile                          *string                  `json:"log_file,omitempty" hcl:"log_file" mapstructure:"log_file"`
241	LogRotateDuration                *string                  `json:"log_rotate_duration,omitempty" hcl:"log_rotate_duration" mapstructure:"log_rotate_duration"`
242	LogRotateBytes                   *int                     `json:"log_rotate_bytes,omitempty" hcl:"log_rotate_bytes" mapstructure:"log_rotate_bytes"`
243	LogRotateMaxFiles                *int                     `json:"log_rotate_max_files,omitempty" hcl:"log_rotate_max_files" mapstructure:"log_rotate_max_files"`
244	MaxQueryTime                     *string                  `json:"max_query_time,omitempty" hcl:"max_query_time" mapstructure:"max_query_time"`
245	NodeID                           *string                  `json:"node_id,omitempty" hcl:"node_id" mapstructure:"node_id"`
246	NodeMeta                         map[string]string        `json:"node_meta,omitempty" hcl:"node_meta" mapstructure:"node_meta"`
247	NodeName                         *string                  `json:"node_name,omitempty" hcl:"node_name" mapstructure:"node_name"`
248	NonVotingServer                  *bool                    `json:"non_voting_server,omitempty" hcl:"non_voting_server" mapstructure:"non_voting_server"`
249	Performance                      Performance              `json:"performance,omitempty" hcl:"performance" mapstructure:"performance"`
250	PidFile                          *string                  `json:"pid_file,omitempty" hcl:"pid_file" mapstructure:"pid_file"`
251	Ports                            Ports                    `json:"ports,omitempty" hcl:"ports" mapstructure:"ports"`
252	PrimaryDatacenter                *string                  `json:"primary_datacenter,omitempty" hcl:"primary_datacenter" mapstructure:"primary_datacenter"`
253	RPCProtocol                      *int                     `json:"protocol,omitempty" hcl:"protocol" mapstructure:"protocol"`
254	RaftProtocol                     *int                     `json:"raft_protocol,omitempty" hcl:"raft_protocol" mapstructure:"raft_protocol"`
255	RaftSnapshotThreshold            *int                     `json:"raft_snapshot_threshold,omitempty" hcl:"raft_snapshot_threshold" mapstructure:"raft_snapshot_threshold"`
256	RaftSnapshotInterval             *string                  `json:"raft_snapshot_interval,omitempty" hcl:"raft_snapshot_interval" mapstructure:"raft_snapshot_interval"`
257	RaftTrailingLogs                 *int                     `json:"raft_trailing_logs,omitempty" hcl:"raft_trailing_logs" mapstructure:"raft_trailing_logs"`
258	ReconnectTimeoutLAN              *string                  `json:"reconnect_timeout,omitempty" hcl:"reconnect_timeout" mapstructure:"reconnect_timeout"`
259	ReconnectTimeoutWAN              *string                  `json:"reconnect_timeout_wan,omitempty" hcl:"reconnect_timeout_wan" mapstructure:"reconnect_timeout_wan"`
260	RejoinAfterLeave                 *bool                    `json:"rejoin_after_leave,omitempty" hcl:"rejoin_after_leave" mapstructure:"rejoin_after_leave"`
261	RetryJoinIntervalLAN             *string                  `json:"retry_interval,omitempty" hcl:"retry_interval" mapstructure:"retry_interval"`
262	RetryJoinIntervalWAN             *string                  `json:"retry_interval_wan,omitempty" hcl:"retry_interval_wan" mapstructure:"retry_interval_wan"`
263	RetryJoinLAN                     []string                 `json:"retry_join,omitempty" hcl:"retry_join" mapstructure:"retry_join"`
264	RetryJoinMaxAttemptsLAN          *int                     `json:"retry_max,omitempty" hcl:"retry_max" mapstructure:"retry_max"`
265	RetryJoinMaxAttemptsWAN          *int                     `json:"retry_max_wan,omitempty" hcl:"retry_max_wan" mapstructure:"retry_max_wan"`
266	RetryJoinWAN                     []string                 `json:"retry_join_wan,omitempty" hcl:"retry_join_wan" mapstructure:"retry_join_wan"`
267	SegmentName                      *string                  `json:"segment,omitempty" hcl:"segment" mapstructure:"segment"`
268	Segments                         []Segment                `json:"segments,omitempty" hcl:"segments" mapstructure:"segments"`
269	SerfBindAddrLAN                  *string                  `json:"serf_lan,omitempty" hcl:"serf_lan" mapstructure:"serf_lan"`
270	SerfBindAddrWAN                  *string                  `json:"serf_wan,omitempty" hcl:"serf_wan" mapstructure:"serf_wan"`
271	ServerMode                       *bool                    `json:"server,omitempty" hcl:"server" mapstructure:"server"`
272	ServerName                       *string                  `json:"server_name,omitempty" hcl:"server_name" mapstructure:"server_name"`
273	Service                          *ServiceDefinition       `json:"service,omitempty" hcl:"service" mapstructure:"service"`
274	Services                         []ServiceDefinition      `json:"services,omitempty" hcl:"services" mapstructure:"services"`
275	SessionTTLMin                    *string                  `json:"session_ttl_min,omitempty" hcl:"session_ttl_min" mapstructure:"session_ttl_min"`
276	SkipLeaveOnInt                   *bool                    `json:"skip_leave_on_interrupt,omitempty" hcl:"skip_leave_on_interrupt" mapstructure:"skip_leave_on_interrupt"`
277	StartJoinAddrsLAN                []string                 `json:"start_join,omitempty" hcl:"start_join" mapstructure:"start_join"`
278	StartJoinAddrsWAN                []string                 `json:"start_join_wan,omitempty" hcl:"start_join_wan" mapstructure:"start_join_wan"`
279	SyslogFacility                   *string                  `json:"syslog_facility,omitempty" hcl:"syslog_facility" mapstructure:"syslog_facility"`
280	TLSCipherSuites                  *string                  `json:"tls_cipher_suites,omitempty" hcl:"tls_cipher_suites" mapstructure:"tls_cipher_suites"`
281	TLSMinVersion                    *string                  `json:"tls_min_version,omitempty" hcl:"tls_min_version" mapstructure:"tls_min_version"`
282	TLSPreferServerCipherSuites      *bool                    `json:"tls_prefer_server_cipher_suites,omitempty" hcl:"tls_prefer_server_cipher_suites" mapstructure:"tls_prefer_server_cipher_suites"`
283	TaggedAddresses                  map[string]string        `json:"tagged_addresses,omitempty" hcl:"tagged_addresses" mapstructure:"tagged_addresses"`
284	Telemetry                        Telemetry                `json:"telemetry,omitempty" hcl:"telemetry" mapstructure:"telemetry"`
285	TranslateWANAddrs                *bool                    `json:"translate_wan_addrs,omitempty" hcl:"translate_wan_addrs" mapstructure:"translate_wan_addrs"`
286	UI                               *bool                    `json:"ui,omitempty" hcl:"ui" mapstructure:"ui"`
287	UIContentPath                    *string                  `json:"ui_content_path,omitempty" hcl:"ui_content_path" mapstructure:"ui_content_path"`
288	UIDir                            *string                  `json:"ui_dir,omitempty" hcl:"ui_dir" mapstructure:"ui_dir"`
289	UnixSocket                       UnixSocket               `json:"unix_sockets,omitempty" hcl:"unix_sockets" mapstructure:"unix_sockets"`
290	VerifyIncoming                   *bool                    `json:"verify_incoming,omitempty" hcl:"verify_incoming" mapstructure:"verify_incoming"`
291	VerifyIncomingHTTPS              *bool                    `json:"verify_incoming_https,omitempty" hcl:"verify_incoming_https" mapstructure:"verify_incoming_https"`
292	VerifyIncomingRPC                *bool                    `json:"verify_incoming_rpc,omitempty" hcl:"verify_incoming_rpc" mapstructure:"verify_incoming_rpc"`
293	VerifyOutgoing                   *bool                    `json:"verify_outgoing,omitempty" hcl:"verify_outgoing" mapstructure:"verify_outgoing"`
294	VerifyServerHostname             *bool                    `json:"verify_server_hostname,omitempty" hcl:"verify_server_hostname" mapstructure:"verify_server_hostname"`
295	Watches                          []map[string]interface{} `json:"watches,omitempty" hcl:"watches" mapstructure:"watches"`
296
297	// This isn't used by Consul but we've documented a feature where users
298	// can deploy their snapshot agent configs alongside their Consul configs
299	// so we have a placeholder here so it can be parsed but this doesn't
300	// manifest itself in any way inside the runtime config.
301	SnapshotAgent map[string]interface{} `json:"snapshot_agent,omitempty" hcl:"snapshot_agent" mapstructure:"snapshot_agent"`
302
303	// non-user configurable values
304	// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
305	ACLDisabledTTL             *string  `json:"acl_disabled_ttl,omitempty" hcl:"acl_disabled_ttl" mapstructure:"acl_disabled_ttl"`
306	AEInterval                 *string  `json:"ae_interval,omitempty" hcl:"ae_interval" mapstructure:"ae_interval"`
307	CheckDeregisterIntervalMin *string  `json:"check_deregister_interval_min,omitempty" hcl:"check_deregister_interval_min" mapstructure:"check_deregister_interval_min"`
308	CheckReapInterval          *string  `json:"check_reap_interval,omitempty" hcl:"check_reap_interval" mapstructure:"check_reap_interval"`
309	Consul                     Consul   `json:"consul,omitempty" hcl:"consul" mapstructure:"consul"`
310	Revision                   *string  `json:"revision,omitempty" hcl:"revision" mapstructure:"revision"`
311	SegmentLimit               *int     `json:"segment_limit,omitempty" hcl:"segment_limit" mapstructure:"segment_limit"`
312	SegmentNameLimit           *int     `json:"segment_name_limit,omitempty" hcl:"segment_name_limit" mapstructure:"segment_name_limit"`
313	SyncCoordinateIntervalMin  *string  `json:"sync_coordinate_interval_min,omitempty" hcl:"sync_coordinate_interval_min" mapstructure:"sync_coordinate_interval_min"`
314	SyncCoordinateRateTarget   *float64 `json:"sync_coordinate_rate_target,omitempty" hcl:"sync_coordinate_rate_target" mapstructure:"sync_coordinate_rate_target"`
315	Version                    *string  `json:"version,omitempty" hcl:"version" mapstructure:"version"`
316	VersionPrerelease          *string  `json:"version_prerelease,omitempty" hcl:"version_prerelease" mapstructure:"version_prerelease"`
317}
318
319type GossipLANConfig struct {
320	GossipNodes    *int    `json:"gossip_nodes,omitempty" hcl:"gossip_nodes" mapstructure:"gossip_nodes"`
321	GossipInterval *string `json:"gossip_interval,omitempty" hcl:"gossip_interval" mapstructure:"gossip_interval"`
322	ProbeInterval  *string `json:"probe_interval,omitempty" hcl:"probe_interval" mapstructure:"probe_interval"`
323	ProbeTimeout   *string `json:"probe_timeout,omitempty" hcl:"probe_timeout" mapstructure:"probe_timeout"`
324	SuspicionMult  *int    `json:"suspicion_mult,omitempty" hcl:"suspicion_mult" mapstructure:"suspicion_mult"`
325	RetransmitMult *int    `json:"retransmit_mult,omitempty" hcl:"retransmit_mult" mapstructure:"retransmit_mult"`
326}
327
328type GossipWANConfig struct {
329	GossipNodes    *int    `json:"gossip_nodes,omitempty" hcl:"gossip_nodes" mapstructure:"gossip_nodes"`
330	GossipInterval *string `json:"gossip_interval,omitempty" hcl:"gossip_interval" mapstructure:"gossip_interval"`
331	ProbeInterval  *string `json:"probe_interval,omitempty" hcl:"probe_interval" mapstructure:"probe_interval"`
332	ProbeTimeout   *string `json:"probe_timeout,omitempty" hcl:"probe_timeout" mapstructure:"probe_timeout"`
333	SuspicionMult  *int    `json:"suspicion_mult,omitempty" hcl:"suspicion_mult" mapstructure:"suspicion_mult"`
334	RetransmitMult *int    `json:"retransmit_mult,omitempty" hcl:"retransmit_mult" mapstructure:"retransmit_mult"`
335}
336
337type Consul struct {
338	Coordinate struct {
339		UpdateBatchSize  *int    `json:"update_batch_size,omitempty" hcl:"update_batch_size" mapstructure:"update_batch_size"`
340		UpdateMaxBatches *int    `json:"update_max_batches,omitempty" hcl:"update_max_batches" mapstructure:"update_max_batches"`
341		UpdatePeriod     *string `json:"update_period,omitempty" hcl:"update_period" mapstructure:"update_period"`
342	} `json:"coordinate,omitempty" hcl:"coordinate" mapstructure:"coordinate"`
343
344	Raft struct {
345		ElectionTimeout    *string `json:"election_timeout,omitempty" hcl:"election_timeout" mapstructure:"election_timeout"`
346		HeartbeatTimeout   *string `json:"heartbeat_timeout,omitempty" hcl:"heartbeat_timeout" mapstructure:"heartbeat_timeout"`
347		LeaderLeaseTimeout *string `json:"leader_lease_timeout,omitempty" hcl:"leader_lease_timeout" mapstructure:"leader_lease_timeout"`
348	} `json:"raft,omitempty" hcl:"raft" mapstructure:"raft"`
349
350	Server struct {
351		HealthInterval *string `json:"health_interval,omitempty" hcl:"health_interval" mapstructure:"health_interval"`
352	} `json:"server,omitempty" hcl:"server" mapstructure:"server"`
353}
354
355type Addresses struct {
356	DNS   *string `json:"dns,omitempty" hcl:"dns" mapstructure:"dns"`
357	HTTP  *string `json:"http,omitempty" hcl:"http" mapstructure:"http"`
358	HTTPS *string `json:"https,omitempty" hcl:"https" mapstructure:"https"`
359	GRPC  *string `json:"grpc,omitempty" hcl:"grpc" mapstructure:"grpc"`
360}
361
362type AdvertiseAddrsConfig struct {
363	RPC     *string `json:"rpc,omitempty" hcl:"rpc" mapstructure:"rpc"`
364	SerfLAN *string `json:"serf_lan,omitempty" hcl:"serf_lan" mapstructure:"serf_lan"`
365	SerfWAN *string `json:"serf_wan,omitempty" hcl:"serf_wan" mapstructure:"serf_wan"`
366}
367
368type Autopilot struct {
369	CleanupDeadServers      *bool   `json:"cleanup_dead_servers,omitempty" hcl:"cleanup_dead_servers" mapstructure:"cleanup_dead_servers"`
370	DisableUpgradeMigration *bool   `json:"disable_upgrade_migration,omitempty" hcl:"disable_upgrade_migration" mapstructure:"disable_upgrade_migration"`
371	LastContactThreshold    *string `json:"last_contact_threshold,omitempty" hcl:"last_contact_threshold" mapstructure:"last_contact_threshold"`
372	MaxTrailingLogs         *int    `json:"max_trailing_logs,omitempty" hcl:"max_trailing_logs" mapstructure:"max_trailing_logs"`
373	MinQuorum               *uint   `json:"min_quorum,omitempty" hcl:"min_quorum" mapstructure:"min_quorum"`
374	RedundancyZoneTag       *string `json:"redundancy_zone_tag,omitempty" hcl:"redundancy_zone_tag" mapstructure:"redundancy_zone_tag"`
375	ServerStabilizationTime *string `json:"server_stabilization_time,omitempty" hcl:"server_stabilization_time" mapstructure:"server_stabilization_time"`
376	UpgradeVersionTag       *string `json:"upgrade_version_tag,omitempty" hcl:"upgrade_version_tag" mapstructure:"upgrade_version_tag"`
377}
378
379// ServiceWeights defines the registration of weights used in DNS for a Service
380type ServiceWeights struct {
381	Passing *int `json:"passing,omitempty" hcl:"passing" mapstructure:"passing"`
382	Warning *int `json:"warning,omitempty" hcl:"warning" mapstructure:"warning"`
383}
384
385type ServiceAddress struct {
386	Address *string `json:"address,omitempty" hcl:"address" mapstructure:"address"`
387	Port    *int    `json:"port,omitempty" hcl:"port" mapstructure:"port"`
388}
389
390type ServiceDefinition struct {
391	Kind              *string                   `json:"kind,omitempty" hcl:"kind" mapstructure:"kind"`
392	ID                *string                   `json:"id,omitempty" hcl:"id" mapstructure:"id"`
393	Name              *string                   `json:"name,omitempty" hcl:"name" mapstructure:"name"`
394	Tags              []string                  `json:"tags,omitempty" hcl:"tags" mapstructure:"tags"`
395	Address           *string                   `json:"address,omitempty" hcl:"address" mapstructure:"address"`
396	TaggedAddresses   map[string]ServiceAddress `json:"tagged_addresses,omitempty" hcl:"tagged_addresses" mapstructure:"tagged_addresses"`
397	Meta              map[string]string         `json:"meta,omitempty" hcl:"meta" mapstructure:"meta"`
398	Port              *int                      `json:"port,omitempty" hcl:"port" mapstructure:"port"`
399	Check             *CheckDefinition          `json:"check,omitempty" hcl:"check" mapstructure:"check"`
400	Checks            []CheckDefinition         `json:"checks,omitempty" hcl:"checks" mapstructure:"checks"`
401	Token             *string                   `json:"token,omitempty" hcl:"token" mapstructure:"token"`
402	Weights           *ServiceWeights           `json:"weights,omitempty" hcl:"weights" mapstructure:"weights"`
403	EnableTagOverride *bool                     `json:"enable_tag_override,omitempty" hcl:"enable_tag_override" mapstructure:"enable_tag_override"`
404	Proxy             *ServiceProxy             `json:"proxy,omitempty" hcl:"proxy" mapstructure:"proxy"`
405	Connect           *ServiceConnect           `json:"connect,omitempty" hcl:"connect" mapstructure:"connect"`
406
407	EnterpriseMeta `hcl:",squash" mapstructure:",squash"`
408}
409
410type CheckDefinition struct {
411	ID                             *string             `json:"id,omitempty" hcl:"id" mapstructure:"id"`
412	Name                           *string             `json:"name,omitempty" hcl:"name" mapstructure:"name"`
413	Notes                          *string             `json:"notes,omitempty" hcl:"notes" mapstructure:"notes"`
414	ServiceID                      *string             `json:"service_id,omitempty" hcl:"service_id" mapstructure:"service_id"`
415	Token                          *string             `json:"token,omitempty" hcl:"token" mapstructure:"token"`
416	Status                         *string             `json:"status,omitempty" hcl:"status" mapstructure:"status"`
417	ScriptArgs                     []string            `json:"args,omitempty" hcl:"args" mapstructure:"args"`
418	HTTP                           *string             `json:"http,omitempty" hcl:"http" mapstructure:"http"`
419	Header                         map[string][]string `json:"header,omitempty" hcl:"header" mapstructure:"header"`
420	Method                         *string             `json:"method,omitempty" hcl:"method" mapstructure:"method"`
421	Body                           *string             `json:"body,omitempty" hcl:"body" mapstructure:"body"`
422	OutputMaxSize                  *int                `json:"output_max_size,omitempty" hcl:"output_max_size" mapstructure:"output_max_size"`
423	TCP                            *string             `json:"tcp,omitempty" hcl:"tcp" mapstructure:"tcp"`
424	Interval                       *string             `json:"interval,omitempty" hcl:"interval" mapstructure:"interval"`
425	DockerContainerID              *string             `json:"docker_container_id,omitempty" hcl:"docker_container_id" mapstructure:"docker_container_id"`
426	Shell                          *string             `json:"shell,omitempty" hcl:"shell" mapstructure:"shell"`
427	GRPC                           *string             `json:"grpc,omitempty" hcl:"grpc" mapstructure:"grpc"`
428	GRPCUseTLS                     *bool               `json:"grpc_use_tls,omitempty" hcl:"grpc_use_tls" mapstructure:"grpc_use_tls"`
429	TLSSkipVerify                  *bool               `json:"tls_skip_verify,omitempty" hcl:"tls_skip_verify" mapstructure:"tls_skip_verify"`
430	AliasNode                      *string             `json:"alias_node,omitempty" hcl:"alias_node" mapstructure:"alias_node"`
431	AliasService                   *string             `json:"alias_service,omitempty" hcl:"alias_service" mapstructure:"alias_service"`
432	Timeout                        *string             `json:"timeout,omitempty" hcl:"timeout" mapstructure:"timeout"`
433	TTL                            *string             `json:"ttl,omitempty" hcl:"ttl" mapstructure:"ttl"`
434	SuccessBeforePassing           *int                `json:"success_before_passing,omitempty" hcl:"success_before_passing" mapstructure:"success_before_passing"`
435	FailuresBeforeCritical         *int                `json:"failures_before_critical,omitempty" hcl:"failures_before_critical" mapstructure:"failures_before_critical"`
436	DeregisterCriticalServiceAfter *string             `json:"deregister_critical_service_after,omitempty" hcl:"deregister_critical_service_after" mapstructure:"deregister_critical_service_after"`
437
438	EnterpriseMeta `hcl:",squash" mapstructure:",squash"`
439}
440
441// ServiceConnect is the connect block within a service registration
442type ServiceConnect struct {
443	// Native is true when this service can natively understand Connect.
444	Native *bool `json:"native,omitempty" hcl:"native" mapstructure:"native"`
445
446	// SidecarService is a nested Service Definition to register at the same time.
447	// It's purely a convenience mechanism to allow specifying a sidecar service
448	// along with the application service definition. It's nested nature allows
449	// all of the fields to be defaulted which can reduce the amount of
450	// boilerplate needed to register a sidecar service separately, but the end
451	// result is identical to just making a second service registration via any
452	// other means.
453	SidecarService *ServiceDefinition `json:"sidecar_service,omitempty" hcl:"sidecar_service" mapstructure:"sidecar_service"`
454}
455
456// ServiceProxy is the additional config needed for a Kind = connect-proxy
457// registration.
458type ServiceProxy struct {
459	// DestinationServiceName is required and is the name of the service to accept
460	// traffic for.
461	DestinationServiceName *string `json:"destination_service_name,omitempty" hcl:"destination_service_name" mapstructure:"destination_service_name"`
462
463	// DestinationServiceID is optional and should only be specified for
464	// "side-car" style proxies where the proxy is in front of just a single
465	// instance of the service. It should be set to the service ID of the instance
466	// being represented which must be registered to the same agent. It's valid to
467	// provide a service ID that does not yet exist to avoid timing issues when
468	// bootstrapping a service with a proxy.
469	DestinationServiceID *string `json:"destination_service_id,omitempty" hcl:"destination_service_id" mapstructure:"destination_service_id"`
470
471	// LocalServiceAddress is the address of the local service instance. It is
472	// optional and should only be specified for "side-car" style proxies. It will
473	// default to 127.0.0.1 if the proxy is a "side-car" (DestinationServiceID is
474	// set) but otherwise will be ignored.
475	LocalServiceAddress *string `json:"local_service_address,omitempty" hcl:"local_service_address" mapstructure:"local_service_address"`
476
477	// LocalServicePort is the port of the local service instance. It is optional
478	// and should only be specified for "side-car" style proxies. It will default
479	// to the registered port for the instance if the proxy is a "side-car"
480	// (DestinationServiceID is set) but otherwise will be ignored.
481	LocalServicePort *int `json:"local_service_port,omitempty" hcl:"local_service_port" mapstructure:"local_service_port"`
482
483	// Config is the arbitrary configuration data provided with the proxy
484	// registration.
485	Config map[string]interface{} `json:"config,omitempty" hcl:"config" mapstructure:"config"`
486
487	// Upstreams describes any upstream dependencies the proxy instance should
488	// setup.
489	Upstreams []Upstream `json:"upstreams,omitempty" hcl:"upstreams" mapstructure:"upstreams"`
490
491	// Mesh Gateway Configuration
492	MeshGateway *MeshGatewayConfig `json:"mesh_gateway,omitempty" hcl:"mesh_gateway" mapstructure:"mesh_gateway"`
493
494	// Expose defines whether checks or paths are exposed through the proxy
495	Expose *ExposeConfig `json:"expose,omitempty" hcl:"expose" mapstructure:"expose"`
496}
497
498// Upstream represents a single upstream dependency for a service or proxy. It
499// describes the mechanism used to discover instances to communicate with (the
500// Target) as well as any potential client configuration that may be useful such
501// as load balancer options, timeouts etc.
502type Upstream struct {
503	// Destination fields are the required ones for determining what this upstream
504	// points to. Depending on DestinationType some other fields below might
505	// further restrict the set of instances allowable.
506	//
507	// DestinationType would be better as an int constant but even with custom
508	// JSON marshallers it causes havoc with all the mapstructure mangling we do
509	// on service definitions in various places.
510	DestinationType      *string `json:"destination_type,omitempty" hcl:"destination_type" mapstructure:"destination_type"`
511	DestinationNamespace *string `json:"destination_namespace,omitempty" hcl:"destination_namespace" mapstructure:"destination_namespace"`
512	DestinationName      *string `json:"destination_name,omitempty" hcl:"destination_name" mapstructure:"destination_name"`
513
514	// Datacenter that the service discovery request should be run against. Note
515	// for prepared queries, the actual results might be from a different
516	// datacenter.
517	Datacenter *string `json:"datacenter,omitempty" hcl:"datacenter" mapstructure:"datacenter"`
518
519	// LocalBindAddress is the ip address a side-car proxy should listen on for
520	// traffic destined for this upstream service. Default if empty is 127.0.0.1.
521	LocalBindAddress *string `json:"local_bind_address,omitempty" hcl:"local_bind_address" mapstructure:"local_bind_address"`
522
523	// LocalBindPort is the ip address a side-car proxy should listen on for traffic
524	// destined for this upstream service. Required.
525	LocalBindPort *int `json:"local_bind_port,omitempty" hcl:"local_bind_port" mapstructure:"local_bind_port"`
526
527	// Config is an opaque config that is specific to the proxy process being run.
528	// It can be used to pass arbitrary configuration for this specific upstream
529	// to the proxy.
530	Config map[string]interface{} `json:"config,omitempty" hcl:"config" mapstructure:"config"`
531
532	// Mesh Gateway Configuration
533	MeshGateway *MeshGatewayConfig `json:"mesh_gateway,omitempty" hcl:"mesh_gateway" mapstructure:"mesh_gateway"`
534}
535
536type MeshGatewayConfig struct {
537	// Mesh Gateway Mode
538	Mode *string `json:"mode,omitempty" hcl:"mode" mapstructure:"mode"`
539}
540
541// ExposeConfig describes HTTP paths to expose through Envoy outside of Connect.
542// Users can expose individual paths and/or all HTTP/GRPC paths for checks.
543type ExposeConfig struct {
544	// Checks defines whether paths associated with Consul checks will be exposed.
545	// This flag triggers exposing all HTTP and GRPC check paths registered for the service.
546	Checks *bool `json:"checks,omitempty" hcl:"checks" mapstructure:"checks"`
547
548	// Port defines the port of the proxy's listener for exposed paths.
549	Port *int `json:"port,omitempty" hcl:"port" mapstructure:"port"`
550
551	// Paths is the list of paths exposed through the proxy.
552	Paths []ExposePath `json:"paths,omitempty" hcl:"paths" mapstructure:"paths"`
553}
554
555type ExposePath struct {
556	// ListenerPort defines the port of the proxy's listener for exposed paths.
557	ListenerPort *int `json:"listener_port,omitempty" hcl:"listener_port" mapstructure:"listener_port"`
558
559	// Path is the path to expose through the proxy, ie. "/metrics."
560	Path *string `json:"path,omitempty" hcl:"path" mapstructure:"path"`
561
562	// Protocol describes the upstream's service protocol.
563	Protocol *string `json:"protocol,omitempty" hcl:"protocol" mapstructure:"protocol"`
564
565	// LocalPathPort is the port that the service is listening on for the given path.
566	LocalPathPort *int `json:"local_path_port,omitempty" hcl:"local_path_port" mapstructure:"local_path_port"`
567}
568
569// AutoEncrypt is the agent-global auto_encrypt configuration.
570type AutoEncrypt struct {
571	// TLS enables receiving certificates for clients from servers
572	TLS *bool `json:"tls,omitempty" hcl:"tls" mapstructure:"tls"`
573
574	// Additional DNS SAN entries that clients request for their certificates.
575	DNSSAN []string `json:"dns_san,omitempty" hcl:"dns_san" mapstructure:"dns_san"`
576
577	// Additional IP SAN entries that clients request for their certificates.
578	IPSAN []string `json:"ip_san,omitempty" hcl:"ip_san" mapstructure:"ip_san"`
579
580	// AllowTLS enables the RPC endpoint on the server to answer
581	// AutoEncrypt.Sign requests.
582	AllowTLS *bool `json:"allow_tls,omitempty" hcl:"allow_tls" mapstructure:"allow_tls"`
583}
584
585// Connect is the agent-global connect configuration.
586type Connect struct {
587	// Enabled opts the agent into connect. It should be set on all clients and
588	// servers in a cluster for correct connect operation.
589	Enabled    *bool                  `json:"enabled,omitempty" hcl:"enabled" mapstructure:"enabled"`
590	CAProvider *string                `json:"ca_provider,omitempty" hcl:"ca_provider" mapstructure:"ca_provider"`
591	CAConfig   map[string]interface{} `json:"ca_config,omitempty" hcl:"ca_config" mapstructure:"ca_config"`
592}
593
594// SOA is the configuration of SOA for DNS
595type SOA struct {
596	Refresh *uint32 `json:"refresh,omitempty" hcl:"refresh" mapstructure:"refresh"`
597	Retry   *uint32 `json:"retry,omitempty" hcl:"retry" mapstructure:"retry"`
598	Expire  *uint32 `json:"expire,omitempty" hcl:"expire" mapstructure:"expire"`
599	Minttl  *uint32 `json:"min_ttl,omitempty" hcl:"min_ttl" mapstructure:"min_ttl"`
600}
601
602type DNS struct {
603	AllowStale          *bool             `json:"allow_stale,omitempty" hcl:"allow_stale" mapstructure:"allow_stale"`
604	ARecordLimit        *int              `json:"a_record_limit,omitempty" hcl:"a_record_limit" mapstructure:"a_record_limit"`
605	DisableCompression  *bool             `json:"disable_compression,omitempty" hcl:"disable_compression" mapstructure:"disable_compression"`
606	EnableTruncate      *bool             `json:"enable_truncate,omitempty" hcl:"enable_truncate" mapstructure:"enable_truncate"`
607	MaxStale            *string           `json:"max_stale,omitempty" hcl:"max_stale" mapstructure:"max_stale"`
608	NodeTTL             *string           `json:"node_ttl,omitempty" hcl:"node_ttl" mapstructure:"node_ttl"`
609	OnlyPassing         *bool             `json:"only_passing,omitempty" hcl:"only_passing" mapstructure:"only_passing"`
610	RecursorTimeout     *string           `json:"recursor_timeout,omitempty" hcl:"recursor_timeout" mapstructure:"recursor_timeout"`
611	ServiceTTL          map[string]string `json:"service_ttl,omitempty" hcl:"service_ttl" mapstructure:"service_ttl"`
612	UDPAnswerLimit      *int              `json:"udp_answer_limit,omitempty" hcl:"udp_answer_limit" mapstructure:"udp_answer_limit"`
613	NodeMetaTXT         *bool             `json:"enable_additional_node_meta_txt,omitempty" hcl:"enable_additional_node_meta_txt" mapstructure:"enable_additional_node_meta_txt"`
614	SOA                 *SOA              `json:"soa,omitempty" hcl:"soa" mapstructure:"soa"`
615	UseCache            *bool             `json:"use_cache,omitempty" hcl:"use_cache" mapstructure:"use_cache"`
616	CacheMaxAge         *string           `json:"cache_max_age,omitempty" hcl:"cache_max_age" mapstructure:"cache_max_age"`
617	EnterpriseDNSConfig `hcl:",squash" mapstructure:",squash"`
618}
619
620type HTTPConfig struct {
621	BlockEndpoints     []string          `json:"block_endpoints,omitempty" hcl:"block_endpoints" mapstructure:"block_endpoints"`
622	AllowWriteHTTPFrom []string          `json:"allow_write_http_from,omitempty" hcl:"allow_write_http_from" mapstructure:"allow_write_http_from"`
623	ResponseHeaders    map[string]string `json:"response_headers,omitempty" hcl:"response_headers" mapstructure:"response_headers"`
624}
625
626type Performance struct {
627	LeaveDrainTime *string `json:"leave_drain_time,omitempty" hcl:"leave_drain_time" mapstructure:"leave_drain_time"`
628	RaftMultiplier *int    `json:"raft_multiplier,omitempty" hcl:"raft_multiplier" mapstructure:"raft_multiplier"` // todo(fs): validate as uint
629	RPCHoldTimeout *string `json:"rpc_hold_timeout" hcl:"rpc_hold_timeout" mapstructure:"rpc_hold_timeout"`
630}
631
632type Telemetry struct {
633	CirconusAPIApp                     *string  `json:"circonus_api_app,omitempty" hcl:"circonus_api_app" mapstructure:"circonus_api_app"`
634	CirconusAPIToken                   *string  `json:"circonus_api_token,omitempty" hcl:"circonus_api_token" mapstructure:"circonus_api_token"`
635	CirconusAPIURL                     *string  `json:"circonus_api_url,omitempty" hcl:"circonus_api_url" mapstructure:"circonus_api_url"`
636	CirconusBrokerID                   *string  `json:"circonus_broker_id,omitempty" hcl:"circonus_broker_id" mapstructure:"circonus_broker_id"`
637	CirconusBrokerSelectTag            *string  `json:"circonus_broker_select_tag,omitempty" hcl:"circonus_broker_select_tag" mapstructure:"circonus_broker_select_tag"`
638	CirconusCheckDisplayName           *string  `json:"circonus_check_display_name,omitempty" hcl:"circonus_check_display_name" mapstructure:"circonus_check_display_name"`
639	CirconusCheckForceMetricActivation *string  `json:"circonus_check_force_metric_activation,omitempty" hcl:"circonus_check_force_metric_activation" mapstructure:"circonus_check_force_metric_activation"`
640	CirconusCheckID                    *string  `json:"circonus_check_id,omitempty" hcl:"circonus_check_id" mapstructure:"circonus_check_id"`
641	CirconusCheckInstanceID            *string  `json:"circonus_check_instance_id,omitempty" hcl:"circonus_check_instance_id" mapstructure:"circonus_check_instance_id"`
642	CirconusCheckSearchTag             *string  `json:"circonus_check_search_tag,omitempty" hcl:"circonus_check_search_tag" mapstructure:"circonus_check_search_tag"`
643	CirconusCheckTags                  *string  `json:"circonus_check_tags,omitempty" hcl:"circonus_check_tags" mapstructure:"circonus_check_tags"`
644	CirconusSubmissionInterval         *string  `json:"circonus_submission_interval,omitempty" hcl:"circonus_submission_interval" mapstructure:"circonus_submission_interval"`
645	CirconusSubmissionURL              *string  `json:"circonus_submission_url,omitempty" hcl:"circonus_submission_url" mapstructure:"circonus_submission_url"`
646	DisableHostname                    *bool    `json:"disable_hostname,omitempty" hcl:"disable_hostname" mapstructure:"disable_hostname"`
647	DogstatsdAddr                      *string  `json:"dogstatsd_addr,omitempty" hcl:"dogstatsd_addr" mapstructure:"dogstatsd_addr"`
648	DogstatsdTags                      []string `json:"dogstatsd_tags,omitempty" hcl:"dogstatsd_tags" mapstructure:"dogstatsd_tags"`
649	FilterDefault                      *bool    `json:"filter_default,omitempty" hcl:"filter_default" mapstructure:"filter_default"`
650	PrefixFilter                       []string `json:"prefix_filter,omitempty" hcl:"prefix_filter" mapstructure:"prefix_filter"`
651	MetricsPrefix                      *string  `json:"metrics_prefix,omitempty" hcl:"metrics_prefix" mapstructure:"metrics_prefix"`
652	PrometheusRetentionTime            *string  `json:"prometheus_retention_time,omitempty" hcl:"prometheus_retention_time" mapstructure:"prometheus_retention_time"`
653	StatsdAddr                         *string  `json:"statsd_address,omitempty" hcl:"statsd_address" mapstructure:"statsd_address"`
654	StatsiteAddr                       *string  `json:"statsite_address,omitempty" hcl:"statsite_address" mapstructure:"statsite_address"`
655}
656
657type Ports struct {
658	DNS            *int `json:"dns,omitempty" hcl:"dns" mapstructure:"dns"`
659	HTTP           *int `json:"http,omitempty" hcl:"http" mapstructure:"http"`
660	HTTPS          *int `json:"https,omitempty" hcl:"https" mapstructure:"https"`
661	SerfLAN        *int `json:"serf_lan,omitempty" hcl:"serf_lan" mapstructure:"serf_lan"`
662	SerfWAN        *int `json:"serf_wan,omitempty" hcl:"serf_wan" mapstructure:"serf_wan"`
663	Server         *int `json:"server,omitempty" hcl:"server" mapstructure:"server"`
664	GRPC           *int `json:"grpc,omitempty" hcl:"grpc" mapstructure:"grpc"`
665	ProxyMinPort   *int `json:"proxy_min_port,omitempty" hcl:"proxy_min_port" mapstructure:"proxy_min_port"`
666	ProxyMaxPort   *int `json:"proxy_max_port,omitempty" hcl:"proxy_max_port" mapstructure:"proxy_max_port"`
667	SidecarMinPort *int `json:"sidecar_min_port,omitempty" hcl:"sidecar_min_port" mapstructure:"sidecar_min_port"`
668	SidecarMaxPort *int `json:"sidecar_max_port,omitempty" hcl:"sidecar_max_port" mapstructure:"sidecar_max_port"`
669	ExposeMinPort  *int `json:"expose_min_port,omitempty" hcl:"expose_min_port" mapstructure:"expose_min_port"`
670	ExposeMaxPort  *int `json:"expose_max_port,omitempty" hcl:"expose_max_port" mapstructure:"expose_max_port"`
671}
672
673type UnixSocket struct {
674	Group *string `json:"group,omitempty" hcl:"group" mapstructure:"group"`
675	Mode  *string `json:"mode,omitempty" hcl:"mode" mapstructure:"mode"`
676	User  *string `json:"user,omitempty" hcl:"user" mapstructure:"user"`
677}
678
679type Limits struct {
680	HTTPMaxConnsPerClient *int     `json:"http_max_conns_per_client,omitempty" hcl:"http_max_conns_per_client" mapstructure:"http_max_conns_per_client"`
681	HTTPSHandshakeTimeout *string  `json:"https_handshake_timeout,omitempty" hcl:"https_handshake_timeout" mapstructure:"https_handshake_timeout"`
682	RPCHandshakeTimeout   *string  `json:"rpc_handshake_timeout,omitempty" hcl:"rpc_handshake_timeout" mapstructure:"rpc_handshake_timeout"`
683	RPCMaxBurst           *int     `json:"rpc_max_burst,omitempty" hcl:"rpc_max_burst" mapstructure:"rpc_max_burst"`
684	RPCMaxConnsPerClient  *int     `json:"rpc_max_conns_per_client,omitempty" hcl:"rpc_max_conns_per_client" mapstructure:"rpc_max_conns_per_client"`
685	RPCRate               *float64 `json:"rpc_rate,omitempty" hcl:"rpc_rate" mapstructure:"rpc_rate"`
686	KVMaxValueSize        *uint64  `json:"kv_max_value_size,omitempty" hcl:"kv_max_value_size" mapstructure:"kv_max_value_size"`
687}
688
689type Segment struct {
690	Advertise   *string `json:"advertise,omitempty" hcl:"advertise" mapstructure:"advertise"`
691	Bind        *string `json:"bind,omitempty" hcl:"bind" mapstructure:"bind"`
692	Name        *string `json:"name,omitempty" hcl:"name" mapstructure:"name"`
693	Port        *int    `json:"port,omitempty" hcl:"port" mapstructure:"port"`
694	RPCListener *bool   `json:"rpc_listener,omitempty" hcl:"rpc_listener" mapstructure:"rpc_listener"`
695}
696
697type ACL struct {
698	Enabled                *bool   `json:"enabled,omitempty" hcl:"enabled" mapstructure:"enabled"`
699	TokenReplication       *bool   `json:"enable_token_replication,omitempty" hcl:"enable_token_replication" mapstructure:"enable_token_replication"`
700	PolicyTTL              *string `json:"policy_ttl,omitempty" hcl:"policy_ttl" mapstructure:"policy_ttl"`
701	RoleTTL                *string `json:"role_ttl,omitempty" hcl:"role_ttl" mapstructure:"role_ttl"`
702	TokenTTL               *string `json:"token_ttl,omitempty" hcl:"token_ttl" mapstructure:"token_ttl"`
703	DownPolicy             *string `json:"down_policy,omitempty" hcl:"down_policy" mapstructure:"down_policy"`
704	DefaultPolicy          *string `json:"default_policy,omitempty" hcl:"default_policy" mapstructure:"default_policy"`
705	EnableKeyListPolicy    *bool   `json:"enable_key_list_policy,omitempty" hcl:"enable_key_list_policy" mapstructure:"enable_key_list_policy"`
706	Tokens                 Tokens  `json:"tokens,omitempty" hcl:"tokens" mapstructure:"tokens"`
707	DisabledTTL            *string `json:"disabled_ttl,omitempty" hcl:"disabled_ttl" mapstructure:"disabled_ttl"`
708	EnableTokenPersistence *bool   `json:"enable_token_persistence" hcl:"enable_token_persistence" mapstructure:"enable_token_persistence"`
709}
710
711type Tokens struct {
712	Master                 *string                `json:"master,omitempty" hcl:"master" mapstructure:"master"`
713	Replication            *string                `json:"replication,omitempty" hcl:"replication" mapstructure:"replication"`
714	AgentMaster            *string                `json:"agent_master,omitempty" hcl:"agent_master" mapstructure:"agent_master"`
715	Default                *string                `json:"default,omitempty" hcl:"default" mapstructure:"default"`
716	Agent                  *string                `json:"agent,omitempty" hcl:"agent" mapstructure:"agent"`
717	ManagedServiceProvider []ServiceProviderToken `json:"managed_service_provider,omitempty" hcl:"managed_service_provider" mapstructure:"managed_service_provider"`
718}
719
720type ServiceProviderToken struct {
721	AccessorID *string `json:"accessor_id,omitempty" hcl:"accessor_id" mapstructure:"accessor_id"`
722	SecretID   *string `json:"secret_id,omitempty" hcl:"secret_id" mapstructure:"secret_id"`
723}
724
725type ConfigEntries struct {
726	// Bootstrap is the list of config_entries that should only be persisted to
727	// cluster on initial startup of a new leader if no such config exists
728	// already. The type is map not structs.ConfigEntry for decoding reasons - we
729	// need to figure out the right concrete type before we can decode it
730	// unabiguously.
731	Bootstrap []map[string]interface{} `json:"bootstrap,omitempty" hcl:"bootstrap" mapstructure:"bootstrap"`
732}
733