-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Starting point for adding Organization app support for Heroku Provider #389
Conversation
Rebased on master. Not sure why tests are failing on Travis, they pass locally 🐼 |
You can use |
|
||
"organization": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing that changing this would require a new app to be created? i.e. you can't "update" an app to be part of an organization? If so, you need to set ForceNew: true
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, the Platform API seems limited here; you can't use it to move an app to an organization. There's App Transfering, but that requires a human on the other side.
Added ForceNew: true
in 5fe2593.
This looks great! Given the API of the Heroku lib, I don't think it is very possible to DRY up the create method unfortunately. With the given fixes, I'd be happy to merge this in. |
@mitchellh I've made updates based on your feedback, thanks! I've also pushed another commit on my fork from a separate branch, based on this one, that changes |
Woot, made it in the 11th hour in 0.3. :) |
Starting point for adding Organization app support for Heroku Provider
Yay 🤘 I'll send another PR for the organization string -> map idea |
💖 |
This is a hack-ish first pass at adding Organization app support (1,2) to the Heroku Provider.
This PR is meant as a starting point for discussion because frankly it's ugly :)
With this PR, you can create an app under and Organization by adding the org name to the resource:
The intent here is to conditionally return the right method to create the app, depending on if the
organization
field was found in the schema. The name is not the best :/For the actual conditional logic:
+ if len(isOrg.(string)) != 0 {
This seems horrible, but a previous check for
nil
was wrong because theorganization
field seems to get the default string value""
(I think).+func resourceHerokuOrgAppCreate(d *schema.ResourceData, meta interface{}) error {
I copy-pasted 99% of this method from
resourceHerokuAppCreate
, only adding/changing org specific things, so there's ugly duplication. Still being a Go novice, I wasn't sure how to separate the similar logic and change the methods to be specific to their cases.I wasn't sure how far to go with the Organization support, as there are other fields like
locked
,joined
, etc. Maybe theorganization
should be a map in the configuration, like so?I would really like feedback and guidance on DRY/cleanup suggestions here, as well as guidance on how to write a test for this. I've verified it works, but I'm not sure where to start on the testing :/