dpl 2.0.0.alpha.14 → 2.0.0.beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile.lock +37 -37
  4. data/NOTES.md +0 -119
  5. data/README.md +56 -5
  6. data/dpl-chef_supermarket-1.10.14.gem +0 -0
  7. data/lib/dpl/helper/interpolate.rb +24 -1
  8. data/lib/dpl/provider.rb +10 -0
  9. data/lib/dpl/provider/dsl.rb +25 -0
  10. data/lib/dpl/providers.rb +1 -0
  11. data/lib/dpl/providers/anynines.rb +2 -0
  12. data/lib/dpl/providers/azure_web_apps.rb +2 -0
  13. data/lib/dpl/providers/bintray.rb +2 -0
  14. data/lib/dpl/providers/bluemixcloudfoundry.rb +3 -1
  15. data/lib/dpl/providers/boxfuse.rb +2 -0
  16. data/lib/dpl/providers/cargo.rb +3 -1
  17. data/lib/dpl/providers/cloud66.rb +2 -0
  18. data/lib/dpl/providers/cloudfiles.rb +2 -0
  19. data/lib/dpl/providers/cloudformation.rb +1 -0
  20. data/lib/dpl/providers/cloudfoundry.rb +2 -0
  21. data/lib/dpl/providers/codedeploy.rb +7 -3
  22. data/lib/dpl/providers/convox.rb +2 -0
  23. data/lib/dpl/providers/datica.rb +2 -0
  24. data/lib/dpl/providers/elasticbeanstalk.rb +2 -0
  25. data/lib/dpl/providers/engineyard.rb +2 -0
  26. data/lib/dpl/providers/firebase.rb +2 -0
  27. data/lib/dpl/providers/flynn.rb +33 -0
  28. data/lib/dpl/providers/gae.rb +2 -0
  29. data/lib/dpl/providers/gcs.rb +2 -0
  30. data/lib/dpl/providers/gleis.rb +2 -0
  31. data/lib/dpl/providers/hackage.rb +2 -0
  32. data/lib/dpl/providers/hephy.rb +2 -0
  33. data/lib/dpl/providers/heroku.rb +2 -0
  34. data/lib/dpl/providers/heroku/api.rb +1 -1
  35. data/lib/dpl/providers/heroku/git.rb +1 -1
  36. data/lib/dpl/providers/lambda.rb +4 -2
  37. data/lib/dpl/providers/launchpad.rb +2 -0
  38. data/lib/dpl/providers/netlify.rb +2 -0
  39. data/lib/dpl/providers/npm.rb +2 -0
  40. data/lib/dpl/providers/openshift.rb +2 -0
  41. data/lib/dpl/providers/opsworks.rb +2 -0
  42. data/lib/dpl/providers/packagecloud.rb +2 -0
  43. data/lib/dpl/providers/pages.rb +2 -0
  44. data/lib/dpl/providers/pages/api.rb +1 -1
  45. data/lib/dpl/providers/pages/git.rb +5 -5
  46. data/lib/dpl/providers/puppetforge.rb +2 -0
  47. data/lib/dpl/providers/pypi.rb +2 -0
  48. data/lib/dpl/providers/releases.rb +2 -0
  49. data/lib/dpl/providers/rubygems.rb +2 -0
  50. data/lib/dpl/providers/s3.rb +2 -0
  51. data/lib/dpl/providers/scalingo.rb +2 -0
  52. data/lib/dpl/providers/script.rb +2 -0
  53. data/lib/dpl/providers/snap.rb +3 -1
  54. data/lib/dpl/providers/surge.rb +2 -0
  55. data/lib/dpl/providers/testfairy.rb +2 -0
  56. data/lib/dpl/providers/transifex.rb +2 -0
  57. data/lib/dpl/version.rb +1 -1
  58. data/status.json +13 -8
  59. metadata +5 -4
@@ -52,6 +52,14 @@ module Dpl
52
52
  Interpolator.new(str, self, args || {}, opts).apply
53
53
  end
54
54
 
55
+ # Interpolation variables as declared by the provider.
56
+ #
57
+ # By default this contains string option names, but additional
58
+ # methods can be added using Provider::Dsl#vars.
59
+ def vars
60
+ self.class.vars
61
+ end
62
+
55
63
  # Obfuscates the given string.
56
64
  #
57
65
  # Replaces all but the first N characters with asterisks, and paddes
@@ -71,6 +79,7 @@ module Dpl
71
79
  PATTERN = /%\{(\$?[\w]+)\}/
72
80
  ENV_VAR = /^\$[A-Z_]+$/
73
81
  UPCASE = /^[A-Z_]+$/
82
+ UNKNOWN = '[unknown variable: %s]'
74
83
 
75
84
  def apply
76
85
  str = interpolate(self.str.to_s)
@@ -102,7 +111,9 @@ module Dpl
102
111
  end
103
112
 
104
113
  def lookup(key)
105
- if mod = modifier(key)
114
+ if vars? && !var?(key)
115
+ UNKNOWN % key
116
+ elsif mod = modifier(key)
106
117
  key = key.to_s.sub("#{mod}d_", '')
107
118
  obj.send(mod, lookup(key))
108
119
  elsif key.to_s =~ ENV_VAR
@@ -121,6 +132,18 @@ module Dpl
121
132
  def modifier(key)
122
133
  MODIFIER.detect { |mod| key.to_s.start_with?("#{mod}d_") }
123
134
  end
135
+
136
+ def var?(key)
137
+ vars.include?(key)
138
+ end
139
+
140
+ def vars
141
+ opts[:vars]
142
+ end
143
+
144
+ def vars?
145
+ !!vars
146
+ end
124
147
  end
125
148
  end
126
149
  end
@@ -152,6 +152,16 @@ module Dpl
152
152
  opt '--fold', 'Wrap log output in folds', internal: true
153
153
  opt '--edge', internal: true
154
154
 
155
+ vars *%i(
156
+ git_author_email
157
+ git_author_name
158
+ git_branch
159
+ git_commit_author
160
+ git_commit_msg
161
+ git_sha
162
+ git_tag
163
+ )
164
+
155
165
  msgs before_install: 'Installing deployment dependencies',
156
166
  before_setup: 'Setting the build environment up for the deployment',
157
167
  setup_git_ssh: 'Setting up git-ssh',
@@ -2,6 +2,15 @@ require 'dpl/helper/squiggle'
2
2
  require 'dpl/helper/wrap'
3
3
  require 'dpl/provider/status'
4
4
 
5
+ # TODO figure out how to allow adding domain specific behavior like this to Cl
6
+ class Cl::Opt
7
+ OPTS << :interpolate
8
+
9
+ def interpolate?
10
+ opts[:interpolate]
11
+ end
12
+ end
13
+
5
14
  module Dpl
6
15
  class Provider < Cl::Cmd
7
16
  # DSL available on the provider's class body.
@@ -36,6 +45,22 @@ module Dpl
36
45
  status ? @status = Status.new(self, status, msg) : @status
37
46
  end
38
47
 
48
+ # Declare additional variables available for interpolation.
49
+ #
50
+ # Interpolating strings, when these exposed to the user, should safelist
51
+ # which variables are available. Options declared on a provider are
52
+ # always available, except if they are flags, arrays, internal, or
53
+ # secrets. This method can be used to allow additional variables, e.g.
54
+ # from the git context.
55
+ def vars(*vars)
56
+ return self.vars.concat(vars) if vars.any?
57
+ return @vars if instance_variable_defined?(:@vars)
58
+ vars = superclass.respond_to?(:vars) ? superclass.vars : []
59
+ reject = %i(flag array internal interpolate secret)
60
+ opts = reject.inject(self.opts) { |opts, attr| opts.reject(&:"#{attr}?") }
61
+ @vars = vars.dup.concat(opts.map(&:name)).uniq.sort - [:strategy]
62
+ end
63
+
39
64
  # @!method env
40
65
  # Declare an environment variable prefix to accept env vars as options
41
66
  #
@@ -15,6 +15,7 @@ require 'dpl/providers/convox'
15
15
  require 'dpl/providers/elasticbeanstalk'
16
16
  require 'dpl/providers/engineyard'
17
17
  require 'dpl/providers/firebase'
18
+ require 'dpl/providers/flynn'
18
19
  require 'dpl/providers/gae'
19
20
  require 'dpl/providers/gcs'
20
21
  require 'dpl/providers/gleis'
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Anynines < Provider
4
+ register :anynines
5
+
4
6
  status :alpha
5
7
 
6
8
  description sq(<<-str)
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class AzureWebApps < Provider
4
+ register :azure_web_apps
5
+
4
6
  status :alpha
5
7
 
6
8
  full_name 'Azure Web Apps'
@@ -5,6 +5,8 @@ require 'find'
5
5
  module Dpl
6
6
  module Providers
7
7
  class Bintray < Provider
8
+ register :bintray
9
+
8
10
  status :stable
9
11
 
10
12
  description sq(<<-str)
@@ -1,7 +1,9 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Bluemixcloudfoundry < Provider
4
- status :alpha
4
+ register :bluemixcloudfoundry
5
+
6
+ status :beta
5
7
 
6
8
  full_name 'Bluemix Cloud Foundry'
7
9
 
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Boxfuse < Provider
4
+ register :boxfuse
5
+
4
6
  status :alpha
5
7
 
6
8
  description sq(<<-str)
@@ -1,7 +1,9 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Cargo < Provider
4
- status :beta
4
+ register :cargo
5
+
6
+ status :stable
5
7
 
6
8
  description sq(<<-str)
7
9
  tbd
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Cloud66 < Provider
4
+ register :cloud66
5
+
4
6
  status :alpha
5
7
 
6
8
  description sq(<<-str)
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Cloudfiles < Provider
4
+ register :cloudfiles
5
+
4
6
  status :alpha
5
7
 
6
8
  full_name 'Cloud Files'
@@ -1,6 +1,7 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Cloudformation < Provider
4
+ register :cloudformation
4
5
  status :stable
5
6
 
6
7
  full_name 'AWS CloudFormation'
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Cloudfoundry < Provider
4
+ register :cloudfoundry
5
+
4
6
  status :stable
5
7
 
6
8
  full_name 'Cloud Foundry'
@@ -3,7 +3,9 @@ module Dpl
3
3
  # split this up to CodeDeploy::Github and CodeDeploy::S3 using the
4
4
  # revision_type, in order to make opts more strict
5
5
  class Codedeploy < Provider
6
- status :alpha
6
+ register :codedeploy
7
+
8
+ status :beta
7
9
 
8
10
  full_name 'AWS Code Deploy'
9
11
 
@@ -30,7 +32,7 @@ module Dpl
30
32
  opt '--wait_until_deployed', 'Wait until the deployment has finished'
31
33
  opt '--bundle_type TYPE', 'Bundle type of the revision'
32
34
  opt '--key KEY', 'S3 bucket key of the revision'
33
- opt '--description DESCR', 'Description of the revision'
35
+ opt '--description DESCR', 'Description of the revision', interpolate: true
34
36
  opt '--endpoint ENDPOINT', 'S3 endpoint url'
35
37
 
36
38
  msgs login: 'Using Access Key: %{access_key_id}',
@@ -44,6 +46,8 @@ module Dpl
44
46
  unknown_revision_type: 'Unknown revision type %p',
45
47
  unknown_bundle_type: 'Unknown bundle type'
46
48
 
49
+ vars :build_number
50
+
47
51
  def login
48
52
  info :login
49
53
  end
@@ -152,7 +156,7 @@ module Dpl
152
156
  end
153
157
 
154
158
  def description
155
- super || interpolate(msg(:description))
159
+ interpolate(super || msg(:description), vars: vars)
156
160
  end
157
161
 
158
162
  def build_number
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Convox < Provider
4
+ register :convox
5
+
4
6
  status :dev
5
7
 
6
8
  description sq(<<-str)
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Datica < Provider
4
+ register :datica
5
+
4
6
  status :dev
5
7
 
6
8
  register :datica, :catalyze
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Elasticbeanstalk < Provider
4
+ register :elasticbeanstalk
5
+
4
6
  status :stable
5
7
 
6
8
  full_name 'AWS Elastic Beanstalk'
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Engineyard < Provider
4
+ register :engineyard
5
+
4
6
  status :alpha
5
7
 
6
8
  description sq(<<-str)
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Firebase < Provider
4
+ register :firebase
5
+
4
6
  status :stable
5
7
 
6
8
  description sq(<<-str)
@@ -0,0 +1,33 @@
1
+ module Dpl
2
+ module Providers
3
+ class Flynn < Provider
4
+ register :flynn
5
+
6
+ status :dev
7
+
8
+ full_name 'Flynn'
9
+
10
+ description sq(<<-str)
11
+ Flynn provider for Dpl
12
+ str
13
+
14
+ opt '--git URL', 'Flynn Git remote URL', required: true
15
+
16
+ needs :git, :git_http_user_agent
17
+
18
+ cmds fetch: 'git fetch origin $TRAVIS_BRANCH --unshallow',
19
+ push: 'git push %{remote} HEAD:refs/heads/master -f'
20
+
21
+ def deploy
22
+ shell :fetch, assert: false
23
+ shell :push
24
+ end
25
+
26
+ private
27
+
28
+ def remote
29
+ git
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Gae < Provider
4
+ register :gae
5
+
4
6
  status :stable
5
7
 
6
8
  full_name 'Google App Engine'
@@ -3,6 +3,8 @@ require 'kconv'
3
3
  module Dpl
4
4
  module Providers
5
5
  class Gcs < Provider
6
+ register :gcs
7
+
6
8
  status :stable
7
9
 
8
10
  full_name 'Google Cloud Store'
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Gleis < Provider
4
+ register :gleis
5
+
4
6
  status :alpha
5
7
 
6
8
  description sq(<<-str)
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Hackage < Provider
4
+ register :hackage
5
+
4
6
  status :alpha
5
7
 
6
8
  description sq(<<-str)
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Hephy < Provider
4
+ register :hephy
5
+
4
6
  status :beta
5
7
 
6
8
  description sq(<<-str)
@@ -1,6 +1,8 @@
1
1
  module Dpl
2
2
  module Providers
3
3
  class Heroku < Provider
4
+ register :heroku
5
+
4
6
  abstract
5
7
 
6
8
  gem 'faraday', '~> 0.9.2'
@@ -2,7 +2,7 @@ module Dpl
2
2
  module Providers
3
3
  class Heroku
4
4
  class Api < Heroku
5
- register 'heroku:api'
5
+ register :'heroku:api'
6
6
 
7
7
  status :stable
8
8
 
@@ -2,7 +2,7 @@ module Dpl
2
2
  module Providers
3
3
  class Heroku
4
4
  class Git < Heroku
5
- register 'heroku:git'
5
+ register :'heroku:git'
6
6
 
7
7
  status :alpha
8
8
 
@@ -3,6 +3,8 @@ require 'dpl/helper/zip'
3
3
  module Dpl
4
4
  module Providers
5
5
  class Lambda < Provider
6
+ register :lambda
7
+
6
8
  status :stable
7
9
 
8
10
  full_name 'AWS Lambda'
@@ -24,7 +26,7 @@ module Dpl
24
26
  opt '--role ROLE', 'ARN of the IAM role to assign to the Lambda function', note: 'required when creating a new function'
25
27
  opt '--handler_name NAME', 'Function the Lambda calls to begin execution.', note: 'required when creating a new function'
26
28
  opt '--module_name NAME', 'Name of the module that exports the handler', default: 'index', requires: :handler_name
27
- opt '--description DESCR', 'Description of the Lambda being created or updated'
29
+ opt '--description DESCR', 'Description of the Lambda being created or updated', interpolate: true
28
30
  opt '--timeout SECS', 'Function execution time (in seconds) at which Lambda should terminate the function', default: 3
29
31
  opt '--memory_size MB', 'Amount of memory in MB to allocate to this Lambda', default: 128
30
32
  opt '--subnet_ids IDS', 'List of subnet IDs to be added to the function', type: :array, note: 'Needs the ec2:DescribeSubnets and ec2:DescribeVpcs permission for the user of the access/secret key to work'
@@ -157,7 +159,7 @@ module Dpl
157
159
  end
158
160
 
159
161
  def description
160
- super || interpolate(msg(:description))
162
+ interpolate(super || msg(:description), vars: vars)
161
163
  end
162
164
 
163
165
  def client