heroku_builder 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e664bec8e4de6657ab2d62b84e6eb2d848c3b469
4
- data.tar.gz: a8aa0f35d53a9b14d52b6bdd5493f87733f3ec3a
3
+ metadata.gz: ff37f31cd4b0b4a614874c42e13e662969afae90
4
+ data.tar.gz: aaaab60a07f9056f537c5a3af0e1341b24a97adb
5
5
  SHA512:
6
- metadata.gz: 283e5e40dcd3ee6ec43e692ea53bd06c587d491c6068b0dbb4ba1a2fac3158447b66ae9c4a2d84bc4516551b7195cb3a7957a98e0225595150f2475be0970db7
7
- data.tar.gz: 35ea3e3cf41ed6163fc2f8ed16f6dceb3dbe00d5b6825f924d9438d1047d6cf3f8ea226a7552142b851206e5816ab61c6da041b4ccc0c9b045fe14d99813bbde
6
+ metadata.gz: 0f37aa12b4873769b0a712909c72d675645a524cd1329bd5992e39e2769de28adc5e645643174a9a5477223beb8d753300199f6f28cb828e8a6ddff731dd4a33
7
+ data.tar.gz: 078f977a07db1a639b5f9b890a4158c4954e4455f16e959de6730f5f94448f42fad81891387059caf53026e9bad98ea911413d7e936a128fb3818b2223c0fd8c
data/README.md CHANGED
@@ -12,7 +12,7 @@ Treating configuration as code allows for peer review, versioning, and a histori
12
12
 
13
13
  ## Installation
14
14
 
15
- Add this line to your application's Gemfile:
15
+ Add this line to your Rails application's Gemfile:
16
16
 
17
17
  ```ruby
18
18
  gem 'heroku_builder'
@@ -44,7 +44,6 @@ When you open `config/heroku.yml`, you'll see something like this:
44
44
  staging:
45
45
  app:
46
46
  name: my-heroku-app-name-staging
47
- git_repo: git@github.com:foo/my-heroku-app-name
48
47
  git_branch: staging
49
48
  config_vars: []
50
49
  addons: []
@@ -55,7 +54,6 @@ staging:
55
54
  production:
56
55
  app:
57
56
  name: my-heroku-app-name
58
- git_repo: git@github.com:foo/my-heroku-app-name
59
57
  git_branch: master
60
58
  config_vars: []
61
59
  addons: []
@@ -76,7 +74,6 @@ Would apply the configuration for the `staging` environment.
76
74
 
77
75
  The `app` sections provides settings particular to the application.
78
76
  * `name` - the Heroku application name. The application will be created unless it already exists on Heroku.
79
- * `git_repo` - the repository the project code is kept in. Code will be checked out from this repository as part of the deploy process, so you'll need at least read permission on the repo to deploy code to Heroku.
80
77
  * `git_branch` - the branch of the `git_repo` repo that you wish to deploy from.
81
78
 
82
79
  The `config_vars` setting allows you to set Config Vars for a particular environment. These can be applied as follows:
@@ -145,20 +142,28 @@ HEROKU_API_KEY=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxx rake builder:staging:apply
145
142
 
146
143
  ### Running Rake Tasks
147
144
 
148
- Heroku Builder currently has two actions: `apply` and `deploy`. Apply will:
145
+ Heroku Builder currently has two actions: `apply` and `deploy`.
149
146
 
150
- * Create the application, if it has not been created
151
- * Set Config-vars (if there are changes)
152
- * Deploy code (if there are changes)
153
- * Configure Add-ons (if there are changes)
154
- * Configure Resources (if there are changes)
147
+ #### Apply
155
148
 
156
- As `apply` only adds or updates when your `heroku.yml` file has changes, it's safe to always use `apply` to deploy code. Alternatively, you can just run the `deploy` portion. Deploy will:
149
+ `$ rake builder:staging:apply`
157
150
 
158
- * Switch to the branch for that environment
159
- * Pull down any remote changes
160
- * Create a remote for Heroku, if the remote is not present
161
- * Push to that remote
151
+ 1. Creates the application, if it has not been created
152
+ 2. Sets Config-vars (if there are changes)
153
+ 3. Deploys code (if there are changes)
154
+ 4. Configures Add-ons (if there are changes)
155
+ 5. Configures Resources (if there are changes)
156
+
157
+ As `apply` only adds or updates when your `heroku.yml` file has changes, it's safe to always use `apply` to deploy code. Alternatively, you can just run the `deploy` portion.
158
+
159
+ #### Deploy
160
+
161
+ `$ rake builder:staging:deploy`
162
+
163
+ 1. Switches to the branch for that environment
164
+ 2. Pulls down any remote changes
165
+ 3. Creates a remote for Heroku, if the remote is not present
166
+ 4. Pushes to that remote
162
167
 
163
168
  The environments defined in your `heroku.yml` file provide scope for the Heroku Builder rake tasks. If you have the following:
164
169
 
@@ -185,7 +190,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
185
190
 
186
191
  ## Contributing
187
192
 
188
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/heroku_builder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
193
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jvanderhoof/heroku_builder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
189
194
 
190
195
 
191
196
  ## License
@@ -38,4 +38,6 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency 'vcr', '~> 2.9.3'
39
39
  spec.add_development_dependency 'simplecov', '~> 0.10'
40
40
  spec.add_development_dependency 'dotenv'
41
+ spec.add_development_dependency 'webmock'
42
+ spec.add_development_dependency 'pry'
41
43
  end
@@ -1,12 +1,13 @@
1
1
  require 'platform-api'
2
2
  require 'git'
3
+ require 'hashdiff'
3
4
 
4
5
  require 'heroku_builder/version'
5
6
  require 'heroku_builder/base'
6
7
  require 'heroku_builder/service'
7
8
  require 'heroku_builder/app'
8
- require 'heroku_builder/env_vars'
9
- require 'heroku_builder/add_ons'
9
+ require 'heroku_builder/env_var'
10
+ require 'heroku_builder/add_on'
10
11
  require 'heroku_builder/deployment'
11
12
  require 'heroku_builder/resource'
12
13
 
@@ -1,12 +1,12 @@
1
1
  # Add Ons
2
2
  module HerokuBuilder
3
- class AddOns < Base
4
- def addons(name)
3
+ class AddOn < Base
4
+ def addon_list(name)
5
5
  conn.addon.list_by_app(name)
6
6
  end
7
7
 
8
8
  def addon_exists?(name, addon_name)
9
- conn.addon.list_by_app(name).any? do |a|
9
+ addon_list(name).any? do |a|
10
10
  # names appear to be stored in two different locations depending on the type
11
11
  (!addon_name.include?(':') && a['addon_service']['name'] == addon_name) ||
12
12
  a['plan']['name'] == addon_name
@@ -16,7 +16,6 @@ module HerokuBuilder
16
16
  def set_addons(name, addons)
17
17
  addons.each do |addon|
18
18
  unless addon_exists?(name, addon)
19
- puts "... adding #{addon}"
20
19
  conn.addon.create(name, 'plan' => addon)
21
20
  end
22
21
  end
@@ -5,12 +5,16 @@ module HerokuBuilder
5
5
  end
6
6
 
7
7
  def find_or_create_app(name)
8
- return if app_exists?(name)
9
- conn.app.create(name: name, region: 'us', stack: 'cedar')
8
+ return app(name) if app_exists?(name)
9
+ conn.app.create('name' => name, 'region' => 'us', 'stack' => 'cedar-14')
10
10
  end
11
11
 
12
12
  def app(name)
13
- @app ||= conn.app.info(name)
13
+ if app_exists?(name)
14
+ conn.app.info(name)
15
+ else
16
+ {}
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -2,12 +2,12 @@
2
2
  module HerokuBuilder
3
3
  class Deployment < Base
4
4
  def remote_exists?(branch)
5
- git.remotes.detect { |remote| remote.name == branch }.nil?
5
+ git.remotes.any? { |remote| remote.name == branch }
6
6
  end
7
7
 
8
8
  def push(name, branch, environment)
9
9
  remote_branch = "heroku-#{environment}"
10
- if remote_exists?(remote_branch)
10
+ unless remote_exists?(remote_branch)
11
11
  git.add_remote(remote_branch, App.new.app(name)['git_url'])
12
12
  end
13
13
  git.push(remote_branch, "#{branch}:master", force: true)
@@ -1,7 +1,7 @@
1
1
  # ENV variables
2
2
  module HerokuBuilder
3
- class EnvVars < Base
4
- def config_vars(name)
3
+ class EnvVar < Base
4
+ def get_config_vars(name)
5
5
  @config_vars ||= conn.config_var.info(name)
6
6
  end
7
7
 
@@ -21,7 +21,7 @@ module HerokuBuilder
21
21
  end
22
22
 
23
23
  def config_env_changes(name, config_vars)
24
- diff_config_vars(config_vars(name), config_vars)
24
+ diff_config_vars(get_config_vars(name), config_vars)
25
25
  end
26
26
  end
27
27
  end
@@ -14,7 +14,7 @@ module HerokuBuilder
14
14
 
15
15
  def self.update_env_vars(name, environment)
16
16
  env_vars = config_from_environment(environment)['config_vars']
17
- EnvVars.new.set_config_vars(name, env_vars)
17
+ EnvVar.new.set_config_vars(name, env_vars)
18
18
  end
19
19
 
20
20
  def self.run_deployment(name, environment)
@@ -24,7 +24,7 @@ module HerokuBuilder
24
24
 
25
25
  def self.update_addons(name, environment)
26
26
  addons = config_from_environment(environment)['addons']
27
- AddOns.new.set_addons(name, addons)
27
+ AddOn.new.set_addons(name, addons)
28
28
  end
29
29
 
30
30
  def self.update_resources(name, environment)
@@ -1,3 +1,3 @@
1
1
  module HerokuBuilder
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
@@ -18,11 +18,6 @@ namespace :builder do
18
18
  HerokuBuilder::Service.deploy(env)
19
19
  end
20
20
 
21
- # task :plan do
22
- # changes('backstage').each do |change|
23
- # puts change
24
- # end
25
- # end
26
21
  end
27
22
  end
28
23
  end
@@ -37,10 +32,11 @@ namespace :builder do
37
32
  env_config = {
38
33
  'app' => {
39
34
  'name' => 'my-heroku-app-name',
40
- 'git_repo' => 'git@github.com:foo/my-heroku-app-name',
41
- 'git_branch' => 'master'
35
+ 'git_branch' => 'master',
42
36
  },
43
- 'config_vars' => [],
37
+ 'config_vars' => [
38
+ 'BUILDPACK_URL' => 'https://github.com/ddollar/heroku-buildpack-multi.git'
39
+ ],
44
40
  'addons' => [],
45
41
  'resources' => {
46
42
  'web' => {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Vanderhoof
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-15 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: platform-api
@@ -136,6 +136,34 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: webmock
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  description: 'Heroku Builder allows for straight forward configuration of your multi
140
168
  (or single) stage Heroku application as well as dead simple deployment. It uses
141
169
  a YAML configuration to manage a multi-environment configuration, including: configuration
@@ -158,11 +186,11 @@ files:
158
186
  - bin/setup
159
187
  - heroku_builder.gemspec
160
188
  - lib/heroku_builder.rb
161
- - lib/heroku_builder/add_ons.rb
189
+ - lib/heroku_builder/add_on.rb
162
190
  - lib/heroku_builder/app.rb
163
191
  - lib/heroku_builder/base.rb
164
192
  - lib/heroku_builder/deployment.rb
165
- - lib/heroku_builder/env_vars.rb
193
+ - lib/heroku_builder/env_var.rb
166
194
  - lib/heroku_builder/resource.rb
167
195
  - lib/heroku_builder/service.rb
168
196
  - lib/heroku_builder/version.rb