@@ -42,7 +42,7 @@ func (a *application) Update() error {
4242
4343func resourceHerokuApp () * schema.Resource {
4444 return & schema.Resource {
45- Create : switchHerokuAppCreate ,
45+ Create : switchHerokuAppCreate ,
4646 Read : resourceHerokuAppRead ,
4747 Update : resourceHerokuAppUpdate ,
4848 Delete : resourceHerokuAppDelete ,
@@ -94,21 +94,22 @@ func resourceHerokuApp() *schema.Resource {
9494 Computed : true ,
9595 },
9696
97- "organization" : & schema.Schema {
98- Type : schema .TypeString ,
99- Optional : true ,
100- },
97+ "organization" : & schema.Schema {
98+ Type : schema .TypeString ,
99+ Optional : true ,
100+ ForceNew : true ,
101+ },
101102 },
102103 }
103104}
104105
105106func switchHerokuAppCreate (d * schema.ResourceData , meta interface {}) error {
106- isOrg := d .Get ("organization" )
107- if len (isOrg .(string )) != 0 {
108- return resourceHerokuOrgAppCreate (d , meta )
109- } else {
110- return resourceHerokuAppCreate (d , meta )
111- }
107+ isOrg := d .Get ("organization" )
108+ if len (isOrg .(string )) != 0 {
109+ return resourceHerokuOrgAppCreate (d , meta )
110+ } else {
111+ return resourceHerokuAppCreate (d , meta )
112+ }
112113}
113114
114115func resourceHerokuAppCreate (d * schema.ResourceData , meta interface {}) error {
@@ -153,47 +154,47 @@ func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
153154}
154155
155156func resourceHerokuOrgAppCreate (d * schema.ResourceData , meta interface {}) error {
156- client := meta .(* heroku.Service )
157- // Build up our creation options
158- opts := heroku.OrganizationAppCreateOpts {}
159- if v := d .Get ("organization" ); v != nil {
160- vs := v .(string )
161- log .Printf ("[DEBUG] App name: %s" , vs )
162- opts .Organization = & vs
163- }
164- if v := d .Get ("name" ); v != nil {
165- vs := v .(string )
166- log .Printf ("[DEBUG] App name: %s" , vs )
167- opts .Name = & vs
168- }
169- if v := d .Get ("region" ); v != nil {
170- vs := v .(string )
171- log .Printf ("[DEBUG] App region: %s" , vs )
172- opts .Region = & vs
173- }
174- if v := d .Get ("stack" ); v != nil {
175- vs := v .(string )
176- log .Printf ("[DEBUG] App stack: %s" , vs )
177- opts .Stack = & vs
178- }
179-
180- log .Printf ("[DEBUG] Creating Heroku app..." )
181- a , err := client .OrganizationAppCreate (opts )
182- if err != nil {
183- return err
184- }
185-
186- d .SetId (a .Name )
187- log .Printf ("[INFO] App ID: %s" , d .Id ())
188-
189- if v := d .Get ("config_vars" ); v != nil {
190- err = update_config_vars (d .Id (), client , nil , v .([]interface {}))
191- if err != nil {
192- return err
193- }
194- }
195-
196- return resourceHerokuAppRead (d , meta )
157+ client := meta .(* heroku.Service )
158+ // Build up our creation options
159+ opts := heroku.OrganizationAppCreateOpts {}
160+ if v := d .Get ("organization" ); v != nil {
161+ vs := v .(string )
162+ log .Printf ("[DEBUG] App name: %s" , vs )
163+ opts .Organization = & vs
164+ }
165+ if v := d .Get ("name" ); v != nil {
166+ vs := v .(string )
167+ log .Printf ("[DEBUG] App name: %s" , vs )
168+ opts .Name = & vs
169+ }
170+ if v := d .Get ("region" ); v != nil {
171+ vs := v .(string )
172+ log .Printf ("[DEBUG] App region: %s" , vs )
173+ opts .Region = & vs
174+ }
175+ if v := d .Get ("stack" ); v != nil {
176+ vs := v .(string )
177+ log .Printf ("[DEBUG] App stack: %s" , vs )
178+ opts .Stack = & vs
179+ }
180+
181+ log .Printf ("[DEBUG] Creating Heroku app..." )
182+ a , err := client .OrganizationAppCreate (opts )
183+ if err != nil {
184+ return err
185+ }
186+
187+ d .SetId (a .Name )
188+ log .Printf ("[INFO] App ID: %s" , d .Id ())
189+
190+ if v := d .Get ("config_vars" ); v != nil {
191+ err = update_config_vars (d .Id (), client , nil , v .([]interface {}))
192+ if err != nil {
193+ return err
194+ }
195+ }
196+
197+ return resourceHerokuAppRead (d , meta )
197198}
198199
199200func resourceHerokuAppRead (d * schema.ResourceData , meta interface {}) error {
0 commit comments