github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/consul/data_source_consul_agent_self.go (about)

     1  package consul
     2  
     3  import (
     4  	"fmt"
     5  	"strconv"
     6  	"time"
     7  
     8  	consulapi "github.com/hashicorp/consul/api"
     9  	"github.com/hashicorp/errwrap"
    10  	"github.com/hashicorp/terraform/helper/schema"
    11  )
    12  
    13  const (
    14  	agentSelfACLDatacenter              = "acl_datacenter"
    15  	agentSelfACLDefaultPolicy           = "acl_default_policy"
    16  	agentSelfACLDisabledTTL             = "acl_disabled_ttl"
    17  	agentSelfACLDownPolicy              = "acl_down_policy"
    18  	agentSelfACLEnforceVersion8         = "acl_enforce_0_8_semantics"
    19  	agentSelfACLTTL                     = "acl_ttl"
    20  	agentSelfAddresses                  = "addresses"
    21  	agentSelfAdvertiseAddr              = "advertise_addr"
    22  	agentSelfAdvertiseAddrWAN           = "advertise_addr_wan"
    23  	agentSelfAdvertiseAddrs             = "advertise_addrs"
    24  	agentSelfAtlasJoin                  = "atlas_join"
    25  	agentSelfBindAddr                   = "bind_addr"
    26  	agentSelfBootstrapExpect            = "bootstrap_expect"
    27  	agentSelfBootstrapMode              = "bootstrap_mode"
    28  	agentSelfCheckDeregisterIntervalMin = "check_deregister_interval_min"
    29  	agentSelfCheckReapInterval          = "check_reap_interval"
    30  	agentSelfCheckUpdateInterval        = "check_update_interval"
    31  	agentSelfClientAddr                 = "client_addr"
    32  	agentSelfDNSConfig                  = "dns"
    33  	agentSelfDNSRecursors               = "dns_recursors"
    34  	agentSelfDataDir                    = "data_dir"
    35  	agentSelfDatacenter                 = "datacenter"
    36  	agentSelfDevMode                    = "dev_mode"
    37  	agentSelfDomain                     = "domain"
    38  	agentSelfEnableAnonymousSignature   = "enable_anonymous_signature"
    39  	agentSelfEnableCoordinates          = "enable_coordinates"
    40  	agentSelfEnableDebug                = "enable_debug"
    41  	agentSelfEnableRemoteExec           = "enable_remote_exec"
    42  	agentSelfEnableSyslog               = "enable_syslog"
    43  	agentSelfEnableUI                   = "enable_ui"
    44  	agentSelfEnableUpdateCheck          = "enable_update_check"
    45  	agentSelfID                         = "id"
    46  	agentSelfLeaveOnInt                 = "leave_on_int"
    47  	agentSelfLeaveOnTerm                = "leave_on_term"
    48  	agentSelfLogLevel                   = "log_level"
    49  	agentSelfName                       = "name"
    50  	agentSelfPerformance                = "performance"
    51  	agentSelfPidFile                    = "pid_file"
    52  	agentSelfPorts                      = "ports"
    53  	agentSelfProtocol                   = "protocol_version"
    54  	agentSelfReconnectTimeoutLAN        = "reconnect_timeout_lan"
    55  	agentSelfReconnectTimeoutWAN        = "reconnect_timeout_wan"
    56  	agentSelfRejoinAfterLeave           = "rejoin_after_leave"
    57  	agentSelfRetryJoin                  = "retry_join"
    58  	agentSelfRetryJoinEC2               = "retry_join_ec2"
    59  	agentSelfRetryJoinGCE               = "retry_join_gce"
    60  	agentSelfRetryJoinWAN               = "retry_join_wan"
    61  	agentSelfRetryMaxAttempts           = "retry_max_attempts"
    62  	agentSelfRetryMaxAttemptsWAN        = "retry_max_attempts_wan"
    63  	agentSelfSerfLANBindAddr            = "serf_lan_bind_addr"
    64  	agentSelfSerfWANBindAddr            = "serf_wan_bind_addr"
    65  	agentSelfServerMode                 = "server_mode"
    66  	agentSelfServerName                 = "server_name"
    67  	agentSelfSessionTTLMin              = "session_ttl_min"
    68  	agentSelfStartJoin                  = "start_join"
    69  	agentSelfStartJoinWAN               = "start_join_wan"
    70  	agentSelfSyslogFacility             = "syslog_facility"
    71  	agentSelfTLSCAFile                  = "tls_ca_file"
    72  	agentSelfTLSCertFile                = "tls_cert_file"
    73  	agentSelfTLSKeyFile                 = "tls_key_file"
    74  	agentSelfTLSMinVersion              = "tls_min_version"
    75  	agentSelfTLSVerifyIncoming          = "tls_verify_incoming"
    76  	agentSelfTLSVerifyOutgoing          = "tls_verify_outgoing"
    77  	agentSelfTLSVerifyServerHostname    = "tls_verify_server_hostname"
    78  	agentSelfTaggedAddresses            = "tagged_addresses"
    79  	agentSelfTelemetry                  = "telemetry"
    80  	agentSelfTranslateWANAddrs          = "translate_wan_addrs"
    81  	agentSelfUIDir                      = "ui_dir"
    82  	agentSelfUnixSockets                = "unix_sockets"
    83  	agentSelfVersion                    = "version"
    84  	agentSelfVersionPrerelease          = "version_prerelease"
    85  	agentSelfVersionRevision            = "version_revision"
    86  )
    87  
    88  const (
    89  	agentSelfRetryJoinAWSRegion   = "region"
    90  	agentSelfRetryJoinAWSTagKey   = "tag_key"
    91  	agentSelfRetryJoinAWSTagValue = "tag_value"
    92  )
    93  
    94  const (
    95  	agentSelfRetryJoinGCECredentialsFile = "credentials_file"
    96  	agentSelfRetryJoinGCEProjectName     = "project_name"
    97  	agentSelfRetryJoinGCETagValue        = "tag_value"
    98  	agentSelfRetryJoinGCEZonePattern     = "zone_pattern"
    99  )
   100  
   101  const (
   102  	agentSelfDNSAllowStale        = "allow_stale"
   103  	agentSelfDNSEnableCompression = "enable_compression"
   104  	agentSelfDNSEnableTruncate    = "enable_truncate"
   105  	agentSelfDNSMaxStale          = "max_stale"
   106  	agentSelfDNSNodeTTL           = "node_ttl"
   107  	agentSelfDNSOnlyPassing       = "only_passing"
   108  	agentSelfDNSRecursorTimeout   = "recursor_timeout"
   109  	agentSelfDNSServiceTTL        = "service_ttl"
   110  	agentSelfDNSUDPAnswerLimit    = "udp_answer_limit"
   111  )
   112  
   113  const (
   114  	agentSelfPerformanceRaftMultiplier = "raft_multiplier"
   115  )
   116  
   117  const (
   118  	agentSelfAPIPortsDNS     = "dns"
   119  	agentSelfAPIPortsHTTP    = "http"
   120  	agentSelfAPIPortsHTTPS   = "https"
   121  	agentSelfAPIPortsRPC     = "rpc"
   122  	agentSelfAPIPortsSerfLAN = "serf_lan"
   123  	agentSelfAPIPortsSerfWAN = "serf_wan"
   124  	agentSelfAPIPortsServer  = "server"
   125  
   126  	agentSelfSchemaPortsDNS     = "dns"
   127  	agentSelfSchemaPortsHTTP    = "http"
   128  	agentSelfSchemaPortsHTTPS   = "https"
   129  	agentSelfSchemaPortsRPC     = "rpc"
   130  	agentSelfSchemaPortsSerfLAN = "serf_lan"
   131  	agentSelfSchemaPortsSerfWAN = "serf_wan"
   132  	agentSelfSchemaPortsServer  = "server"
   133  )
   134  
   135  const (
   136  	agentSelfTaggedAddressesLAN = "lan"
   137  	agentSelfTaggedAddressesWAN = "wan"
   138  )
   139  
   140  const (
   141  	agentSelfTelemetryCirconusAPIApp                    = "circonus_api_app"
   142  	agentSelfTelemetryCirconusAPIToken                  = "circonus_api_token"
   143  	agentSelfTelemetryCirconusAPIURL                    = "circonus_api_url"
   144  	agentSelfTelemetryCirconusBrokerID                  = "circonus_broker_id"
   145  	agentSelfTelemetryCirconusBrokerSelectTag           = "circonus_select_tag"
   146  	agentSelfTelemetryCirconusCheckDisplayName          = "circonus_display_name"
   147  	agentSelfTelemetryCirconusCheckForceMetricActiation = "circonus_force_metric_activation"
   148  	agentSelfTelemetryCirconusCheckID                   = "circonus_check_id"
   149  	agentSelfTelemetryCirconusCheckInstanceID           = "circonus_instance_id"
   150  	agentSelfTelemetryCirconusCheckSearchTag            = "circonus_search_tag"
   151  	agentSelfTelemetryCirconusCheckSubmissionURL        = "circonus_submission_url"
   152  	agentSelfTelemetryCirconusCheckTags                 = "circonus_check_tags"
   153  	agentSelfTelemetryCirconusSubmissionInterval        = "circonus_submission_interval"
   154  
   155  	agentSelfTelemetryDogStatsdAddr  = "dogstatsd_addr"
   156  	agentSelfTelemetryDogStatsdTags  = "dogstatsd_tags"
   157  	agentSelfTelemetryEnableHostname = "enable_hostname"
   158  	agentSelfTelemetryStatsdAddr     = "statsd_addr"
   159  	agentSelfTelemetryStatsiteAddr   = "statsite_addr"
   160  	agentSelfTelemetryStatsitePrefix = "statsite_prefix"
   161  )
   162  
   163  const (
   164  	agentSelfUnixSocketGroup = "group"
   165  	agentSelfUnixSocketMode  = "mode"
   166  	agentSelfUnixSocketUser  = "user"
   167  )
   168  
   169  func dataSourceConsulAgentSelf() *schema.Resource {
   170  	return &schema.Resource{
   171  		Read: dataSourceConsulAgentSelfRead,
   172  		Schema: map[string]*schema.Schema{
   173  			agentSelfACLDatacenter: {
   174  				Computed: true,
   175  				Type:     schema.TypeString,
   176  			},
   177  			agentSelfACLDefaultPolicy: {
   178  				Computed: true,
   179  				Type:     schema.TypeString,
   180  			},
   181  			agentSelfACLDisabledTTL: {
   182  				Computed: true,
   183  				Type:     schema.TypeString,
   184  			},
   185  			agentSelfACLDownPolicy: {
   186  				Computed: true,
   187  				Type:     schema.TypeString,
   188  			},
   189  			agentSelfACLEnforceVersion8: {
   190  				Computed: true,
   191  				Type:     schema.TypeBool,
   192  			},
   193  			agentSelfACLTTL: {
   194  				Computed: true,
   195  				Type:     schema.TypeString,
   196  			},
   197  			agentSelfAddresses: {
   198  				Computed: true,
   199  				Type:     schema.TypeMap,
   200  				Elem: &schema.Resource{
   201  					Schema: map[string]*schema.Schema{
   202  						agentSelfSchemaPortsDNS: &schema.Schema{
   203  							Type:     schema.TypeString,
   204  							Computed: true,
   205  						},
   206  						agentSelfSchemaPortsHTTP: &schema.Schema{
   207  							Type:     schema.TypeString,
   208  							Computed: true,
   209  						},
   210  						agentSelfSchemaPortsHTTPS: &schema.Schema{
   211  							Type:     schema.TypeString,
   212  							Computed: true,
   213  						},
   214  						agentSelfSchemaPortsRPC: &schema.Schema{
   215  							Type:     schema.TypeString,
   216  							Computed: true,
   217  						},
   218  					},
   219  				},
   220  			},
   221  			agentSelfAdvertiseAddr: {
   222  				Computed: true,
   223  				Type:     schema.TypeString,
   224  			},
   225  			agentSelfAdvertiseAddrs: {
   226  				Computed: true,
   227  				Type:     schema.TypeMap,
   228  				Elem: &schema.Resource{
   229  					Schema: map[string]*schema.Schema{
   230  						agentSelfSchemaPortsSerfLAN: &schema.Schema{
   231  							Type:     schema.TypeString,
   232  							Computed: true,
   233  						},
   234  						agentSelfSchemaPortsSerfWAN: &schema.Schema{
   235  							Type:     schema.TypeString,
   236  							Computed: true,
   237  						},
   238  						agentSelfSchemaPortsRPC: &schema.Schema{
   239  							Type:     schema.TypeString,
   240  							Computed: true,
   241  						},
   242  					},
   243  				},
   244  			},
   245  			agentSelfAdvertiseAddrWAN: {
   246  				Computed: true,
   247  				Type:     schema.TypeString,
   248  			},
   249  			// Omitting the following since they've been depreciated:
   250  			//
   251  			// "AtlasInfrastructure":        "",
   252  			// "AtlasEndpoint":       "",
   253  			agentSelfAtlasJoin: {
   254  				Computed: true,
   255  				Type:     schema.TypeBool,
   256  			},
   257  			agentSelfBindAddr: {
   258  				Computed: true,
   259  				Type:     schema.TypeString,
   260  			},
   261  			agentSelfBootstrapMode: {
   262  				Computed: true,
   263  				Type:     schema.TypeBool,
   264  			},
   265  			agentSelfBootstrapExpect: {
   266  				Computed: true,
   267  				Type:     schema.TypeInt,
   268  			},
   269  			agentSelfCheckDeregisterIntervalMin: {
   270  				Computed: true,
   271  				Type:     schema.TypeString,
   272  			},
   273  			agentSelfCheckReapInterval: {
   274  				Computed: true,
   275  				Type:     schema.TypeString,
   276  			},
   277  			agentSelfCheckUpdateInterval: {
   278  				Computed: true,
   279  				Type:     schema.TypeString,
   280  			},
   281  			agentSelfClientAddr: {
   282  				Computed: true,
   283  				Type:     schema.TypeString,
   284  			},
   285  			agentSelfDNSConfig: {
   286  				Computed: true,
   287  				Type:     schema.TypeMap,
   288  				Elem: &schema.Resource{
   289  					Schema: map[string]*schema.Schema{
   290  						agentSelfDNSAllowStale: {
   291  							Computed: true,
   292  							Type:     schema.TypeBool,
   293  						},
   294  						agentSelfDNSEnableCompression: {
   295  							Computed: true,
   296  							Type:     schema.TypeBool,
   297  						},
   298  						agentSelfDNSEnableTruncate: {
   299  							Computed: true,
   300  							Type:     schema.TypeBool,
   301  						},
   302  						agentSelfDNSMaxStale: {
   303  							Computed: true,
   304  							Type:     schema.TypeString,
   305  						},
   306  						agentSelfDNSNodeTTL: {
   307  							Computed: true,
   308  							Type:     schema.TypeString,
   309  						},
   310  						agentSelfDNSOnlyPassing: {
   311  							Computed: true,
   312  							Type:     schema.TypeBool,
   313  						},
   314  						agentSelfDNSRecursorTimeout: {
   315  							Computed: true,
   316  							Type:     schema.TypeString,
   317  						},
   318  						agentSelfDNSServiceTTL: {
   319  							Computed: true,
   320  							Type:     schema.TypeString,
   321  						},
   322  						agentSelfDNSUDPAnswerLimit: {
   323  							Computed: true,
   324  							Type:     schema.TypeInt,
   325  						},
   326  					},
   327  				},
   328  			},
   329  			agentSelfDataDir: {
   330  				Computed: true,
   331  				Type:     schema.TypeString,
   332  			},
   333  			agentSelfDatacenter: {
   334  				Computed: true,
   335  				Type:     schema.TypeString,
   336  			},
   337  			agentSelfDevMode: {
   338  				Computed: true,
   339  				Type:     schema.TypeBool,
   340  			},
   341  			agentSelfEnableAnonymousSignature: {
   342  				Computed: true,
   343  				Type:     schema.TypeBool,
   344  			},
   345  			agentSelfEnableCoordinates: {
   346  				Computed: true,
   347  				Type:     schema.TypeBool,
   348  			},
   349  			agentSelfEnableRemoteExec: {
   350  				Computed: true,
   351  				Type:     schema.TypeBool,
   352  			},
   353  			agentSelfEnableUpdateCheck: {
   354  				Computed: true,
   355  				Type:     schema.TypeBool,
   356  			},
   357  			agentSelfDNSRecursors: {
   358  				Computed: true,
   359  				Type:     schema.TypeList,
   360  				Elem:     &schema.Schema{Type: schema.TypeString},
   361  			},
   362  			agentSelfDomain: {
   363  				Computed: true,
   364  				Type:     schema.TypeString,
   365  			},
   366  			agentSelfEnableDebug: {
   367  				Computed: true,
   368  				Type:     schema.TypeBool,
   369  			},
   370  			agentSelfEnableSyslog: {
   371  				Computed: true,
   372  				Type:     schema.TypeBool,
   373  			},
   374  			agentSelfEnableUI: {
   375  				Computed: true,
   376  				Type:     schema.TypeBool,
   377  			},
   378  			// "HTTPAPIResponseHeaders": nil, // TODO(sean@)
   379  			agentSelfID: {
   380  				Computed: true,
   381  				Type:     schema.TypeString,
   382  			},
   383  			agentSelfLeaveOnInt: {
   384  				Computed: true,
   385  				Type:     schema.TypeBool,
   386  			},
   387  			agentSelfLeaveOnTerm: {
   388  				Computed: true,
   389  				Type:     schema.TypeBool,
   390  			},
   391  			agentSelfLogLevel: {
   392  				Computed: true,
   393  				Type:     schema.TypeString,
   394  			},
   395  			agentSelfName: {
   396  				Computed: true,
   397  				Type:     schema.TypeString,
   398  			},
   399  			agentSelfPerformance: {
   400  				Computed: true,
   401  				Type:     schema.TypeMap,
   402  				Elem: &schema.Resource{
   403  					Schema: map[string]*schema.Schema{
   404  						agentSelfPerformanceRaftMultiplier: {
   405  							Computed: true,
   406  							Type:     schema.TypeString, // FIXME(sean@): should be schema.TypeInt
   407  						},
   408  					},
   409  				},
   410  			},
   411  			agentSelfPidFile: {
   412  				Computed: true,
   413  				Type:     schema.TypeString,
   414  			},
   415  			agentSelfPorts: {
   416  				Computed: true,
   417  				Type:     schema.TypeMap,
   418  				Elem: &schema.Resource{
   419  					Schema: map[string]*schema.Schema{
   420  						agentSelfSchemaPortsDNS: {
   421  							Computed: true,
   422  							Type:     schema.TypeInt,
   423  						},
   424  						agentSelfSchemaPortsHTTP: {
   425  							Computed: true,
   426  							Type:     schema.TypeInt,
   427  						},
   428  						agentSelfSchemaPortsHTTPS: {
   429  							Computed: true,
   430  							Type:     schema.TypeInt,
   431  						},
   432  						agentSelfSchemaPortsRPC: {
   433  							Computed: true,
   434  							Type:     schema.TypeInt,
   435  						},
   436  						agentSelfSchemaPortsSerfLAN: {
   437  							Computed: true,
   438  							Type:     schema.TypeInt,
   439  						},
   440  						agentSelfSchemaPortsSerfWAN: {
   441  							Computed: true,
   442  							Type:     schema.TypeInt,
   443  						},
   444  						agentSelfSchemaPortsServer: {
   445  							Computed: true,
   446  							Type:     schema.TypeInt,
   447  						},
   448  					},
   449  				},
   450  			},
   451  			agentSelfProtocol: {
   452  				Computed: true,
   453  				Type:     schema.TypeInt,
   454  			},
   455  			agentSelfReconnectTimeoutLAN: {
   456  				Computed: true,
   457  				Type:     schema.TypeString,
   458  			},
   459  			agentSelfReconnectTimeoutWAN: {
   460  				Computed: true,
   461  				Type:     schema.TypeString,
   462  			},
   463  			agentSelfRejoinAfterLeave: {
   464  				Computed: true,
   465  				Type:     schema.TypeBool,
   466  			},
   467  			agentSelfRetryJoin: {
   468  				Computed: true,
   469  				Type:     schema.TypeList,
   470  				Elem:     &schema.Schema{Type: schema.TypeString},
   471  			},
   472  			agentSelfRetryJoinWAN: {
   473  				Computed: true,
   474  				Type:     schema.TypeList,
   475  				Elem:     &schema.Schema{Type: schema.TypeString},
   476  			},
   477  			agentSelfRetryMaxAttempts: {
   478  				Computed: true,
   479  				Type:     schema.TypeInt,
   480  			},
   481  			agentSelfRetryMaxAttemptsWAN: {
   482  				Computed: true,
   483  				Type:     schema.TypeInt,
   484  			},
   485  			agentSelfRetryJoinEC2: {
   486  				Computed: true,
   487  				Type:     schema.TypeMap,
   488  				Elem: &schema.Resource{
   489  					Schema: map[string]*schema.Schema{
   490  						agentSelfRetryJoinAWSRegion: &schema.Schema{
   491  							Type:     schema.TypeString,
   492  							Computed: true,
   493  						},
   494  						agentSelfRetryJoinAWSTagKey: &schema.Schema{
   495  							Type:     schema.TypeString,
   496  							Computed: true,
   497  						},
   498  						agentSelfRetryJoinAWSTagValue: &schema.Schema{
   499  							Type:     schema.TypeString,
   500  							Computed: true,
   501  						},
   502  					},
   503  				},
   504  			},
   505  			agentSelfRetryJoinGCE: {
   506  				Computed: true,
   507  				Type:     schema.TypeMap,
   508  				Elem: &schema.Resource{
   509  					Schema: map[string]*schema.Schema{
   510  						agentSelfRetryJoinGCEProjectName: &schema.Schema{
   511  							Type:     schema.TypeString,
   512  							Computed: true,
   513  						},
   514  						agentSelfRetryJoinGCEZonePattern: &schema.Schema{
   515  							Type:     schema.TypeString,
   516  							Computed: true,
   517  						},
   518  						agentSelfRetryJoinGCETagValue: &schema.Schema{
   519  							Type:     schema.TypeString,
   520  							Computed: true,
   521  						},
   522  						agentSelfRetryJoinGCECredentialsFile: &schema.Schema{
   523  							Type:     schema.TypeString,
   524  							Computed: true,
   525  						},
   526  					},
   527  				},
   528  			},
   529  			agentSelfSerfLANBindAddr: {
   530  				Computed: true,
   531  				Type:     schema.TypeString,
   532  			},
   533  			agentSelfSerfWANBindAddr: {
   534  				Computed: true,
   535  				Type:     schema.TypeString,
   536  			},
   537  			agentSelfServerMode: {
   538  				Computed: true,
   539  				Type:     schema.TypeBool,
   540  			},
   541  			agentSelfServerName: {
   542  				Computed: true,
   543  				Type:     schema.TypeString,
   544  			},
   545  			agentSelfSessionTTLMin: {
   546  				Computed: true,
   547  				Type:     schema.TypeString,
   548  			},
   549  			agentSelfStartJoin: {
   550  				Computed: true,
   551  				Type:     schema.TypeList,
   552  				Elem:     &schema.Schema{Type: schema.TypeString},
   553  			},
   554  			agentSelfStartJoinWAN: {
   555  				Computed: true,
   556  				Type:     schema.TypeList,
   557  				Elem:     &schema.Schema{Type: schema.TypeString},
   558  			},
   559  			agentSelfSyslogFacility: {
   560  				Computed: true,
   561  				Type:     schema.TypeString,
   562  			},
   563  			agentSelfTaggedAddresses: {
   564  				Computed: true,
   565  				Type:     schema.TypeMap,
   566  				Elem: &schema.Resource{
   567  					Schema: map[string]*schema.Schema{
   568  						agentSelfTaggedAddressesLAN: &schema.Schema{
   569  							Type:     schema.TypeString,
   570  							Computed: true,
   571  						},
   572  						agentSelfTaggedAddressesWAN: &schema.Schema{
   573  							Type:     schema.TypeString,
   574  							Computed: true,
   575  						},
   576  					},
   577  				},
   578  			},
   579  			agentSelfTelemetry: {
   580  				Computed: true,
   581  				Type:     schema.TypeMap,
   582  				Elem: &schema.Resource{
   583  					Schema: map[string]*schema.Schema{
   584  						agentSelfTelemetryCirconusAPIApp: &schema.Schema{
   585  							Type:     schema.TypeString,
   586  							Computed: true,
   587  						},
   588  						agentSelfTelemetryCirconusAPIToken: &schema.Schema{
   589  							Type:     schema.TypeString,
   590  							Computed: true,
   591  						},
   592  						agentSelfTelemetryCirconusAPIURL: &schema.Schema{
   593  							Type:     schema.TypeString,
   594  							Computed: true,
   595  						},
   596  						agentSelfTelemetryCirconusBrokerID: &schema.Schema{
   597  							Type:     schema.TypeString,
   598  							Computed: true,
   599  						},
   600  						agentSelfTelemetryCirconusBrokerSelectTag: &schema.Schema{
   601  							Type:     schema.TypeString,
   602  							Computed: true,
   603  						},
   604  						agentSelfTelemetryCirconusCheckDisplayName: &schema.Schema{
   605  							Type:     schema.TypeString,
   606  							Computed: true,
   607  						},
   608  						agentSelfTelemetryCirconusCheckID: &schema.Schema{
   609  							Type:     schema.TypeString,
   610  							Computed: true,
   611  						},
   612  						agentSelfTelemetryCirconusCheckInstanceID: &schema.Schema{
   613  							Type:     schema.TypeString,
   614  							Computed: true,
   615  						},
   616  						agentSelfTelemetryCirconusCheckSearchTag: &schema.Schema{
   617  							Type:     schema.TypeString,
   618  							Computed: true,
   619  						},
   620  						agentSelfTelemetryCirconusCheckSubmissionURL: &schema.Schema{
   621  							Type:     schema.TypeString,
   622  							Computed: true,
   623  						},
   624  						agentSelfTelemetryCirconusCheckTags: &schema.Schema{
   625  							Type:     schema.TypeString,
   626  							Computed: true,
   627  						},
   628  						agentSelfTelemetryCirconusCheckForceMetricActiation: &schema.Schema{
   629  							Type:     schema.TypeBool,
   630  							Computed: true,
   631  						},
   632  						agentSelfTelemetryCirconusSubmissionInterval: &schema.Schema{
   633  							Type:     schema.TypeString,
   634  							Computed: true,
   635  						},
   636  						agentSelfTelemetryEnableHostname: &schema.Schema{
   637  							Type:     schema.TypeString,
   638  							Computed: true,
   639  						},
   640  						agentSelfTelemetryDogStatsdAddr: &schema.Schema{
   641  							Type:     schema.TypeString,
   642  							Computed: true,
   643  						},
   644  						agentSelfTelemetryDogStatsdTags: &schema.Schema{
   645  							Type:     schema.TypeList,
   646  							Computed: true,
   647  							Elem:     &schema.Schema{Type: schema.TypeString},
   648  						},
   649  						agentSelfTelemetryStatsdAddr: {
   650  							Type:     schema.TypeString,
   651  							Computed: true,
   652  						},
   653  						agentSelfTelemetryStatsiteAddr: {
   654  							Type:     schema.TypeString,
   655  							Computed: true,
   656  						},
   657  						agentSelfTelemetryStatsitePrefix: {
   658  							Type:     schema.TypeString,
   659  							Computed: true,
   660  						},
   661  					},
   662  				},
   663  			},
   664  			agentSelfTLSCAFile: {
   665  				Computed: true,
   666  				Type:     schema.TypeString,
   667  			},
   668  			agentSelfTLSCertFile: {
   669  				Computed: true,
   670  				Type:     schema.TypeString,
   671  			},
   672  			agentSelfTLSKeyFile: {
   673  				Computed: true,
   674  				Type:     schema.TypeString,
   675  			},
   676  			agentSelfTLSMinVersion: {
   677  				Computed: true,
   678  				Type:     schema.TypeString,
   679  			},
   680  			agentSelfTLSVerifyIncoming: {
   681  				Computed: true,
   682  				Type:     schema.TypeBool,
   683  			},
   684  			agentSelfTLSVerifyServerHostname: {
   685  				Computed: true,
   686  				Type:     schema.TypeBool,
   687  			},
   688  			agentSelfTLSVerifyOutgoing: {
   689  				Computed: true,
   690  				Type:     schema.TypeBool,
   691  			},
   692  			agentSelfTranslateWANAddrs: {
   693  				Computed: true,
   694  				Type:     schema.TypeBool,
   695  			},
   696  			agentSelfUIDir: {
   697  				Computed: true,
   698  				Type:     schema.TypeString,
   699  			},
   700  			agentSelfUnixSockets: {
   701  				Computed: true,
   702  				Type:     schema.TypeMap,
   703  				Elem: &schema.Resource{
   704  					Schema: map[string]*schema.Schema{
   705  						agentSelfUnixSocketUser: &schema.Schema{
   706  							Type:     schema.TypeString,
   707  							Computed: true,
   708  						},
   709  						agentSelfUnixSocketGroup: &schema.Schema{
   710  							Type:     schema.TypeString,
   711  							Computed: true,
   712  						},
   713  						agentSelfUnixSocketMode: &schema.Schema{
   714  							Type:     schema.TypeString,
   715  							Computed: true,
   716  						},
   717  					},
   718  				},
   719  			},
   720  			agentSelfVersion: {
   721  				Computed: true,
   722  				Type:     schema.TypeString,
   723  			},
   724  			agentSelfVersionPrerelease: {
   725  				Computed: true,
   726  				Type:     schema.TypeString,
   727  			},
   728  			agentSelfVersionRevision: {
   729  				Computed: true,
   730  				Type:     schema.TypeString,
   731  			},
   732  			// "Watches":                nil,
   733  		},
   734  	}
   735  }
   736  
   737  func dataSourceConsulAgentSelfRead(d *schema.ResourceData, meta interface{}) error {
   738  	client := meta.(*consulapi.Client)
   739  	info, err := client.Agent().Self()
   740  	if err != nil {
   741  		return err
   742  	}
   743  
   744  	const apiAgentConfig = "Config"
   745  	cfg, ok := info[apiAgentConfig]
   746  	if !ok {
   747  		return fmt.Errorf("No %s info available within provider's agent/self endpoint", apiAgentConfig)
   748  	}
   749  
   750  	// Pull the datacenter first because we use it when setting the ID
   751  	var dc string
   752  	if v, found := cfg["Datacenter"]; found {
   753  		dc = v.(string)
   754  	}
   755  
   756  	const idKeyFmt = "agent-self-%s"
   757  	d.SetId(fmt.Sprintf(idKeyFmt, dc))
   758  
   759  	if v, found := cfg["ACLDatacenter"]; found {
   760  		d.Set(agentSelfACLDatacenter, v.(string))
   761  	}
   762  
   763  	if v, found := cfg["ACLDefaultPolicy"]; found {
   764  		d.Set(agentSelfACLDefaultPolicy, v.(string))
   765  	}
   766  
   767  	if v, found := cfg["ACLDisabledTTL"]; found {
   768  		dur := time.Duration(int64(v.(float64)))
   769  		d.Set(agentSelfACLDisabledTTL, dur.String())
   770  	}
   771  
   772  	if v, found := cfg["ACLDownPolicy"]; found {
   773  		d.Set(agentSelfACLDownPolicy, v.(string))
   774  	}
   775  
   776  	if v, found := cfg["ACLEnforceVersion8"]; found {
   777  		d.Set(agentSelfACLEnforceVersion8, v.(bool))
   778  	}
   779  
   780  	if v, found := cfg["ACLTTL"]; found {
   781  		dur := time.Duration(int64(v.(float64)))
   782  		d.Set(agentSelfACLTTL, dur.String())
   783  	}
   784  
   785  	if v, found := cfg["Addresses"]; found {
   786  		addrs := v.(map[string]interface{})
   787  
   788  		m := make(map[string]interface{}, len(addrs))
   789  
   790  		if v, found := addrs["DNS"]; found {
   791  			m[agentSelfSchemaPortsDNS] = v.(string)
   792  		}
   793  
   794  		if v, found := addrs["HTTP"]; found {
   795  			m[agentSelfSchemaPortsHTTP] = v.(string)
   796  		}
   797  
   798  		if v, found := addrs["HTTPS"]; found {
   799  			m[agentSelfSchemaPortsHTTPS] = v.(string)
   800  		}
   801  
   802  		if v, found := addrs["RPC"]; found {
   803  			m[agentSelfSchemaPortsRPC] = v.(string)
   804  		}
   805  
   806  		if err := d.Set(agentSelfAddresses, m); err != nil {
   807  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfAddresses), err)
   808  		}
   809  	}
   810  
   811  	if v, found := cfg["AdvertiseAddr"]; found {
   812  		d.Set(agentSelfAdvertiseAddr, v.(string))
   813  	}
   814  
   815  	if v, found := cfg["AdvertiseAddrs"]; found {
   816  		addrs := v.(map[string]interface{})
   817  
   818  		m := make(map[string]interface{}, len(addrs))
   819  
   820  		if v, found := addrs["SerfLan"]; found && v != nil {
   821  			m[agentSelfSchemaPortsSerfLAN] = v.(string)
   822  		}
   823  
   824  		if v, found := addrs["SerfWan"]; found && v != nil {
   825  			m[agentSelfSchemaPortsSerfWAN] = v.(string)
   826  		}
   827  
   828  		if v, found := addrs["RPC"]; found && v != nil {
   829  			m[agentSelfSchemaPortsRPC] = v.(string)
   830  		}
   831  
   832  		if err := d.Set(agentSelfAdvertiseAddrs, m); err != nil {
   833  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfAdvertiseAddrs), err)
   834  		}
   835  	}
   836  
   837  	if v, found := cfg["AtlasJoin"]; found {
   838  		d.Set(agentSelfAtlasJoin, v.(bool))
   839  	}
   840  
   841  	if v, found := cfg["BindAddr"]; found {
   842  		d.Set(agentSelfBindAddr, v.(string))
   843  	}
   844  
   845  	if v, found := cfg["Bootstrap"]; found {
   846  		d.Set(agentSelfBootstrapMode, v.(bool))
   847  	}
   848  
   849  	if v, found := cfg["BootstrapExpect"]; found {
   850  		d.Set(agentSelfBootstrapExpect, int(v.(float64)))
   851  	}
   852  
   853  	if v, found := cfg["CheckDeregisterIntervalMin"]; found {
   854  		dur := time.Duration(int64(v.(float64)))
   855  		d.Set(agentSelfCheckDeregisterIntervalMin, dur.String())
   856  	}
   857  
   858  	if v, found := cfg["CheckReapInterval"]; found {
   859  		dur := time.Duration(int64(v.(float64)))
   860  		d.Set(agentSelfCheckReapInterval, dur.String())
   861  	}
   862  
   863  	if v, found := cfg["CheckUpdateInterval"]; found {
   864  		dur := time.Duration(int64(v.(float64)))
   865  		d.Set(agentSelfCheckUpdateInterval, dur.String())
   866  	}
   867  
   868  	if v, found := cfg["ClientAddr"]; found {
   869  		d.Set(agentSelfClientAddr, v.(string))
   870  	}
   871  
   872  	if v, found := cfg["DNS"]; found {
   873  		dnsOpts := v.(map[string]interface{})
   874  
   875  		m := make(map[string]interface{}, len(dnsOpts))
   876  
   877  		if v, found := dnsOpts["AllowStale"]; found {
   878  			m[agentSelfDNSAllowStale] = v.(bool)
   879  		}
   880  
   881  		if v, found := dnsOpts["DisableCompression"]; found {
   882  			m[agentSelfDNSEnableCompression] = !v.(bool)
   883  		}
   884  
   885  		if v, found := dnsOpts["EnableTruncate"]; found {
   886  			m[agentSelfDNSEnableTruncate] = v.(bool)
   887  		}
   888  
   889  		if v, found := dnsOpts["MaxStale"]; found {
   890  			dur := time.Duration(int64(v.(float64)))
   891  			m[agentSelfDNSMaxStale] = dur.String()
   892  		}
   893  
   894  		if v, found := dnsOpts["NodeTTL"]; found {
   895  			dur := time.Duration(int64(v.(float64)))
   896  			m[agentSelfDNSNodeTTL] = dur.String()
   897  		}
   898  
   899  		if v, found := dnsOpts["OnlyPassing"]; found {
   900  			m[agentSelfDNSOnlyPassing] = v.(bool)
   901  		}
   902  
   903  		if v, found := dnsOpts["RecursorTimeout"]; found {
   904  			dur := time.Duration(int64(v.(float64)))
   905  			m[agentSelfDNSRecursorTimeout] = dur.String()
   906  		}
   907  
   908  		if v, found := dnsOpts["ServiceTTL"]; found {
   909  			dur := time.Duration(int64(v.(float64)))
   910  			m[agentSelfDNSServiceTTL] = dur.String()
   911  		}
   912  
   913  		if v, found := dnsOpts["UDPAnswerLimit"]; found {
   914  			m[agentSelfDNSServiceTTL] = v.(int)
   915  		}
   916  
   917  		if err := d.Set(agentSelfDNSConfig, m); err != nil {
   918  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfDNSConfig), err)
   919  		}
   920  	}
   921  
   922  	{
   923  		var l []interface{}
   924  
   925  		if v, found := cfg["DNSRecursors"]; found {
   926  			l = make([]interface{}, 0, len(v.([]interface{}))+1)
   927  			l = append(l, v.([]interface{})...)
   928  		}
   929  
   930  		if v, found := cfg["DNSRecursor"]; found {
   931  			l = append([]interface{}{v.(string)}, l...)
   932  		}
   933  
   934  		if len(l) > 0 {
   935  			if err := d.Set(agentSelfDNSRecursors, l); err != nil {
   936  				return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfDNSRecursors), err)
   937  			}
   938  		}
   939  	}
   940  
   941  	if v, found := cfg["DataDir"]; found {
   942  		d.Set(agentSelfDataDir, v.(string))
   943  	}
   944  
   945  	if len(dc) > 0 {
   946  		d.Set(agentSelfDatacenter, dc)
   947  	}
   948  
   949  	if v, found := cfg["DevMode"]; found {
   950  		d.Set(agentSelfDevMode, v.(bool))
   951  	}
   952  
   953  	if v, found := cfg["DisableAnonymousSignature"]; found {
   954  		d.Set(agentSelfEnableAnonymousSignature, !v.(bool))
   955  	}
   956  
   957  	if v, found := cfg["DisableCoordinates"]; found {
   958  		d.Set(agentSelfEnableCoordinates, !v.(bool))
   959  	}
   960  
   961  	if v, found := cfg["DisableRemoteExec"]; found {
   962  		d.Set(agentSelfEnableRemoteExec, !v.(bool))
   963  	}
   964  
   965  	if v, found := cfg["DisableUpdateCheck"]; found {
   966  		d.Set(agentSelfEnableUpdateCheck, !v.(bool))
   967  	}
   968  
   969  	if v, found := cfg["Domain"]; found {
   970  		d.Set(agentSelfDomain, v.(string))
   971  	}
   972  
   973  	if v, found := cfg["EnableDebug"]; found {
   974  		d.Set(agentSelfEnableDebug, v.(bool))
   975  	}
   976  
   977  	if v, found := cfg["EnableSyslog"]; found {
   978  		d.Set(agentSelfEnableSyslog, v.(bool))
   979  	}
   980  
   981  	if v, found := cfg["EnableUi"]; found {
   982  		d.Set(agentSelfEnableUI, v.(bool))
   983  	}
   984  
   985  	if v, found := cfg["id"]; found {
   986  		d.Set(agentSelfID, v.(string))
   987  	}
   988  
   989  	if v, found := cfg["SkipLeaveOnInt"]; found {
   990  		d.Set(agentSelfLeaveOnInt, !v.(bool))
   991  	}
   992  
   993  	if v, found := cfg["LeaveOnTerm"]; found {
   994  		d.Set(agentSelfLeaveOnTerm, v.(bool))
   995  	}
   996  
   997  	if v, found := cfg["LogLevel"]; found {
   998  		d.Set(agentSelfLogLevel, v.(string))
   999  	}
  1000  
  1001  	if v, found := cfg["NodeName"]; found {
  1002  		d.Set(agentSelfName, v.(string))
  1003  	}
  1004  
  1005  	if v, found := cfg["Performance"]; found {
  1006  		cfgs := v.(map[string]interface{})
  1007  
  1008  		m := make(map[string]interface{}, len(cfgs))
  1009  
  1010  		if v, found := cfgs["RaftMultiplier"]; found {
  1011  			m[agentSelfPerformanceRaftMultiplier] = strconv.FormatFloat(v.(float64), 'g', -1, 64)
  1012  		}
  1013  
  1014  		if err := d.Set(agentSelfPerformance, m); err != nil {
  1015  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfPerformance), err)
  1016  		}
  1017  	}
  1018  
  1019  	if v, found := cfg["PidFile"]; found {
  1020  		d.Set(agentSelfPidFile, v.(string))
  1021  	}
  1022  
  1023  	if v, found := cfg["Ports"]; found {
  1024  		cfgs := v.(map[string]interface{})
  1025  
  1026  		m := make(map[string]interface{}, len(cfgs))
  1027  
  1028  		if v, found := cfgs[agentSelfAPIPortsDNS]; found {
  1029  			m[agentSelfSchemaPortsDNS] = int(v.(float64))
  1030  		}
  1031  
  1032  		if v, found := cfgs[agentSelfAPIPortsHTTP]; found {
  1033  			m[agentSelfSchemaPortsHTTP] = int(v.(float64))
  1034  		}
  1035  
  1036  		if v, found := cfgs[agentSelfAPIPortsHTTPS]; found {
  1037  			m[agentSelfSchemaPortsHTTPS] = int(v.(float64))
  1038  		}
  1039  
  1040  		if v, found := cfgs[agentSelfAPIPortsRPC]; found {
  1041  			m[agentSelfSchemaPortsRPC] = int(v.(float64))
  1042  		}
  1043  
  1044  		if v, found := cfgs[agentSelfAPIPortsSerfLAN]; found {
  1045  			m[agentSelfSchemaPortsSerfLAN] = int(v.(float64))
  1046  		}
  1047  
  1048  		if v, found := cfgs[agentSelfAPIPortsSerfWAN]; found {
  1049  			m[agentSelfSchemaPortsSerfWAN] = int(v.(float64))
  1050  		}
  1051  
  1052  		if v, found := cfgs[agentSelfAPIPortsServer]; found {
  1053  			m[agentSelfSchemaPortsServer] = int(v.(float64))
  1054  		}
  1055  
  1056  		if err := d.Set(agentSelfPorts, m); err != nil {
  1057  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfPorts), err)
  1058  		}
  1059  	}
  1060  
  1061  	if v, found := cfg["Protocol"]; found {
  1062  		d.Set(agentSelfProtocol, int(v.(float64)))
  1063  	}
  1064  
  1065  	if v, found := cfg["ReconnectTimeoutLan"]; found {
  1066  		dur := time.Duration(int64(v.(float64)))
  1067  		d.Set(agentSelfReconnectTimeoutLAN, dur.String())
  1068  	}
  1069  
  1070  	if v, found := cfg["ReconnectTimeoutWan"]; found {
  1071  		dur := time.Duration(int64(v.(float64)))
  1072  		d.Set(agentSelfReconnectTimeoutWAN, dur.String())
  1073  	}
  1074  
  1075  	if v, found := cfg["RejoinAfterLeave"]; found {
  1076  		d.Set(agentSelfRejoinAfterLeave, v.(bool))
  1077  	}
  1078  
  1079  	if v, found := cfg["RetryJoin"]; found {
  1080  		l := make([]string, 0, len(v.([]interface{})))
  1081  		for _, e := range v.([]interface{}) {
  1082  			l = append(l, e.(string))
  1083  		}
  1084  
  1085  		if err := d.Set(agentSelfRetryJoin, l); err != nil {
  1086  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfRetryJoin), err)
  1087  		}
  1088  	}
  1089  
  1090  	if v, found := cfg["RetryJoinEC2"]; found {
  1091  		ec2Config := v.(map[string]interface{})
  1092  
  1093  		m := make(map[string]interface{}, len(ec2Config))
  1094  
  1095  		if v, found := ec2Config["Region"]; found {
  1096  			m[agentSelfRetryJoinAWSRegion] = v.(string)
  1097  		}
  1098  
  1099  		if v, found := ec2Config["TagKey"]; found {
  1100  			m[agentSelfRetryJoinAWSTagKey] = v.(string)
  1101  		}
  1102  
  1103  		if v, found := ec2Config["TagValue"]; found {
  1104  			m[agentSelfRetryJoinAWSTagValue] = v.(string)
  1105  		}
  1106  
  1107  		if err := d.Set(agentSelfRetryJoinEC2, m); err != nil {
  1108  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfRetryJoinEC2), err)
  1109  		}
  1110  	}
  1111  
  1112  	if v, found := cfg["RetryJoinWan"]; found {
  1113  		l := make([]string, 0, len(v.([]interface{})))
  1114  		for _, e := range v.([]interface{}) {
  1115  			l = append(l, e.(string))
  1116  		}
  1117  
  1118  		if err := d.Set(agentSelfRetryJoinWAN, l); err != nil {
  1119  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfRetryJoinWAN), err)
  1120  		}
  1121  	}
  1122  
  1123  	if v, found := cfg["RetryMaxAttempts"]; found {
  1124  		d.Set(agentSelfRetryMaxAttempts, int(v.(float64)))
  1125  	}
  1126  
  1127  	if v, found := cfg["RetryMaxAttemptsWan"]; found {
  1128  		d.Set(agentSelfRetryMaxAttemptsWAN, int(v.(float64)))
  1129  	}
  1130  
  1131  	if v, found := cfg["SerfLanBindAddr"]; found {
  1132  		d.Set(agentSelfSerfLANBindAddr, v.(string))
  1133  	}
  1134  
  1135  	if v, found := cfg["SerfWanBindAddr"]; found {
  1136  		d.Set(agentSelfSerfWANBindAddr, v.(string))
  1137  	}
  1138  
  1139  	if v, found := cfg["Server"]; found {
  1140  		d.Set(agentSelfServerMode, v.(bool))
  1141  	}
  1142  
  1143  	if v, found := cfg["ServerName"]; found {
  1144  		d.Set(agentSelfServerName, v.(string))
  1145  	}
  1146  
  1147  	if v, found := cfg["SessionTTLMin"]; found {
  1148  		dur := time.Duration(int64(v.(float64)))
  1149  		d.Set(agentSelfSessionTTLMin, dur.String())
  1150  	}
  1151  
  1152  	if v, found := cfg["StartJoin"]; found {
  1153  		serverList := v.([]interface{})
  1154  		l := make([]interface{}, 0, len(serverList))
  1155  		l = append(l, serverList...)
  1156  		if err := d.Set(agentSelfStartJoin, l); err != nil {
  1157  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfStartJoin), err)
  1158  		}
  1159  	}
  1160  
  1161  	if v, found := cfg["StartJoinWan"]; found {
  1162  		serverList := v.([]interface{})
  1163  		l := make([]interface{}, 0, len(serverList))
  1164  		l = append(l, serverList...)
  1165  		if err := d.Set(agentSelfStartJoinWAN, l); err != nil {
  1166  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfStartJoinWAN), err)
  1167  		}
  1168  	}
  1169  
  1170  	if v, found := cfg["SyslogFacility"]; found {
  1171  		d.Set(agentSelfSyslogFacility, v.(string))
  1172  	}
  1173  
  1174  	if v, found := cfg["CAFile"]; found {
  1175  		d.Set(agentSelfTLSCAFile, v.(string))
  1176  	}
  1177  
  1178  	if v, found := cfg["CertFile"]; found {
  1179  		d.Set(agentSelfTLSCertFile, v.(string))
  1180  	}
  1181  
  1182  	if v, found := cfg["KeyFile"]; found {
  1183  		d.Set(agentSelfTLSKeyFile, v.(string))
  1184  	}
  1185  
  1186  	if v, found := cfg["TLSMinVersion"]; found {
  1187  		d.Set(agentSelfTLSMinVersion, v.(string))
  1188  	}
  1189  
  1190  	if v, found := cfg["VerifyIncoming"]; found {
  1191  		d.Set(agentSelfTLSVerifyIncoming, v.(bool))
  1192  	}
  1193  
  1194  	if v, found := cfg["VerifyOutgoing"]; found {
  1195  		d.Set(agentSelfTLSVerifyOutgoing, v.(bool))
  1196  	}
  1197  
  1198  	if v, found := cfg["VerifyServerHostname"]; found {
  1199  		d.Set(agentSelfTLSVerifyServerHostname, v.(bool))
  1200  	}
  1201  
  1202  	if v, found := cfg["TaggedAddresses"]; found {
  1203  		addrs := v.(map[string]interface{})
  1204  
  1205  		m := make(map[string]interface{}, len(addrs))
  1206  
  1207  		// NOTE(sean@): agentSelfTaggedAddressesLAN and agentSelfTaggedAddressesWAN
  1208  		// are the only two known values that should be in this map at present, but
  1209  		// in the future this value could/will expand and the schema should be
  1210  		// releaxed to include both the known *{L,W}AN values as well as whatever
  1211  		// else the user specifies.
  1212  		for s, t := range addrs {
  1213  			m[s] = t
  1214  		}
  1215  
  1216  		if err := d.Set(agentSelfTaggedAddresses, m); err != nil {
  1217  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfTaggedAddresses), err)
  1218  		}
  1219  	}
  1220  
  1221  	if v, found := cfg["Telemetry"]; found {
  1222  		telemetryCfg := v.(map[string]interface{})
  1223  
  1224  		m := make(map[string]interface{}, len(telemetryCfg))
  1225  
  1226  		if v, found := telemetryCfg["CirconusAPIApp"]; found {
  1227  			m[agentSelfTelemetryCirconusAPIApp] = v.(string)
  1228  		}
  1229  
  1230  		if v, found := telemetryCfg["CirconusAPIURL"]; found {
  1231  			m[agentSelfTelemetryCirconusAPIURL] = v.(string)
  1232  		}
  1233  
  1234  		if v, found := telemetryCfg["CirconusBrokerID"]; found {
  1235  			m[agentSelfTelemetryCirconusBrokerID] = v.(string)
  1236  		}
  1237  
  1238  		if v, found := telemetryCfg["CirconusBrokerSelectTag"]; found {
  1239  			m[agentSelfTelemetryCirconusBrokerSelectTag] = v.(string)
  1240  		}
  1241  
  1242  		if v, found := telemetryCfg["CirconusCheckDisplayName"]; found {
  1243  			m[agentSelfTelemetryCirconusCheckDisplayName] = v.(string)
  1244  		}
  1245  
  1246  		if v, found := telemetryCfg["CirconusCheckID"]; found {
  1247  			m[agentSelfTelemetryCirconusCheckID] = v.(string)
  1248  		}
  1249  
  1250  		if v, found := telemetryCfg["CirconusCheckInstanceID"]; found {
  1251  			m[agentSelfTelemetryCirconusCheckInstanceID] = v.(string)
  1252  		}
  1253  
  1254  		if v, found := telemetryCfg["CirconusCheckSearchTag"]; found {
  1255  			m[agentSelfTelemetryCirconusCheckSearchTag] = v.(string)
  1256  		}
  1257  
  1258  		if v, found := telemetryCfg["CirconusCheckSubmissionURL"]; found {
  1259  			m[agentSelfTelemetryCirconusCheckSubmissionURL] = v.(string)
  1260  		}
  1261  
  1262  		if v, found := telemetryCfg["CirconusCheckTags"]; found {
  1263  			m[agentSelfTelemetryCirconusCheckTags] = v.(string)
  1264  		}
  1265  
  1266  		if v, found := telemetryCfg["CirconusCheckForceMetricActivation"]; found {
  1267  			m[agentSelfTelemetryCirconusCheckForceMetricActiation] = v.(string)
  1268  		}
  1269  
  1270  		if v, found := telemetryCfg["CirconusSubmissionInterval"]; found {
  1271  			m[agentSelfTelemetryCirconusSubmissionInterval] = v.(string)
  1272  		}
  1273  
  1274  		if v, found := telemetryCfg["DisableHostname"]; found {
  1275  			m[agentSelfTelemetryEnableHostname] = fmt.Sprintf("%t", !v.(bool))
  1276  		}
  1277  
  1278  		if v, found := telemetryCfg["DogStatsdAddr"]; found {
  1279  			m[agentSelfTelemetryDogStatsdAddr] = v.(string)
  1280  		}
  1281  
  1282  		if v, found := telemetryCfg["DogStatsdTags"]; found && v != nil {
  1283  			m[agentSelfTelemetryDogStatsdTags] = append([]interface{}(nil), v.([]interface{})...)
  1284  		}
  1285  
  1286  		if v, found := telemetryCfg["StatsdAddr"]; found {
  1287  			m[agentSelfTelemetryStatsdAddr] = v.(string)
  1288  		}
  1289  
  1290  		if v, found := telemetryCfg["StatsiteAddr"]; found {
  1291  			m[agentSelfTelemetryStatsiteAddr] = v.(string)
  1292  		}
  1293  
  1294  		if v, found := telemetryCfg["StatsitePrefix"]; found {
  1295  			m[agentSelfTelemetryStatsitePrefix] = v.(string)
  1296  		}
  1297  
  1298  		if err := d.Set(agentSelfTelemetry, m); err != nil {
  1299  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfTelemetry), err)
  1300  		}
  1301  	}
  1302  
  1303  	if v, found := cfg["TranslateWanTelemetryCfg"]; found {
  1304  		d.Set(agentSelfTranslateWANAddrs, v.(bool))
  1305  	}
  1306  
  1307  	if v, found := cfg["UiDir"]; found {
  1308  		d.Set(agentSelfUIDir, v.(string))
  1309  	}
  1310  
  1311  	if v, found := cfg["UnixSockets"]; found {
  1312  		socketConfig := v.(map[string]interface{})
  1313  
  1314  		m := make(map[string]interface{}, len(socketConfig))
  1315  
  1316  		if v, found := socketConfig["Grp"]; found {
  1317  			m[agentSelfUnixSocketGroup] = v.(string)
  1318  		}
  1319  
  1320  		if v, found := socketConfig["Mode"]; found {
  1321  			m[agentSelfUnixSocketMode] = v.(string)
  1322  		}
  1323  
  1324  		if v, found := socketConfig["Usr"]; found {
  1325  			m[agentSelfUnixSocketUser] = v.(string)
  1326  		}
  1327  
  1328  		if err := d.Set(agentSelfUnixSockets, m); err != nil {
  1329  			return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfUnixSockets), err)
  1330  		}
  1331  	}
  1332  
  1333  	if v, found := cfg["Version"]; found {
  1334  		d.Set(agentSelfVersion, v.(string))
  1335  	}
  1336  
  1337  	if v, found := cfg["VersionPrerelease"]; found {
  1338  		d.Set(agentSelfVersionPrerelease, v.(string))
  1339  	}
  1340  
  1341  	if v, found := cfg["VersionPrerelease"]; found {
  1342  		d.Set(agentSelfVersionPrerelease, v.(string))
  1343  	}
  1344  
  1345  	if v, found := cfg["Revision"]; found {
  1346  		d.Set(agentSelfVersionRevision, v.(string))
  1347  	}
  1348  
  1349  	return nil
  1350  }