github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/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 ValidateFunc: makeValidationFunc(agentSelfACLDisabledTTL, validatorInputs{ 185 validateDurationMin("0ns"), 186 }), 187 }, 188 agentSelfACLDownPolicy: { 189 Computed: true, 190 Type: schema.TypeString, 191 }, 192 agentSelfACLEnforceVersion8: { 193 Computed: true, 194 Type: schema.TypeBool, 195 }, 196 agentSelfACLTTL: { 197 Computed: true, 198 Type: schema.TypeString, 199 ValidateFunc: makeValidationFunc(agentSelfACLTTL, validatorInputs{ 200 validateDurationMin("0ns"), 201 }), 202 }, 203 agentSelfAddresses: { 204 Computed: true, 205 Type: schema.TypeMap, 206 Elem: &schema.Resource{ 207 Schema: map[string]*schema.Schema{ 208 agentSelfSchemaPortsDNS: &schema.Schema{ 209 Type: schema.TypeString, 210 Computed: true, 211 }, 212 agentSelfSchemaPortsHTTP: &schema.Schema{ 213 Type: schema.TypeString, 214 Computed: true, 215 }, 216 agentSelfSchemaPortsHTTPS: &schema.Schema{ 217 Type: schema.TypeString, 218 Computed: true, 219 }, 220 agentSelfSchemaPortsRPC: &schema.Schema{ 221 Type: schema.TypeString, 222 Computed: true, 223 }, 224 }, 225 }, 226 }, 227 agentSelfAdvertiseAddr: { 228 Computed: true, 229 Type: schema.TypeString, 230 }, 231 agentSelfAdvertiseAddrs: { 232 Computed: true, 233 Type: schema.TypeMap, 234 Elem: &schema.Resource{ 235 Schema: map[string]*schema.Schema{ 236 agentSelfSchemaPortsSerfLAN: &schema.Schema{ 237 Type: schema.TypeString, 238 Computed: true, 239 }, 240 agentSelfSchemaPortsSerfWAN: &schema.Schema{ 241 Type: schema.TypeString, 242 Computed: true, 243 }, 244 agentSelfSchemaPortsRPC: &schema.Schema{ 245 Type: schema.TypeString, 246 Computed: true, 247 }, 248 }, 249 }, 250 }, 251 agentSelfAdvertiseAddrWAN: { 252 Computed: true, 253 Type: schema.TypeString, 254 }, 255 // Omitting the following since they've been depreciated: 256 // 257 // "AtlasInfrastructure": "", 258 // "AtlasEndpoint": "", 259 agentSelfAtlasJoin: { 260 Computed: true, 261 Type: schema.TypeBool, 262 }, 263 agentSelfBindAddr: { 264 Computed: true, 265 Type: schema.TypeString, 266 }, 267 agentSelfBootstrapMode: { 268 Computed: true, 269 Type: schema.TypeBool, 270 }, 271 agentSelfBootstrapExpect: { 272 Computed: true, 273 Type: schema.TypeInt, 274 }, 275 agentSelfCheckDeregisterIntervalMin: { 276 Computed: true, 277 Type: schema.TypeString, 278 ValidateFunc: makeValidationFunc(agentSelfCheckDeregisterIntervalMin, validatorInputs{ 279 validateDurationMin("0ns"), 280 }), 281 }, 282 agentSelfCheckReapInterval: { 283 Computed: true, 284 Type: schema.TypeString, 285 ValidateFunc: makeValidationFunc(agentSelfCheckReapInterval, validatorInputs{ 286 validateDurationMin("0ns"), 287 }), 288 }, 289 agentSelfCheckUpdateInterval: { 290 Computed: true, 291 Type: schema.TypeString, 292 ValidateFunc: makeValidationFunc(agentSelfCheckUpdateInterval, validatorInputs{ 293 validateDurationMin("0ns"), 294 }), 295 }, 296 agentSelfClientAddr: { 297 Computed: true, 298 Type: schema.TypeString, 299 }, 300 agentSelfDNSConfig: { 301 Computed: true, 302 Type: schema.TypeMap, 303 Elem: &schema.Resource{ 304 Schema: map[string]*schema.Schema{ 305 agentSelfDNSAllowStale: { 306 Computed: true, 307 Type: schema.TypeBool, 308 }, 309 agentSelfDNSEnableCompression: { 310 Computed: true, 311 Type: schema.TypeBool, 312 }, 313 agentSelfDNSEnableTruncate: { 314 Computed: true, 315 Type: schema.TypeBool, 316 }, 317 agentSelfDNSMaxStale: { 318 Computed: true, 319 Type: schema.TypeString, 320 ValidateFunc: makeValidationFunc(agentSelfDNSMaxStale, validatorInputs{ 321 validateDurationMin("0ns"), 322 }), 323 }, 324 agentSelfDNSNodeTTL: { 325 Computed: true, 326 Type: schema.TypeString, 327 ValidateFunc: makeValidationFunc(agentSelfDNSNodeTTL, validatorInputs{ 328 validateDurationMin("0ns"), 329 }), 330 }, 331 agentSelfDNSOnlyPassing: { 332 Computed: true, 333 Type: schema.TypeBool, 334 }, 335 agentSelfDNSRecursorTimeout: { 336 Computed: true, 337 Type: schema.TypeString, 338 ValidateFunc: makeValidationFunc(agentSelfDNSRecursorTimeout, validatorInputs{ 339 validateDurationMin("0ns"), 340 }), 341 }, 342 agentSelfDNSServiceTTL: { 343 Computed: true, 344 Type: schema.TypeString, 345 ValidateFunc: makeValidationFunc(agentSelfDNSServiceTTL, validatorInputs{ 346 validateDurationMin("0ns"), 347 }), 348 }, 349 agentSelfDNSUDPAnswerLimit: { 350 Computed: true, 351 Type: schema.TypeInt, 352 }, 353 }, 354 }, 355 }, 356 agentSelfDataDir: { 357 Computed: true, 358 Type: schema.TypeString, 359 }, 360 agentSelfDatacenter: { 361 Computed: true, 362 Type: schema.TypeString, 363 }, 364 agentSelfDevMode: { 365 Computed: true, 366 Type: schema.TypeBool, 367 }, 368 agentSelfEnableAnonymousSignature: { 369 Computed: true, 370 Type: schema.TypeBool, 371 }, 372 agentSelfEnableCoordinates: { 373 Computed: true, 374 Type: schema.TypeBool, 375 }, 376 agentSelfEnableRemoteExec: { 377 Computed: true, 378 Type: schema.TypeBool, 379 }, 380 agentSelfEnableUpdateCheck: { 381 Computed: true, 382 Type: schema.TypeBool, 383 }, 384 agentSelfDNSRecursors: { 385 Computed: true, 386 Type: schema.TypeList, 387 Elem: &schema.Schema{Type: schema.TypeString}, 388 }, 389 agentSelfDomain: { 390 Computed: true, 391 Type: schema.TypeString, 392 }, 393 agentSelfEnableDebug: { 394 Computed: true, 395 Type: schema.TypeBool, 396 }, 397 agentSelfEnableSyslog: { 398 Computed: true, 399 Type: schema.TypeBool, 400 }, 401 agentSelfEnableUI: { 402 Computed: true, 403 Type: schema.TypeBool, 404 }, 405 // "HTTPAPIResponseHeaders": nil, // TODO(sean@) 406 agentSelfID: { 407 Computed: true, 408 Type: schema.TypeString, 409 ValidateFunc: makeValidationFunc(agentSelfID, validatorInputs{ 410 validateRegexp(`(?i)^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$`), 411 }), 412 }, 413 agentSelfLeaveOnInt: { 414 Computed: true, 415 Type: schema.TypeBool, 416 }, 417 agentSelfLeaveOnTerm: { 418 Computed: true, 419 Type: schema.TypeBool, 420 }, 421 agentSelfLogLevel: { 422 Computed: true, 423 Type: schema.TypeString, 424 }, 425 agentSelfName: { 426 Computed: true, 427 Type: schema.TypeString, 428 }, 429 agentSelfPerformance: { 430 Computed: true, 431 Type: schema.TypeMap, 432 Elem: &schema.Resource{ 433 Schema: map[string]*schema.Schema{ 434 agentSelfPerformanceRaftMultiplier: { 435 Computed: true, 436 Type: schema.TypeString, // FIXME(sean@): should be schema.TypeInt 437 ValidateFunc: makeValidationFunc(agentSelfPerformanceRaftMultiplier, validatorInputs{ 438 validateIntMin(0), 439 }), 440 }, 441 }, 442 }, 443 }, 444 agentSelfPidFile: { 445 Computed: true, 446 Type: schema.TypeString, 447 }, 448 agentSelfPorts: { 449 Computed: true, 450 Type: schema.TypeMap, 451 Elem: &schema.Resource{ 452 Schema: map[string]*schema.Schema{ 453 agentSelfSchemaPortsDNS: { 454 Computed: true, 455 Type: schema.TypeInt, 456 ValidateFunc: makeValidationFunc(agentSelfSchemaPortsDNS, validatorInputs{ 457 validateIntMin(1), 458 validateIntMax(65535), 459 }), 460 }, 461 agentSelfSchemaPortsHTTP: { 462 Computed: true, 463 Type: schema.TypeInt, 464 ValidateFunc: makeValidationFunc(agentSelfSchemaPortsHTTP, validatorInputs{ 465 validateIntMin(1), 466 validateIntMax(65535), 467 }), 468 }, 469 agentSelfSchemaPortsHTTPS: { 470 Computed: true, 471 Type: schema.TypeInt, 472 ValidateFunc: makeValidationFunc(agentSelfSchemaPortsHTTPS, validatorInputs{ 473 validateIntMin(1), 474 validateIntMax(65535), 475 }), 476 }, 477 agentSelfSchemaPortsRPC: { 478 Computed: true, 479 Type: schema.TypeInt, 480 ValidateFunc: makeValidationFunc(agentSelfSchemaPortsRPC, validatorInputs{ 481 validateIntMin(1), 482 validateIntMax(65535), 483 }), 484 }, 485 agentSelfSchemaPortsSerfLAN: { 486 Computed: true, 487 Type: schema.TypeInt, 488 ValidateFunc: makeValidationFunc(agentSelfSchemaPortsSerfLAN, validatorInputs{ 489 validateIntMin(1), 490 validateIntMax(65535), 491 }), 492 }, 493 agentSelfSchemaPortsSerfWAN: { 494 Computed: true, 495 Type: schema.TypeInt, 496 ValidateFunc: makeValidationFunc(agentSelfSchemaPortsSerfWAN, validatorInputs{ 497 validateIntMin(1), 498 validateIntMax(65535), 499 }), 500 }, 501 agentSelfSchemaPortsServer: { 502 Computed: true, 503 Type: schema.TypeInt, 504 ValidateFunc: makeValidationFunc(agentSelfSchemaPortsServer, validatorInputs{ 505 validateIntMin(1), 506 validateIntMax(65535), 507 }), 508 }, 509 }, 510 }, 511 }, 512 agentSelfProtocol: { 513 Computed: true, 514 Type: schema.TypeInt, 515 }, 516 agentSelfReconnectTimeoutLAN: { 517 Computed: true, 518 Type: schema.TypeString, 519 ValidateFunc: makeValidationFunc(agentSelfReconnectTimeoutLAN, validatorInputs{ 520 validateDurationMin("0ns"), 521 }), 522 }, 523 agentSelfReconnectTimeoutWAN: { 524 Computed: true, 525 Type: schema.TypeString, 526 ValidateFunc: makeValidationFunc(agentSelfReconnectTimeoutWAN, validatorInputs{ 527 validateDurationMin("0ns"), 528 }), 529 }, 530 agentSelfRejoinAfterLeave: { 531 Computed: true, 532 Type: schema.TypeBool, 533 }, 534 agentSelfRetryJoin: { 535 Computed: true, 536 Type: schema.TypeList, 537 Elem: &schema.Schema{Type: schema.TypeString}, 538 }, 539 agentSelfRetryJoinWAN: { 540 Computed: true, 541 Type: schema.TypeList, 542 Elem: &schema.Schema{Type: schema.TypeString}, 543 }, 544 agentSelfRetryMaxAttempts: { 545 Computed: true, 546 Type: schema.TypeInt, 547 }, 548 agentSelfRetryMaxAttemptsWAN: { 549 Computed: true, 550 Type: schema.TypeInt, 551 }, 552 agentSelfRetryJoinEC2: { 553 Computed: true, 554 Type: schema.TypeMap, 555 Elem: &schema.Resource{ 556 Schema: map[string]*schema.Schema{ 557 agentSelfRetryJoinAWSRegion: &schema.Schema{ 558 Type: schema.TypeString, 559 Computed: true, 560 }, 561 agentSelfRetryJoinAWSTagKey: &schema.Schema{ 562 Type: schema.TypeString, 563 Computed: true, 564 }, 565 agentSelfRetryJoinAWSTagValue: &schema.Schema{ 566 Type: schema.TypeString, 567 Computed: true, 568 }, 569 }, 570 }, 571 }, 572 agentSelfRetryJoinGCE: { 573 Computed: true, 574 Type: schema.TypeMap, 575 Elem: &schema.Resource{ 576 Schema: map[string]*schema.Schema{ 577 agentSelfRetryJoinGCEProjectName: &schema.Schema{ 578 Type: schema.TypeString, 579 Computed: true, 580 }, 581 agentSelfRetryJoinGCEZonePattern: &schema.Schema{ 582 Type: schema.TypeString, 583 Computed: true, 584 }, 585 agentSelfRetryJoinGCETagValue: &schema.Schema{ 586 Type: schema.TypeString, 587 Computed: true, 588 }, 589 agentSelfRetryJoinGCECredentialsFile: &schema.Schema{ 590 Type: schema.TypeString, 591 Computed: true, 592 }, 593 }, 594 }, 595 }, 596 agentSelfSerfLANBindAddr: { 597 Computed: true, 598 Type: schema.TypeString, 599 }, 600 agentSelfSerfWANBindAddr: { 601 Computed: true, 602 Type: schema.TypeString, 603 }, 604 agentSelfServerMode: { 605 Computed: true, 606 Type: schema.TypeBool, 607 }, 608 agentSelfServerName: { 609 Computed: true, 610 Type: schema.TypeString, 611 }, 612 agentSelfSessionTTLMin: { 613 Computed: true, 614 Type: schema.TypeString, 615 ValidateFunc: makeValidationFunc(agentSelfSessionTTLMin, validatorInputs{ 616 validateDurationMin("0ns"), 617 }), 618 }, 619 agentSelfStartJoin: { 620 Computed: true, 621 Type: schema.TypeList, 622 Elem: &schema.Schema{Type: schema.TypeString}, 623 }, 624 agentSelfStartJoinWAN: { 625 Computed: true, 626 Type: schema.TypeList, 627 Elem: &schema.Schema{Type: schema.TypeString}, 628 }, 629 agentSelfSyslogFacility: { 630 Computed: true, 631 Type: schema.TypeString, 632 }, 633 agentSelfTaggedAddresses: { 634 Computed: true, 635 Type: schema.TypeMap, 636 Elem: &schema.Resource{ 637 Schema: map[string]*schema.Schema{ 638 agentSelfTaggedAddressesLAN: &schema.Schema{ 639 Type: schema.TypeString, 640 Computed: true, 641 }, 642 agentSelfTaggedAddressesWAN: &schema.Schema{ 643 Type: schema.TypeString, 644 Computed: true, 645 }, 646 }, 647 }, 648 }, 649 agentSelfTelemetry: { 650 Computed: true, 651 Type: schema.TypeMap, 652 Elem: &schema.Resource{ 653 Schema: map[string]*schema.Schema{ 654 agentSelfTelemetryCirconusAPIApp: &schema.Schema{ 655 Type: schema.TypeString, 656 Computed: true, 657 }, 658 agentSelfTelemetryCirconusAPIToken: &schema.Schema{ 659 Type: schema.TypeString, 660 Computed: true, 661 }, 662 agentSelfTelemetryCirconusAPIURL: &schema.Schema{ 663 Type: schema.TypeString, 664 Computed: true, 665 }, 666 agentSelfTelemetryCirconusBrokerID: &schema.Schema{ 667 Type: schema.TypeString, 668 Computed: true, 669 }, 670 agentSelfTelemetryCirconusBrokerSelectTag: &schema.Schema{ 671 Type: schema.TypeString, 672 Computed: true, 673 }, 674 agentSelfTelemetryCirconusCheckDisplayName: &schema.Schema{ 675 Type: schema.TypeString, 676 Computed: true, 677 }, 678 agentSelfTelemetryCirconusCheckID: &schema.Schema{ 679 Type: schema.TypeString, 680 Computed: true, 681 }, 682 agentSelfTelemetryCirconusCheckInstanceID: &schema.Schema{ 683 Type: schema.TypeString, 684 Computed: true, 685 }, 686 agentSelfTelemetryCirconusCheckSearchTag: &schema.Schema{ 687 Type: schema.TypeString, 688 Computed: true, 689 }, 690 agentSelfTelemetryCirconusCheckSubmissionURL: &schema.Schema{ 691 Type: schema.TypeString, 692 Computed: true, 693 }, 694 agentSelfTelemetryCirconusCheckTags: &schema.Schema{ 695 Type: schema.TypeString, 696 Computed: true, 697 }, 698 agentSelfTelemetryCirconusCheckForceMetricActiation: &schema.Schema{ 699 Type: schema.TypeBool, 700 Computed: true, 701 }, 702 agentSelfTelemetryCirconusSubmissionInterval: &schema.Schema{ 703 Type: schema.TypeString, 704 Computed: true, 705 ValidateFunc: makeValidationFunc(agentSelfTelemetryCirconusSubmissionInterval, validatorInputs{ 706 validateDurationMin("0ns"), 707 }), 708 }, 709 agentSelfTelemetryEnableHostname: &schema.Schema{ 710 Type: schema.TypeString, 711 Computed: true, 712 }, 713 agentSelfTelemetryDogStatsdAddr: &schema.Schema{ 714 Type: schema.TypeString, 715 Computed: true, 716 }, 717 agentSelfTelemetryDogStatsdTags: &schema.Schema{ 718 Type: schema.TypeList, 719 Computed: true, 720 Elem: &schema.Schema{Type: schema.TypeString}, 721 }, 722 agentSelfTelemetryStatsdAddr: { 723 Type: schema.TypeString, 724 Computed: true, 725 }, 726 agentSelfTelemetryStatsiteAddr: { 727 Type: schema.TypeString, 728 Computed: true, 729 }, 730 agentSelfTelemetryStatsitePrefix: { 731 Type: schema.TypeString, 732 Computed: true, 733 }, 734 }, 735 }, 736 }, 737 agentSelfTLSCAFile: { 738 Computed: true, 739 Type: schema.TypeString, 740 }, 741 agentSelfTLSCertFile: { 742 Computed: true, 743 Type: schema.TypeString, 744 }, 745 agentSelfTLSKeyFile: { 746 Computed: true, 747 Type: schema.TypeString, 748 }, 749 agentSelfTLSMinVersion: { 750 Computed: true, 751 Type: schema.TypeString, 752 }, 753 agentSelfTLSVerifyIncoming: { 754 Computed: true, 755 Type: schema.TypeBool, 756 }, 757 agentSelfTLSVerifyServerHostname: { 758 Computed: true, 759 Type: schema.TypeBool, 760 }, 761 agentSelfTLSVerifyOutgoing: { 762 Computed: true, 763 Type: schema.TypeBool, 764 }, 765 agentSelfTranslateWANAddrs: { 766 Computed: true, 767 Type: schema.TypeBool, 768 }, 769 agentSelfUIDir: { 770 Computed: true, 771 Type: schema.TypeString, 772 }, 773 agentSelfUnixSockets: { 774 Computed: true, 775 Type: schema.TypeMap, 776 Elem: &schema.Resource{ 777 Schema: map[string]*schema.Schema{ 778 agentSelfUnixSocketUser: &schema.Schema{ 779 Type: schema.TypeString, 780 Computed: true, 781 }, 782 agentSelfUnixSocketGroup: &schema.Schema{ 783 Type: schema.TypeString, 784 Computed: true, 785 }, 786 agentSelfUnixSocketMode: &schema.Schema{ 787 Type: schema.TypeString, 788 Computed: true, 789 }, 790 }, 791 }, 792 }, 793 agentSelfVersion: { 794 Computed: true, 795 Type: schema.TypeString, 796 }, 797 agentSelfVersionPrerelease: { 798 Computed: true, 799 Type: schema.TypeString, 800 }, 801 agentSelfVersionRevision: { 802 Computed: true, 803 Type: schema.TypeString, 804 }, 805 // "Watches": nil, 806 }, 807 } 808 } 809 810 func dataSourceConsulAgentSelfRead(d *schema.ResourceData, meta interface{}) error { 811 client := meta.(*consulapi.Client) 812 info, err := client.Agent().Self() 813 if err != nil { 814 return err 815 } 816 817 const apiAgentConfig = "Config" 818 cfg, ok := info[apiAgentConfig] 819 if !ok { 820 return fmt.Errorf("No %s info available within provider's agent/self endpoint", apiAgentConfig) 821 } 822 823 // Pull the datacenter first because we use it when setting the ID 824 var dc string 825 if v, found := cfg["Datacenter"]; found { 826 dc = v.(string) 827 } 828 829 const idKeyFmt = "agent-self-%s" 830 d.SetId(fmt.Sprintf(idKeyFmt, dc)) 831 832 if v, found := cfg["ACLDatacenter"]; found { 833 d.Set(agentSelfACLDatacenter, v.(string)) 834 } 835 836 if v, found := cfg["ACLDefaultPolicy"]; found { 837 d.Set(agentSelfACLDefaultPolicy, v.(string)) 838 } 839 840 if v, found := cfg["ACLDisabledTTL"]; found { 841 dur := time.Duration(int64(v.(float64))) 842 d.Set(agentSelfACLDisabledTTL, dur.String()) 843 } 844 845 if v, found := cfg["ACLDownPolicy"]; found { 846 d.Set(agentSelfACLDownPolicy, v.(string)) 847 } 848 849 if v, found := cfg["ACLEnforceVersion8"]; found { 850 d.Set(agentSelfACLEnforceVersion8, v.(bool)) 851 } 852 853 if v, found := cfg["ACLTTL"]; found { 854 dur := time.Duration(int64(v.(float64))) 855 d.Set(agentSelfACLTTL, dur.String()) 856 } 857 858 if v, found := cfg["Addresses"]; found { 859 addrs := v.(map[string]interface{}) 860 861 m := make(map[string]interface{}, len(addrs)) 862 863 if v, found := addrs["DNS"]; found { 864 m[agentSelfSchemaPortsDNS] = v.(string) 865 } 866 867 if v, found := addrs["HTTP"]; found { 868 m[agentSelfSchemaPortsHTTP] = v.(string) 869 } 870 871 if v, found := addrs["HTTPS"]; found { 872 m[agentSelfSchemaPortsHTTPS] = v.(string) 873 } 874 875 if v, found := addrs["RPC"]; found { 876 m[agentSelfSchemaPortsRPC] = v.(string) 877 } 878 879 if err := d.Set(agentSelfAddresses, m); err != nil { 880 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfAddresses), err) 881 } 882 } 883 884 if v, found := cfg["AdvertiseAddr"]; found { 885 d.Set(agentSelfAdvertiseAddr, v.(string)) 886 } 887 888 if v, found := cfg["AdvertiseAddrs"]; found { 889 addrs := v.(map[string]interface{}) 890 891 m := make(map[string]interface{}, len(addrs)) 892 893 if v, found := addrs["SerfLan"]; found && v != nil { 894 m[agentSelfSchemaPortsSerfLAN] = v.(string) 895 } 896 897 if v, found := addrs["SerfWan"]; found && v != nil { 898 m[agentSelfSchemaPortsSerfWAN] = v.(string) 899 } 900 901 if v, found := addrs["RPC"]; found && v != nil { 902 m[agentSelfSchemaPortsRPC] = v.(string) 903 } 904 905 if err := d.Set(agentSelfAdvertiseAddrs, m); err != nil { 906 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfAdvertiseAddrs), err) 907 } 908 } 909 910 if v, found := cfg["AtlasJoin"]; found { 911 d.Set(agentSelfAtlasJoin, v.(bool)) 912 } 913 914 if v, found := cfg["BindAddr"]; found { 915 d.Set(agentSelfBindAddr, v.(string)) 916 } 917 918 if v, found := cfg["Bootstrap"]; found { 919 d.Set(agentSelfBootstrapMode, v.(bool)) 920 } 921 922 if v, found := cfg["BootstrapExpect"]; found { 923 d.Set(agentSelfBootstrapExpect, int(v.(float64))) 924 } 925 926 if v, found := cfg["CheckDeregisterIntervalMin"]; found { 927 dur := time.Duration(int64(v.(float64))) 928 d.Set(agentSelfCheckDeregisterIntervalMin, dur.String()) 929 } 930 931 if v, found := cfg["CheckReapInterval"]; found { 932 dur := time.Duration(int64(v.(float64))) 933 d.Set(agentSelfCheckReapInterval, dur.String()) 934 } 935 936 if v, found := cfg["CheckUpdateInterval"]; found { 937 dur := time.Duration(int64(v.(float64))) 938 d.Set(agentSelfCheckUpdateInterval, dur.String()) 939 } 940 941 if v, found := cfg["ClientAddr"]; found { 942 d.Set(agentSelfClientAddr, v.(string)) 943 } 944 945 if v, found := cfg["DNS"]; found { 946 dnsOpts := v.(map[string]interface{}) 947 948 m := make(map[string]interface{}, len(dnsOpts)) 949 950 if v, found := dnsOpts["AllowStale"]; found { 951 m[agentSelfDNSAllowStale] = v.(bool) 952 } 953 954 if v, found := dnsOpts["DisableCompression"]; found { 955 m[agentSelfDNSEnableCompression] = !v.(bool) 956 } 957 958 if v, found := dnsOpts["EnableTruncate"]; found { 959 m[agentSelfDNSEnableTruncate] = v.(bool) 960 } 961 962 if v, found := dnsOpts["MaxStale"]; found { 963 dur := time.Duration(int64(v.(float64))) 964 m[agentSelfDNSMaxStale] = dur.String() 965 } 966 967 if v, found := dnsOpts["NodeTTL"]; found { 968 dur := time.Duration(int64(v.(float64))) 969 m[agentSelfDNSNodeTTL] = dur.String() 970 } 971 972 if v, found := dnsOpts["OnlyPassing"]; found { 973 m[agentSelfDNSOnlyPassing] = v.(bool) 974 } 975 976 if v, found := dnsOpts["RecursorTimeout"]; found { 977 dur := time.Duration(int64(v.(float64))) 978 m[agentSelfDNSRecursorTimeout] = dur.String() 979 } 980 981 if v, found := dnsOpts["ServiceTTL"]; found { 982 dur := time.Duration(int64(v.(float64))) 983 m[agentSelfDNSServiceTTL] = dur.String() 984 } 985 986 if v, found := dnsOpts["UDPAnswerLimit"]; found { 987 m[agentSelfDNSServiceTTL] = v.(int) 988 } 989 990 if err := d.Set(agentSelfDNSConfig, m); err != nil { 991 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfDNSConfig), err) 992 } 993 } 994 995 { 996 var l []interface{} 997 998 if v, found := cfg["DNSRecursors"]; found { 999 l = make([]interface{}, 0, len(v.([]interface{}))+1) 1000 l = append(l, v.([]interface{})...) 1001 } 1002 1003 if v, found := cfg["DNSRecursor"]; found { 1004 l = append([]interface{}{v.(string)}, l...) 1005 } 1006 1007 if len(l) > 0 { 1008 if err := d.Set(agentSelfDNSRecursors, l); err != nil { 1009 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfDNSRecursors), err) 1010 } 1011 } 1012 } 1013 1014 if v, found := cfg["DataDir"]; found { 1015 d.Set(agentSelfDataDir, v.(string)) 1016 } 1017 1018 if len(dc) > 0 { 1019 d.Set(agentSelfDatacenter, dc) 1020 } 1021 1022 if v, found := cfg["DevMode"]; found { 1023 d.Set(agentSelfDevMode, v.(bool)) 1024 } 1025 1026 if v, found := cfg["DisableAnonymousSignature"]; found { 1027 d.Set(agentSelfEnableAnonymousSignature, !v.(bool)) 1028 } 1029 1030 if v, found := cfg["DisableCoordinates"]; found { 1031 d.Set(agentSelfEnableCoordinates, !v.(bool)) 1032 } 1033 1034 if v, found := cfg["DisableRemoteExec"]; found { 1035 d.Set(agentSelfEnableRemoteExec, !v.(bool)) 1036 } 1037 1038 if v, found := cfg["DisableUpdateCheck"]; found { 1039 d.Set(agentSelfEnableUpdateCheck, !v.(bool)) 1040 } 1041 1042 if v, found := cfg["Domain"]; found { 1043 d.Set(agentSelfDomain, v.(string)) 1044 } 1045 1046 if v, found := cfg["EnableDebug"]; found { 1047 d.Set(agentSelfEnableDebug, v.(bool)) 1048 } 1049 1050 if v, found := cfg["EnableSyslog"]; found { 1051 d.Set(agentSelfEnableSyslog, v.(bool)) 1052 } 1053 1054 if v, found := cfg["EnableUi"]; found { 1055 d.Set(agentSelfEnableUI, v.(bool)) 1056 } 1057 1058 if v, found := cfg["id"]; found { 1059 d.Set(agentSelfID, v.(string)) 1060 } 1061 1062 if v, found := cfg["SkipLeaveOnInt"]; found { 1063 d.Set(agentSelfLeaveOnInt, !v.(bool)) 1064 } 1065 1066 if v, found := cfg["LeaveOnTerm"]; found { 1067 d.Set(agentSelfLeaveOnTerm, v.(bool)) 1068 } 1069 1070 if v, found := cfg["LogLevel"]; found { 1071 d.Set(agentSelfLogLevel, v.(string)) 1072 } 1073 1074 if v, found := cfg["NodeName"]; found { 1075 d.Set(agentSelfName, v.(string)) 1076 } 1077 1078 if v, found := cfg["Performance"]; found { 1079 cfgs := v.(map[string]interface{}) 1080 1081 m := make(map[string]interface{}, len(cfgs)) 1082 1083 if v, found := cfgs["RaftMultiplier"]; found { 1084 m[agentSelfPerformanceRaftMultiplier] = strconv.FormatFloat(v.(float64), 'g', -1, 64) 1085 } 1086 1087 if err := d.Set(agentSelfPerformance, m); err != nil { 1088 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfPerformance), err) 1089 } 1090 } 1091 1092 if v, found := cfg["PidFile"]; found { 1093 d.Set(agentSelfPidFile, v.(string)) 1094 } 1095 1096 if v, found := cfg["Ports"]; found { 1097 cfgs := v.(map[string]interface{}) 1098 1099 m := make(map[string]interface{}, len(cfgs)) 1100 1101 if v, found := cfgs[agentSelfAPIPortsDNS]; found { 1102 m[agentSelfSchemaPortsDNS] = int(v.(float64)) 1103 } 1104 1105 if v, found := cfgs[agentSelfAPIPortsHTTP]; found { 1106 m[agentSelfSchemaPortsHTTP] = int(v.(float64)) 1107 } 1108 1109 if v, found := cfgs[agentSelfAPIPortsHTTPS]; found { 1110 m[agentSelfSchemaPortsHTTPS] = int(v.(float64)) 1111 } 1112 1113 if v, found := cfgs[agentSelfAPIPortsRPC]; found { 1114 m[agentSelfSchemaPortsRPC] = int(v.(float64)) 1115 } 1116 1117 if v, found := cfgs[agentSelfAPIPortsSerfLAN]; found { 1118 m[agentSelfSchemaPortsSerfLAN] = int(v.(float64)) 1119 } 1120 1121 if v, found := cfgs[agentSelfAPIPortsSerfWAN]; found { 1122 m[agentSelfSchemaPortsSerfWAN] = int(v.(float64)) 1123 } 1124 1125 if v, found := cfgs[agentSelfAPIPortsServer]; found { 1126 m[agentSelfSchemaPortsServer] = int(v.(float64)) 1127 } 1128 1129 if err := d.Set(agentSelfPorts, m); err != nil { 1130 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfPorts), err) 1131 } 1132 } 1133 1134 if v, found := cfg["Protocol"]; found { 1135 d.Set(agentSelfProtocol, int(v.(float64))) 1136 } 1137 1138 if v, found := cfg["ReconnectTimeoutLan"]; found { 1139 dur := time.Duration(int64(v.(float64))) 1140 d.Set(agentSelfReconnectTimeoutLAN, dur.String()) 1141 } 1142 1143 if v, found := cfg["ReconnectTimeoutWan"]; found { 1144 dur := time.Duration(int64(v.(float64))) 1145 d.Set(agentSelfReconnectTimeoutWAN, dur.String()) 1146 } 1147 1148 if v, found := cfg["RejoinAfterLeave"]; found { 1149 d.Set(agentSelfRejoinAfterLeave, v.(bool)) 1150 } 1151 1152 if v, found := cfg["RetryJoin"]; found { 1153 l := make([]string, 0, len(v.([]interface{}))) 1154 for _, e := range v.([]interface{}) { 1155 l = append(l, e.(string)) 1156 } 1157 1158 if err := d.Set(agentSelfRetryJoin, l); err != nil { 1159 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfRetryJoin), err) 1160 } 1161 } 1162 1163 if v, found := cfg["RetryJoinEC2"]; found { 1164 ec2Config := v.(map[string]interface{}) 1165 1166 m := make(map[string]interface{}, len(ec2Config)) 1167 1168 if v, found := ec2Config["Region"]; found { 1169 m[agentSelfRetryJoinAWSRegion] = v.(string) 1170 } 1171 1172 if v, found := ec2Config["TagKey"]; found { 1173 m[agentSelfRetryJoinAWSTagKey] = v.(string) 1174 } 1175 1176 if v, found := ec2Config["TagValue"]; found { 1177 m[agentSelfRetryJoinAWSTagValue] = v.(string) 1178 } 1179 1180 if err := d.Set(agentSelfRetryJoinEC2, m); err != nil { 1181 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfRetryJoinEC2), err) 1182 } 1183 } 1184 1185 if v, found := cfg["RetryJoinWan"]; found { 1186 l := make([]string, 0, len(v.([]interface{}))) 1187 for _, e := range v.([]interface{}) { 1188 l = append(l, e.(string)) 1189 } 1190 1191 if err := d.Set(agentSelfRetryJoinWAN, l); err != nil { 1192 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfRetryJoinWAN), err) 1193 } 1194 } 1195 1196 if v, found := cfg["RetryMaxAttempts"]; found { 1197 d.Set(agentSelfRetryMaxAttempts, int(v.(float64))) 1198 } 1199 1200 if v, found := cfg["RetryMaxAttemptsWan"]; found { 1201 d.Set(agentSelfRetryMaxAttemptsWAN, int(v.(float64))) 1202 } 1203 1204 if v, found := cfg["SerfLanBindAddr"]; found { 1205 d.Set(agentSelfSerfLANBindAddr, v.(string)) 1206 } 1207 1208 if v, found := cfg["SerfWanBindAddr"]; found { 1209 d.Set(agentSelfSerfWANBindAddr, v.(string)) 1210 } 1211 1212 if v, found := cfg["Server"]; found { 1213 d.Set(agentSelfServerMode, v.(bool)) 1214 } 1215 1216 if v, found := cfg["ServerName"]; found { 1217 d.Set(agentSelfServerName, v.(string)) 1218 } 1219 1220 if v, found := cfg["SessionTTLMin"]; found { 1221 dur := time.Duration(int64(v.(float64))) 1222 d.Set(agentSelfSessionTTLMin, dur.String()) 1223 } 1224 1225 if v, found := cfg["StartJoin"]; found { 1226 serverList := v.([]interface{}) 1227 l := make([]interface{}, 0, len(serverList)) 1228 l = append(l, serverList...) 1229 if err := d.Set(agentSelfStartJoin, l); err != nil { 1230 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfStartJoin), err) 1231 } 1232 } 1233 1234 if v, found := cfg["StartJoinWan"]; found { 1235 serverList := v.([]interface{}) 1236 l := make([]interface{}, 0, len(serverList)) 1237 l = append(l, serverList...) 1238 if err := d.Set(agentSelfStartJoinWAN, l); err != nil { 1239 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfStartJoinWAN), err) 1240 } 1241 } 1242 1243 if v, found := cfg["SyslogFacility"]; found { 1244 d.Set(agentSelfSyslogFacility, v.(string)) 1245 } 1246 1247 if v, found := cfg["CAFile"]; found { 1248 d.Set(agentSelfTLSCAFile, v.(string)) 1249 } 1250 1251 if v, found := cfg["CertFile"]; found { 1252 d.Set(agentSelfTLSCertFile, v.(string)) 1253 } 1254 1255 if v, found := cfg["KeyFile"]; found { 1256 d.Set(agentSelfTLSKeyFile, v.(string)) 1257 } 1258 1259 if v, found := cfg["TLSMinVersion"]; found { 1260 d.Set(agentSelfTLSMinVersion, v.(string)) 1261 } 1262 1263 if v, found := cfg["VerifyIncoming"]; found { 1264 d.Set(agentSelfTLSVerifyIncoming, v.(bool)) 1265 } 1266 1267 if v, found := cfg["VerifyOutgoing"]; found { 1268 d.Set(agentSelfTLSVerifyOutgoing, v.(bool)) 1269 } 1270 1271 if v, found := cfg["VerifyServerHostname"]; found { 1272 d.Set(agentSelfTLSVerifyServerHostname, v.(bool)) 1273 } 1274 1275 if v, found := cfg["TaggedAddresses"]; found { 1276 addrs := v.(map[string]interface{}) 1277 1278 m := make(map[string]interface{}, len(addrs)) 1279 1280 // NOTE(sean@): agentSelfTaggedAddressesLAN and agentSelfTaggedAddressesWAN 1281 // are the only two known values that should be in this map at present, but 1282 // in the future this value could/will expand and the schema should be 1283 // releaxed to include both the known *{L,W}AN values as well as whatever 1284 // else the user specifies. 1285 for s, t := range addrs { 1286 m[s] = t 1287 } 1288 1289 if err := d.Set(agentSelfTaggedAddresses, m); err != nil { 1290 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfTaggedAddresses), err) 1291 } 1292 } 1293 1294 if v, found := cfg["Telemetry"]; found { 1295 telemetryCfg := v.(map[string]interface{}) 1296 1297 m := make(map[string]interface{}, len(telemetryCfg)) 1298 1299 if v, found := telemetryCfg["CirconusAPIApp"]; found { 1300 m[agentSelfTelemetryCirconusAPIApp] = v.(string) 1301 } 1302 1303 if v, found := telemetryCfg["CirconusAPIURL"]; found { 1304 m[agentSelfTelemetryCirconusAPIURL] = v.(string) 1305 } 1306 1307 if v, found := telemetryCfg["CirconusBrokerID"]; found { 1308 m[agentSelfTelemetryCirconusBrokerID] = v.(string) 1309 } 1310 1311 if v, found := telemetryCfg["CirconusBrokerSelectTag"]; found { 1312 m[agentSelfTelemetryCirconusBrokerSelectTag] = v.(string) 1313 } 1314 1315 if v, found := telemetryCfg["CirconusCheckDisplayName"]; found { 1316 m[agentSelfTelemetryCirconusCheckDisplayName] = v.(string) 1317 } 1318 1319 if v, found := telemetryCfg["CirconusCheckID"]; found { 1320 m[agentSelfTelemetryCirconusCheckID] = v.(string) 1321 } 1322 1323 if v, found := telemetryCfg["CirconusCheckInstanceID"]; found { 1324 m[agentSelfTelemetryCirconusCheckInstanceID] = v.(string) 1325 } 1326 1327 if v, found := telemetryCfg["CirconusCheckSearchTag"]; found { 1328 m[agentSelfTelemetryCirconusCheckSearchTag] = v.(string) 1329 } 1330 1331 if v, found := telemetryCfg["CirconusCheckSubmissionURL"]; found { 1332 m[agentSelfTelemetryCirconusCheckSubmissionURL] = v.(string) 1333 } 1334 1335 if v, found := telemetryCfg["CirconusCheckTags"]; found { 1336 m[agentSelfTelemetryCirconusCheckTags] = v.(string) 1337 } 1338 1339 if v, found := telemetryCfg["CirconusCheckForceMetricActivation"]; found { 1340 m[agentSelfTelemetryCirconusCheckForceMetricActiation] = v.(string) 1341 } 1342 1343 if v, found := telemetryCfg["CirconusSubmissionInterval"]; found { 1344 m[agentSelfTelemetryCirconusSubmissionInterval] = v.(string) 1345 } 1346 1347 if v, found := telemetryCfg["DisableHostname"]; found { 1348 m[agentSelfTelemetryEnableHostname] = fmt.Sprintf("%t", !v.(bool)) 1349 } 1350 1351 if v, found := telemetryCfg["DogStatsdAddr"]; found { 1352 m[agentSelfTelemetryDogStatsdAddr] = v.(string) 1353 } 1354 1355 if v, found := telemetryCfg["DogStatsdTags"]; found && v != nil { 1356 m[agentSelfTelemetryDogStatsdTags] = append([]interface{}(nil), v.([]interface{})...) 1357 } 1358 1359 if v, found := telemetryCfg["StatsdAddr"]; found { 1360 m[agentSelfTelemetryStatsdAddr] = v.(string) 1361 } 1362 1363 if v, found := telemetryCfg["StatsiteAddr"]; found { 1364 m[agentSelfTelemetryStatsiteAddr] = v.(string) 1365 } 1366 1367 if v, found := telemetryCfg["StatsitePrefix"]; found { 1368 m[agentSelfTelemetryStatsitePrefix] = v.(string) 1369 } 1370 1371 if err := d.Set(agentSelfTelemetry, m); err != nil { 1372 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfTelemetry), err) 1373 } 1374 } 1375 1376 if v, found := cfg["TranslateWanTelemetryCfg"]; found { 1377 d.Set(agentSelfTranslateWANAddrs, v.(bool)) 1378 } 1379 1380 if v, found := cfg["UiDir"]; found { 1381 d.Set(agentSelfUIDir, v.(string)) 1382 } 1383 1384 if v, found := cfg["UnixSockets"]; found { 1385 socketConfig := v.(map[string]interface{}) 1386 1387 m := make(map[string]interface{}, len(socketConfig)) 1388 1389 if v, found := socketConfig["Grp"]; found { 1390 m[agentSelfUnixSocketGroup] = v.(string) 1391 } 1392 1393 if v, found := socketConfig["Mode"]; found { 1394 m[agentSelfUnixSocketMode] = v.(string) 1395 } 1396 1397 if v, found := socketConfig["Usr"]; found { 1398 m[agentSelfUnixSocketUser] = v.(string) 1399 } 1400 1401 if err := d.Set(agentSelfUnixSockets, m); err != nil { 1402 return errwrap.Wrapf(fmt.Sprintf("Unable to set %s: {{err}}", agentSelfUnixSockets), err) 1403 } 1404 } 1405 1406 if v, found := cfg["Version"]; found { 1407 d.Set(agentSelfVersion, v.(string)) 1408 } 1409 1410 if v, found := cfg["VersionPrerelease"]; found { 1411 d.Set(agentSelfVersionPrerelease, v.(string)) 1412 } 1413 1414 if v, found := cfg["VersionPrerelease"]; found { 1415 d.Set(agentSelfVersionPrerelease, v.(string)) 1416 } 1417 1418 if v, found := cfg["Revision"]; found { 1419 d.Set(agentSelfVersionRevision, v.(string)) 1420 } 1421 1422 return nil 1423 }