Merge pull request #406 from catsby/heroku-orgs-maps
Proposal to change Heroku organization TypeString to a TypeList
This commit is contained in:
commit
98f104dde6
|
@ -95,17 +95,40 @@ func resourceHerokuApp() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
"organization": &schema.Schema{
|
"organization": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
|
||||||
Description: "Name of Organization to create application in. Leave blank for personal apps.",
|
Description: "Name of Organization to create application in. Leave blank for personal apps.",
|
||||||
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
Elem: &schema.Resource{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"name": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
"locked": &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
"personal": &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func switchHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
|
func switchHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
if _, ok := d.GetOk("organization"); ok {
|
orgCount := d.Get("organization.#").(int)
|
||||||
|
if orgCount > 1 {
|
||||||
|
return fmt.Errorf("Error Creating Heroku App: Only 1 Heroku Organization is permitted")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := d.GetOk("organization.0.name"); ok {
|
||||||
return resourceHerokuOrgAppCreate(d, meta)
|
return resourceHerokuOrgAppCreate(d, meta)
|
||||||
} else {
|
} else {
|
||||||
return resourceHerokuAppCreate(d, meta)
|
return resourceHerokuAppCreate(d, meta)
|
||||||
|
@ -157,12 +180,26 @@ func resourceHerokuOrgAppCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
client := meta.(*heroku.Service)
|
client := meta.(*heroku.Service)
|
||||||
// Build up our creation options
|
// Build up our creation options
|
||||||
opts := heroku.OrganizationAppCreateOpts{}
|
opts := heroku.OrganizationAppCreateOpts{}
|
||||||
if v, ok := d.GetOk("organization"); ok {
|
|
||||||
|
if v := d.Get("organization.0.name"); v != nil {
|
||||||
vs := v.(string)
|
vs := v.(string)
|
||||||
log.Printf("[DEBUG] App name: %s", vs)
|
log.Printf("[DEBUG] Organization name: %s", vs)
|
||||||
opts.Organization = &vs
|
opts.Organization = &vs
|
||||||
}
|
}
|
||||||
if v, ok := d.GetOk("name"); ok {
|
|
||||||
|
if v := d.Get("organization.0.personal"); v != nil {
|
||||||
|
vs := v.(bool)
|
||||||
|
log.Printf("[DEBUG] Organization Personal: %s", vs)
|
||||||
|
opts.Personal = &vs
|
||||||
|
}
|
||||||
|
|
||||||
|
if v := d.Get("organization.0.locked"); v != nil {
|
||||||
|
vs := v.(bool)
|
||||||
|
log.Printf("[DEBUG] Organization locked: %s", vs)
|
||||||
|
opts.Locked = &vs
|
||||||
|
}
|
||||||
|
|
||||||
|
if v := d.Get("name"); v != nil {
|
||||||
vs := v.(string)
|
vs := v.(string)
|
||||||
log.Printf("[DEBUG] App name: %s", vs)
|
log.Printf("[DEBUG] App name: %s", vs)
|
||||||
opts.Name = &vs
|
opts.Name = &vs
|
||||||
|
|
Loading…
Reference in New Issue