Skip to content
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

Heroku addons configuration #31

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/heroku_san/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,20 @@
task :config do
each_heroku_app do |name, app, repo, config|
(config).each do |var, value|
sh "heroku config:add --app #{app} #{var}=#{value}"
sh "heroku config:add --app #{app} #{var}=\"#{value}\""
end
end
end

desc 'Add addons to each application.'
task :addons do
each_heroku_app do |name, app, repo, config, addons|
(addons.split(',')).each do |addon|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work for you? addons is populated with a Hash if I follow the example.yml:

addons:
  custom_domains: "basic"

Even if I specify as an Array:

addons:
- custom_domains:basic

Arrays don't implement split.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a matter of fact, it's actually set for using a one-liner string, mind you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be:

addons.each do |addon|

with heroku.yml:

addons:
- custom_domains:basic
- cron:daily

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some heroku addons don't have the second part (the :foopart). How could you handle them with either an Array or a Hash? I felt that, because of this requirement, String was the only way...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I described above, the addons key has a value that is an Array of strings

addons:
- custom_error_pages
- cron:daily

Would yield:

addons = @app_settings[name]['addons'] || []
=> addons = [ "custom_error_pages", "cron:daily" ]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are right. Will be nicer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed it up: bryan-ash@8c11593

sh "heroku addons:add --app #{app} #{addon}"
end
end
end

desc 'Runs a rake task remotely'
task :rake, :task do |t, args|
each_heroku_app do |name, app, repo|
Expand Down Expand Up @@ -251,7 +260,8 @@ def each_heroku_app
@heroku_apps.each do |name|
app = @app_settings[name]['app']
config = @app_settings[name]['config'] || []
yield(name, app, "git@heroku.com:#{app}.git", config)
addons = @app_settings[name]['addons'] || []
yield(name, app, "git@heroku.com:#{app}.git", config, addons)
end
puts
else
Expand Down
4 changes: 4 additions & 0 deletions lib/templates/heroku.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ production:
config:
BUNDLE_WITHOUT: "development:test"
GOOGLE_ANALYTICS: "UA-12345678-1"
addons: &addons
cron: "daily"
ssl: "piggyback"

staging:
app: awesomeapp-staging
config: &default
BUNDLE_WITHOUT: "development:test"
addons: *addons

demo:
app: awesomeapp-demo
Expand Down