Merge branch 'master' into cgriggs01-comm-5
This commit is contained in:
commit
0cc057b873
|
@ -971,7 +971,19 @@ func TestCheckModuleResourceAttr(mp []string, name string, key string, value str
|
|||
}
|
||||
|
||||
func testCheckResourceAttr(is *terraform.InstanceState, name string, key string, value string) error {
|
||||
// Empty containers may be elided from the state.
|
||||
// If the intent here is to check for an empty container, allow the key to
|
||||
// also be non-existent.
|
||||
emptyCheck := false
|
||||
if value == "0" && (strings.HasSuffix(key, ".#") || strings.HasSuffix(key, ".%")) {
|
||||
emptyCheck = true
|
||||
}
|
||||
|
||||
if v, ok := is.Attributes[key]; !ok || v != value {
|
||||
if emptyCheck && !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !ok {
|
||||
return fmt.Errorf("%s: Attribute '%s' not found", name, key)
|
||||
}
|
||||
|
@ -1014,7 +1026,20 @@ func TestCheckModuleNoResourceAttr(mp []string, name string, key string) TestChe
|
|||
}
|
||||
|
||||
func testCheckNoResourceAttr(is *terraform.InstanceState, name string, key string) error {
|
||||
if _, ok := is.Attributes[key]; ok {
|
||||
// Empty containers may sometimes be included in the state.
|
||||
// If the intent here is to check for an empty container, allow the value to
|
||||
// also be "0".
|
||||
emptyCheck := false
|
||||
if strings.HasSuffix(key, ".#") || strings.HasSuffix(key, ".%") {
|
||||
emptyCheck = true
|
||||
}
|
||||
|
||||
val, exists := is.Attributes[key]
|
||||
if emptyCheck && val == "0" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if exists {
|
||||
return fmt.Errorf("%s: Attribute '%s' found when not expected", name, key)
|
||||
}
|
||||
|
||||
|
|
|
@ -1113,3 +1113,65 @@ resource "test_instance" "foo" {}
|
|||
const testConfigStrProvider = `
|
||||
provider "test" {}
|
||||
`
|
||||
|
||||
func TestCheckResourceAttr_empty(t *testing.T) {
|
||||
s := terraform.NewState()
|
||||
s.AddModuleState(&terraform.ModuleState{
|
||||
Path: []string{"root"},
|
||||
Resources: map[string]*terraform.ResourceState{
|
||||
"test_resource": &terraform.ResourceState{
|
||||
Primary: &terraform.InstanceState{
|
||||
Attributes: map[string]string{
|
||||
"empty_list.#": "0",
|
||||
"empty_map.%": "0",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
for _, key := range []string{
|
||||
"empty_list.#",
|
||||
"empty_map.%",
|
||||
"missing_list.#",
|
||||
"missing_map.%",
|
||||
} {
|
||||
t.Run(key, func(t *testing.T) {
|
||||
check := TestCheckResourceAttr("test_resource", key, "0")
|
||||
if err := check(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckNoResourceAttr_empty(t *testing.T) {
|
||||
s := terraform.NewState()
|
||||
s.AddModuleState(&terraform.ModuleState{
|
||||
Path: []string{"root"},
|
||||
Resources: map[string]*terraform.ResourceState{
|
||||
"test_resource": &terraform.ResourceState{
|
||||
Primary: &terraform.InstanceState{
|
||||
Attributes: map[string]string{
|
||||
"empty_list.#": "0",
|
||||
"empty_map.%": "0",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
for _, key := range []string{
|
||||
"empty_list.#",
|
||||
"empty_map.%",
|
||||
"missing_list.#",
|
||||
"missing_map.%",
|
||||
} {
|
||||
t.Run(key, func(t *testing.T) {
|
||||
check := TestCheckNoResourceAttr("test_resource", key)
|
||||
if err := check(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ Use the navigation to the left to find available providers by type or scroll
|
|||
down to see all providers.
|
||||
|
||||
<table class="table">
|
||||
|
||||
<tr>
|
||||
<td><a href="/docs/providers/acme/index.html">ACME</a></td>
|
||||
<td><a href="/docs/providers/alicloud/index.html">Alicloud</a></td>
|
||||
|
@ -29,157 +30,157 @@ down to see all providers.
|
|||
<tr>
|
||||
<td><a href="/docs/providers/arukas/index.html">Arukas</a></td>
|
||||
<td><a href="/docs/providers/aws/index.html">AWS</a></td>
|
||||
<td><a href="/docs/providers/azurerm/index.html">Azure</a></td>
|
||||
<td><a href="/docs/providers/azuread/index.html">Azure Active Directory</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/azurerm/index.html">Azure</a></td>
|
||||
<td><a href="/docs/providers/azurestack/index.html">Azure Stack</a></td>
|
||||
<td><a href="/docs/providers/bitbucket/index.html">Bitbucket</a></td>
|
||||
<td><a href="/docs/providers/brightbox/index.html">Brightbox</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/brightbox/index.html">Brightbox</a></td>
|
||||
<td><a href="/docs/providers/clc/index.html">CenturyLinkCloud</a></td>
|
||||
<td><a href="/docs/providers/chef/index.html">Chef</a></td>
|
||||
<td><a href="/docs/providers/circonus/index.html">Circonus</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/circonus/index.html">Circonus</a></td>
|
||||
<td><a href="/docs/providers/cloudflare/index.html">Cloudflare</a></td>
|
||||
<td><a href="/docs/providers/cloudscale/index.html">CloudScale.ch</a></td>
|
||||
<td><a href="/docs/providers/cloudstack/index.html">CloudStack</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/cloudstack/index.html">CloudStack</a></td>
|
||||
<td><a href="/docs/providers/cobbler/index.html">Cobbler</a></td>
|
||||
<td><a href="/docs/providers/consul/index.html">Consul</a></td>
|
||||
<td><a href="/docs/providers/datadog/index.html">Datadog</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/datadog/index.html">Datadog</a></td>
|
||||
<td><a href="/docs/providers/do/index.html">DigitalOcean</a></td>
|
||||
<td><a href="/docs/providers/dns/index.html">DNS</a></td>
|
||||
<td><a href="/docs/providers/dme/index.html">DNSMadeEasy</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/dme/index.html">DNSMadeEasy</a></td>
|
||||
<td><a href="/docs/providers/dnsimple/index.html">DNSimple</a></td>
|
||||
<td><a href="/docs/providers/docker/index.html">Docker</a></td>
|
||||
<td><a href="/docs/providers/dyn/index.html">Dyn</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/dyn/index.html">Dyn</a></td>
|
||||
<td><a href="/docs/providers/external/index.html">External</a></td>
|
||||
<td><a href="/docs/providers/bigip/index.html">F5 BIG-IP</a></td>
|
||||
<td><a href="/docs/providers/fastly/index.html">Fastly</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/fastly/index.html">Fastly</a></td>
|
||||
<td><a href="/docs/providers/flexibleengine/index.html">FlexibleEngine</a></td>
|
||||
<td><a href="/docs/providers/github/index.html">GitHub</a></td>
|
||||
<td><a href="/docs/providers/gitlab/index.html">Gitlab</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/gitlab/index.html">Gitlab</a></td>
|
||||
<td><a href="/docs/providers/google/index.html">Google Cloud</a></td>
|
||||
<td><a href="/docs/providers/grafana/index.html">Grafana</a></td>
|
||||
<td><a href="/docs/providers/hedvig/index.html">Hedvig</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/hedvig/index.html">Hedvig</a></td>
|
||||
<td><a href="/docs/providers/helm/index.html">Helm</a></td>
|
||||
<td><a href="/docs/providers/heroku/index.html">Heroku</a></td>
|
||||
<td><a href="/docs/providers/hcloud/index.html">Hetzner Cloud</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/hcloud/index.html">Hetzner Cloud</a></td>
|
||||
<td><a href="/docs/providers/http/index.html">HTTP</a></td>
|
||||
<td><a href="/docs/providers/huaweicloud/index.html">HuaweiCloud</a></td>
|
||||
<td><a href="/docs/providers/icinga2/index.html">Icinga2</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/icinga2/index.html">Icinga2</a></td>
|
||||
<td><a href="/docs/providers/ignition/index.html">Ignition</a></td>
|
||||
<td><a href="/docs/providers/influxdb/index.html">InfluxDB</a></td>
|
||||
<td><a href="/docs/providers/kubernetes/index.html">Kubernetes</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/kubernetes/index.html">Kubernetes</a></td>
|
||||
<td><a href="/docs/providers/librato/index.html">Librato</a></td>
|
||||
<td><a href="/docs/providers/linode/index.html">Linode</a></td>
|
||||
<td><a href="/docs/providers/local/index.html">Local</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/local/index.html">Local</a></td>
|
||||
<td><a href="/docs/providers/logentries/index.html">Logentries</a></td>
|
||||
<td><a href="/docs/providers/logicmonitor/index.html">LogicMonitor</a></td>
|
||||
<td><a href="/docs/providers/mailgun/index.html">Mailgun</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/mailgun/index.html">Mailgun</a></td>
|
||||
<td><a href="/docs/providers/mysql/index.html">MySQL</a></td>
|
||||
<td><a href="/docs/providers/netlify/index.html">Netlify</a></td>
|
||||
<td><a href="/docs/providers/newrelic/index.html">New Relic</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/newrelic/index.html">New Relic</a></td>
|
||||
<td><a href="/docs/providers/nomad/index.html">Nomad</a></td>
|
||||
<td><a href="/docs/providers/ns1/index.html">NS1</a></td>
|
||||
<td><a href="/docs/providers/null/index.html">Null</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/null/index.html">Null</a></td>
|
||||
<td><a href="/docs/providers/nutanix/index.html">Nutanix</a></td>
|
||||
<td><a href="/docs/providers/oneandone/index.html">1&1</a></td>
|
||||
<td><a href="/docs/providers/openstack/index.html">OpenStack</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/openstack/index.html">OpenStack</a></td>
|
||||
<td><a href="/docs/providers/opentelekomcloud/index.html">OpenTelekomCloud</a></td>
|
||||
<td><a href="/docs/providers/opsgenie/index.html">OpsGenie</a></td>
|
||||
<td><a href="/docs/providers/oci/index.html">Oracle Cloud Infrastructure</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/oci/index.html">Oracle Cloud Infrastructure</a></td>
|
||||
<td><a href="/docs/providers/oraclepaas/index.html">Oracle Cloud Platform</a></td>
|
||||
<td><a href="/docs/providers/opc/index.html">Oracle Public Cloud</a></td>
|
||||
<td><a href="/docs/providers/ovh/index.html">OVH</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/ovh/index.html">OVH</a></td>
|
||||
<td><a href="/docs/providers/packet/index.html">Packet</a></td>
|
||||
<td><a href="/docs/providers/pagerduty/index.html">PagerDuty</a></td>
|
||||
<td><a href="/docs/providers/panos/index.html">Palo Alto Networks</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/panos/index.html">Palo Alto Networks</a></td>
|
||||
<td><a href="/docs/providers/postgresql/index.html">PostgreSQL</a></td>
|
||||
<td><a href="/docs/providers/powerdns/index.html">PowerDNS</a></td>
|
||||
<td><a href="/docs/providers/profitbricks/index.html">ProfitBricks</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/profitbricks/index.html">ProfitBricks</a></td>
|
||||
<td><a href="/docs/providers/rabbitmq/index.html">RabbitMQ</a></td>
|
||||
<td><a href="/docs/providers/rancher/index.html">Rancher</a></td>
|
||||
<td><a href="/docs/providers/random/index.html">Random</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/random/index.html">Random</a></td>
|
||||
<td><a href="/docs/providers/rightscale/index.html">RightScale</a></td>
|
||||
<td><a href="/docs/providers/rundeck/index.html">Rundeck</a></td>
|
||||
<td><a href="/docs/providers/runscope/index.html">RunScope</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/runscope/index.html">RunScope</a></td>
|
||||
<td><a href="/docs/providers/scaleway/index.html">Scaleway</a></td>
|
||||
<td><a href="/docs/providers/selvpc/index.html">Selectel</a></td>
|
||||
<td><a href="/docs/providers/skytap/index.html">Skytap</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/skytap/index.html">Skytap</a></td>
|
||||
<td><a href="/docs/providers/softlayer/index.html">SoftLayer</a></td>
|
||||
<td><a href="/docs/providers/statuscake/index.html">StatusCake</a></td>
|
||||
<td><a href="/docs/providers/spotinst/index.html">Spotinst</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/spotinst/index.html">Spotinst</a></td>
|
||||
<td><a href="/docs/providers/telefonicaopencloud/index.html">TelefonicaOpenCloud</a></td>
|
||||
<td><a href="/docs/providers/template/index.html">Template</a></td>
|
||||
<td><a href="/docs/providers/tencentcloud/index.html">TencentCloud</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/tencentcloud/index.html">TencentCloud</a></td>
|
||||
<td><a href="/docs/providers/terraform/index.html">Terraform</a></td>
|
||||
<td><a href="/docs/providers/tfe/index.html">Terraform Enterprise</a></td>
|
||||
<td><a href="/docs/providers/tls/index.html">TLS</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/tls/index.html">TLS</a></td>
|
||||
<td><a href="/docs/providers/triton/index.html">Triton</a></td>
|
||||
<td><a href="/docs/providers/ucloud/index.html">UCloud</a></td>
|
||||
<td><a href="/docs/providers/ultradns/index.html">UltraDNS</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/ultradns/index.html">UltraDNS</a></td>
|
||||
<td><a href="/docs/providers/vault/index.html">Vault</a></td>
|
||||
<td><a href="/docs/providers/vcd/index.html">VMware vCloud Director</a></td>
|
||||
<td><a href="/docs/providers/nsxt/index.html">VMware NSX-T</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="/docs/providers/nsxt/index.html">VMware NSX-T</a></td>
|
||||
<td><a href="/docs/providers/vsphere/index.html">VMware vSphere</a></td>
|
||||
<td><a></a></td>
|
||||
<td><a></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
Loading…
Reference in New Issue