Skip to content

Commit ca24c6f

Browse files
committed
Handle botched container host provisions a bit better
1 parent 2376f2c commit ca24c6f

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ The following arguments are supported:
7676

7777
* `uaa_password` - (Optional) The HSDP CF UAA password.
7878

79+
* `uaa_url` - (Optional) The URL of the UAA authentication service
80+
7981
* `org_id` - (Optional) Your IAM root ORG id as provided by HSDP
8082

8183
* `shared_key` - (Optional) The shared key as provided by HSDP. Actions which require API signing will not work if this value is missing.

docs/resources/metrics_autoscaler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# hsdp_metrics_autoscaler
22
Manages HSDP Metrics Autoscaler settings for Cloudfoundry applications hosted in an HSDP CF space.
33

4-
> This resource is only available when the `region` and `uaa_*` keys are set in the provider config
4+
~> **NOTE:** This resource is only available when the `region` and `uaa_*` keys are set in the provider config
55

66
[Metrics Service Broker](https://www.hsdp.io/documentation/metrics-service-broker)
77

hsdp/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Config struct {
2424
RetryMax int
2525
UAAUsername string
2626
UAAPassword string
27+
UAAURL string
2728

2829
iamClient *iam.Client
2930
cartelClient *cartel.Client

hsdp/provider.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ func Provider(build string) terraform.ResourceProvider {
9595
Description: descriptions["uaa_password"],
9696
RequiredWith: []string{"uaa_username"},
9797
},
98+
"uaa_url": {
99+
Type: schema.TypeString,
100+
Optional: true,
101+
Description: descriptions["uaa_url"],
102+
},
98103
"shared_key": {
99104
Type: schema.TypeString,
100105
Optional: true,
@@ -209,6 +214,7 @@ func init() {
209214
"retry_max": "Maximum number of retries for API requests",
210215
"uaa_username": "The username of the Cloudfoundry account to use",
211216
"uaa_password": "The password of the Cloudfoundry account to use",
217+
"uaa_url": "The URL of the UAA server",
212218
}
213219
}
214220

@@ -239,6 +245,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
239245
config.RetryMax = d.Get("retry_max").(int)
240246
config.UAAUsername = d.Get("uaa_username").(string)
241247
config.UAAPassword = d.Get("uaa_password").(string)
248+
config.UAAURL = d.Get("uaa_url").(string)
242249

243250
config.setupIAMClient()
244251
config.setupS3CredsClient()

hsdp/resource_container_host.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
77
"github.com/philips-software/go-hsdp-api/cartel"
88
"log"
9+
"net/http"
910
"time"
1011
)
1112

@@ -280,8 +281,13 @@ func resourceContainerHostRead(d *schema.ResourceData, m interface{}) error {
280281
}
281282

282283
tagName := d.Get("name").(string)
283-
state, _, err := client.GetDeploymentState(tagName)
284+
state, resp, err := client.GetDeploymentState(tagName)
284285
if err != nil {
286+
if resp != nil && resp.StatusCode == http.StatusBadRequest {
287+
// State not found, probably a botched provision :(
288+
d.SetId("")
289+
return nil
290+
}
285291
return err
286292
}
287293
if state != "succeeded" {

0 commit comments

Comments
 (0)