travis_dpl_test 2.0.3.beta.4.ror
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +172 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +392 -0
- data/Gemfile +32 -0
- data/Gemfile.lock +611 -0
- data/LICENSE +19 -0
- data/README.md +2744 -0
- data/Rakefile +210 -0
- data/bin/dpl +11 -0
- data/config/transliterate.yml +733 -0
- data/dpl.gemspec +23 -0
- data/lib/dpl/assets/atlas/install +19 -0
- data/lib/dpl/assets/convox/install +11 -0
- data/lib/dpl/assets/dpl/README.erb.md +138 -0
- data/lib/dpl/assets/dpl/git_ssh +8 -0
- data/lib/dpl/assets/git/detect_private_key +8 -0
- data/lib/dpl/assets/hephy/filter_log +3 -0
- data/lib/dpl/assets/pypi/install +4 -0
- data/lib/dpl/assets/scalingo/install +6 -0
- data/lib/dpl/cli.rb +100 -0
- data/lib/dpl/ctx/bash.rb +549 -0
- data/lib/dpl/ctx/test.rb +255 -0
- data/lib/dpl/ctx.rb +4 -0
- data/lib/dpl/helper/assets.rb +38 -0
- data/lib/dpl/helper/cmd.rb +169 -0
- data/lib/dpl/helper/config_file.rb +49 -0
- data/lib/dpl/helper/cookbook_site_streaming_uploader.rb +249 -0
- data/lib/dpl/helper/env.rb +92 -0
- data/lib/dpl/helper/github.rb +22 -0
- data/lib/dpl/helper/interpolate.rb +160 -0
- data/lib/dpl/helper/memoize.rb +23 -0
- data/lib/dpl/helper/squiggle.rb +24 -0
- data/lib/dpl/helper/transliterate.rb +13 -0
- data/lib/dpl/helper/wrap.rb +11 -0
- data/lib/dpl/helper/zip.rb +71 -0
- data/lib/dpl/provider/dsl.rb +410 -0
- data/lib/dpl/provider/examples.rb +132 -0
- data/lib/dpl/provider/status.rb +61 -0
- data/lib/dpl/provider.rb +651 -0
- data/lib/dpl/providers/anynines.rb +71 -0
- data/lib/dpl/providers/azure_web_apps.rb +63 -0
- data/lib/dpl/providers/bintray.rb +324 -0
- data/lib/dpl/providers/bluemixcloudfoundry.rb +98 -0
- data/lib/dpl/providers/boxfuse.rb +52 -0
- data/lib/dpl/providers/cargo.rb +32 -0
- data/lib/dpl/providers/chef_supermarket.rb +132 -0
- data/lib/dpl/providers/cloud66.rb +46 -0
- data/lib/dpl/providers/cloudfiles.rb +62 -0
- data/lib/dpl/providers/cloudformation.rb +281 -0
- data/lib/dpl/providers/cloudfoundry.rb +89 -0
- data/lib/dpl/providers/codedeploy.rb +190 -0
- data/lib/dpl/providers/convox.rb +130 -0
- data/lib/dpl/providers/datica.rb +64 -0
- data/lib/dpl/providers/ecr.rb +129 -0
- data/lib/dpl/providers/elasticbeanstalk.rb +207 -0
- data/lib/dpl/providers/engineyard.rb +113 -0
- data/lib/dpl/providers/firebase.rb +45 -0
- data/lib/dpl/providers/flynn.rb +35 -0
- data/lib/dpl/providers/gae.rb +78 -0
- data/lib/dpl/providers/gcs.rb +132 -0
- data/lib/dpl/providers/git_push.rb +273 -0
- data/lib/dpl/providers/gleis.rb +74 -0
- data/lib/dpl/providers/hackage.rb +53 -0
- data/lib/dpl/providers/hephy.rb +107 -0
- data/lib/dpl/providers/heroku/api.rb +123 -0
- data/lib/dpl/providers/heroku/git.rb +54 -0
- data/lib/dpl/providers/heroku.rb +111 -0
- data/lib/dpl/providers/lambda.rb +211 -0
- data/lib/dpl/providers/launchpad.rb +80 -0
- data/lib/dpl/providers/netlify.rb +38 -0
- data/lib/dpl/providers/npm.rb +130 -0
- data/lib/dpl/providers/nuget.rb +41 -0
- data/lib/dpl/providers/openshift.rb +52 -0
- data/lib/dpl/providers/opsworks.rb +146 -0
- data/lib/dpl/providers/packagecloud.rb_ +194 -0
- data/lib/dpl/providers/pages/api.rb +106 -0
- data/lib/dpl/providers/pages/git.rb +262 -0
- data/lib/dpl/providers/pages.rb +18 -0
- data/lib/dpl/providers/puppetforge.rb +50 -0
- data/lib/dpl/providers/pypi.rb +125 -0
- data/lib/dpl/providers/releases.rb +234 -0
- data/lib/dpl/providers/rubygems.rb +97 -0
- data/lib/dpl/providers/s3.rb +251 -0
- data/lib/dpl/providers/scalingo.rb +69 -0
- data/lib/dpl/providers/script.rb +32 -0
- data/lib/dpl/providers/snap.rb +68 -0
- data/lib/dpl/providers/surge.rb +59 -0
- data/lib/dpl/providers/testfairy.rb +101 -0
- data/lib/dpl/providers/transifex.rb +72 -0
- data/lib/dpl/providers.rb +48 -0
- data/lib/dpl/string_ext.rb +23 -0
- data/lib/dpl/support/aws_sdk_patch.rb +26 -0
- data/lib/dpl/support/gems.rb +73 -0
- data/lib/dpl/support/gstore_patch.rb +8 -0
- data/lib/dpl/support/version.rb +84 -0
- data/lib/dpl/version.rb +5 -0
- data/lib/dpl.rb +23 -0
- data/status.json +237 -0
- metadata +161 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dpl
|
|
4
|
+
module Providers
|
|
5
|
+
class Heroku < Provider
|
|
6
|
+
register :heroku
|
|
7
|
+
|
|
8
|
+
abstract
|
|
9
|
+
|
|
10
|
+
gem 'faraday', '~> 1'
|
|
11
|
+
gem 'netrc', '~> 0.11.0'
|
|
12
|
+
gem 'rendezvous', '~> 0.1.3'
|
|
13
|
+
|
|
14
|
+
env :heroku
|
|
15
|
+
|
|
16
|
+
opt '--strategy NAME', 'Heroku deployment strategy', default: 'api', enum: %w[api git]
|
|
17
|
+
opt '--app APP', 'Heroku app name', default: :repo_name
|
|
18
|
+
opt '--log_level LEVEL', internal: true
|
|
19
|
+
|
|
20
|
+
msgs login: 'Authenticating ... ',
|
|
21
|
+
restart: 'Restarting dynos ... ',
|
|
22
|
+
validate: 'Checking for app %{app} ... ',
|
|
23
|
+
run_cmd: 'Running command %s ... ',
|
|
24
|
+
success: 'success.',
|
|
25
|
+
api_error: 'API request failed: %s (see %s)'
|
|
26
|
+
|
|
27
|
+
URL = 'https://api.heroku.com'
|
|
28
|
+
|
|
29
|
+
HEADERS = {
|
|
30
|
+
'Accept': 'application/vnd.heroku+json; version=3',
|
|
31
|
+
'User-Agent': user_agent
|
|
32
|
+
}.freeze
|
|
33
|
+
|
|
34
|
+
attr_reader :email
|
|
35
|
+
|
|
36
|
+
def login
|
|
37
|
+
print :login
|
|
38
|
+
res = http.get('/account')
|
|
39
|
+
handle_error(res) unless res.success?
|
|
40
|
+
@email = JSON.parse(res.body)['email']
|
|
41
|
+
info :success
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def validate
|
|
45
|
+
print :validate
|
|
46
|
+
res = http.get("/apps/#{app}")
|
|
47
|
+
handle_error(res) unless res.success?
|
|
48
|
+
info :success
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def restart
|
|
52
|
+
print :restart
|
|
53
|
+
res = http.delete "/apps/#{app}/dynos" do |req|
|
|
54
|
+
req.headers['Content-Type'] = 'application/json'
|
|
55
|
+
end
|
|
56
|
+
handle_error(res) unless res.success?
|
|
57
|
+
info :success
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def run_cmd(cmd)
|
|
61
|
+
print :run_cmd, cmd
|
|
62
|
+
res = http.post "/apps/#{app}/dynos" do |req|
|
|
63
|
+
req.headers['Content-Type'] = 'application/json'
|
|
64
|
+
req.body = { command: cmd, attach: true }.to_json
|
|
65
|
+
end
|
|
66
|
+
handle_error(res) unless res.success?
|
|
67
|
+
rendezvous(JSON.parse(res.body)['attach_url'])
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
def http
|
|
73
|
+
@http ||= Faraday.new(url: URL, headers:) do |http|
|
|
74
|
+
http.basic_auth(username, password) if username && password
|
|
75
|
+
http.response :logger, logger, &method(:filter) if log_level?
|
|
76
|
+
http.adapter Faraday.default_adapter
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def headers
|
|
81
|
+
return HEADERS.dup if username && password
|
|
82
|
+
|
|
83
|
+
HEADERS.merge('Authorization': "Bearer #{api_key}")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def filter(logger)
|
|
87
|
+
logger.filter(/(.*Authorization: ).*/, '\1[REDACTED]')
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def logger
|
|
91
|
+
super(log_level)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def handle_error(response)
|
|
95
|
+
body = JSON.parse(response.body)
|
|
96
|
+
error :api_error, body['message'], body['url']
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def rendezvous(url)
|
|
100
|
+
Rendezvous.start(url:)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# overwritten in Git, meaningless in Api
|
|
104
|
+
def username; end
|
|
105
|
+
def password; end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
require 'dpl/providers/heroku/api'
|
|
111
|
+
require 'dpl/providers/heroku/git'
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'dpl/helper/zip'
|
|
4
|
+
|
|
5
|
+
module Dpl
|
|
6
|
+
module Providers
|
|
7
|
+
class Lambda < Provider
|
|
8
|
+
register :lambda
|
|
9
|
+
|
|
10
|
+
status :stable
|
|
11
|
+
|
|
12
|
+
full_name 'AWS Lambda'
|
|
13
|
+
|
|
14
|
+
description sq(<<-STR)
|
|
15
|
+
tbd
|
|
16
|
+
STR
|
|
17
|
+
|
|
18
|
+
gem 'aws-sdk-lambda', '~> 1.104.0'
|
|
19
|
+
gem 'nokogiri', '~> 1.15'
|
|
20
|
+
gem 'rubyzip', '~> 2.3', require: 'zip'
|
|
21
|
+
|
|
22
|
+
env :aws, :lambda
|
|
23
|
+
config '~/.aws/credentials', '~/.aws/config', prefix: 'aws'
|
|
24
|
+
|
|
25
|
+
opt '--access_key_id ID', 'AWS access key id', required: true, secret: true
|
|
26
|
+
opt '--secret_access_key KEY', 'AWS secret key', required: true, secret: true
|
|
27
|
+
opt '--region REGION', 'AWS region the Lambda function is running in', default: 'us-east-1'
|
|
28
|
+
opt '--function_name FUNC', 'Name of the Lambda being created or updated', required: true
|
|
29
|
+
opt '--role ROLE', 'ARN of the IAM role to assign to the Lambda function', note: 'required when creating a new function'
|
|
30
|
+
opt '--handler_name NAME', 'Function the Lambda calls to begin execution.', note: 'required when creating a new function'
|
|
31
|
+
opt '--module_name NAME', 'Name of the module that exports the handler', default: 'index', requires: :handler_name
|
|
32
|
+
opt '--description DESCR', 'Description of the Lambda being created or updated', interpolate: true
|
|
33
|
+
opt '--timeout SECS', 'Function execution time (in seconds) at which Lambda should terminate the function', default: 3
|
|
34
|
+
opt '--memory_size MB', 'Amount of memory in MB to allocate to this Lambda', default: 128
|
|
35
|
+
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'
|
|
36
|
+
opt '--security_group_ids IDS', 'List of security group IDs to be added to the function', type: :array, note: 'Needs the ec2:DescribeSecurityGroups and ec2:DescribeVpcs permission for the user of the access/secret key to work'
|
|
37
|
+
opt '--environment VARS', 'List of Environment Variables to add to the function', type: :array, format: /[\w-]+=.+/, note: 'Can be encrypted for added security', alias: :environment_variables
|
|
38
|
+
opt '--runtime NAME', 'Lambda runtime to use', note: 'required when creating a new function', default: 'nodejs12.x', enum: %w[nodejs16.x nodejs14.x nodejs12.x python3.8 python3.7 python3.6 python2.7 ruby2.7 ruby2.5 java11 java8 go1.x dotnetcore2.1]
|
|
39
|
+
opt '--dead_letter_arn ARN', 'ARN to an SNS or SQS resource used for the dead letter queue.'
|
|
40
|
+
opt '--kms_key_arn ARN', 'KMS key ARN to use to encrypt environment_variables.'
|
|
41
|
+
opt '--tracing_mode MODE', 'Tracing mode', default: 'PassThrough', enum: %w[Active PassThrough], note: 'Needs xray:PutTraceSegments xray:PutTelemetryRecords on the role'
|
|
42
|
+
opt '--layers LAYERS', 'Function layer arns', type: :array
|
|
43
|
+
opt '--function_tags TAGS', 'List of tags to add to the function', type: :array, format: /[\w-]+=.+/, note: 'Can be encrypted for added security'
|
|
44
|
+
opt '--publish', 'Create a new version of the code instead of replacing the existing one.'
|
|
45
|
+
opt '--zip PATH', 'Path to a packaged Lambda, a directory to package, or a single file to package', default: '.'
|
|
46
|
+
opt '--dot_match', 'Include hidden .* files to the zipped archive'
|
|
47
|
+
|
|
48
|
+
msgs login: 'Using Access Key: %{access_key_id}',
|
|
49
|
+
create_function: 'Creating function %{function_name}.',
|
|
50
|
+
update_config: 'Updating existing function %{function_name}.',
|
|
51
|
+
update_tags: 'Updating tags.',
|
|
52
|
+
update_code: 'Updating code.',
|
|
53
|
+
description: 'Deploy build %{build_number} to AWS Lambda via Travis CI'
|
|
54
|
+
|
|
55
|
+
def login
|
|
56
|
+
info :login
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def deploy
|
|
60
|
+
exists? ? update : create
|
|
61
|
+
rescue Aws::Errors::ServiceError => e
|
|
62
|
+
error e.message
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def exists?
|
|
68
|
+
!!client.get_function(function_name:)
|
|
69
|
+
rescue ::Aws::Lambda::Errors::ResourceNotFoundException
|
|
70
|
+
false
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def create
|
|
74
|
+
info :create_function
|
|
75
|
+
config = function_config
|
|
76
|
+
config = config.merge(code: { zip_file: function_zip })
|
|
77
|
+
config = config.merge(tags: function_tags) if function_tags?
|
|
78
|
+
client.create_function(config)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def update
|
|
82
|
+
arn = update_config
|
|
83
|
+
client.wait_until(:function_updated, { function_name: })
|
|
84
|
+
update_tags(arn) if function_tags?
|
|
85
|
+
client.wait_until(:function_updated, { function_name: })
|
|
86
|
+
update_code
|
|
87
|
+
rescue Aws::Waiters::Errors::WaiterFailed
|
|
88
|
+
error 'Update timed out.'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def update_config
|
|
92
|
+
info :update_config
|
|
93
|
+
response = client.update_function_configuration(function_config)
|
|
94
|
+
response.function_arn
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def update_tags(arn)
|
|
98
|
+
info :update_tags
|
|
99
|
+
client.tag_resource(tag_resource(arn))
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def update_code
|
|
103
|
+
info :update_code
|
|
104
|
+
client.update_function_code(function_code)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def function_config
|
|
108
|
+
compact(
|
|
109
|
+
function_name:,
|
|
110
|
+
role:,
|
|
111
|
+
handler:,
|
|
112
|
+
description:,
|
|
113
|
+
timeout:,
|
|
114
|
+
memory_size:,
|
|
115
|
+
vpc_config:,
|
|
116
|
+
environment:,
|
|
117
|
+
runtime:,
|
|
118
|
+
dead_letter_config: dead_letter_arn,
|
|
119
|
+
kms_key_arn:,
|
|
120
|
+
tracing_config:,
|
|
121
|
+
layers:
|
|
122
|
+
)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def tag_resource(arn)
|
|
126
|
+
{
|
|
127
|
+
resource: arn,
|
|
128
|
+
tags: function_tags
|
|
129
|
+
}
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def function_code
|
|
133
|
+
{
|
|
134
|
+
function_name:,
|
|
135
|
+
zip_file: function_zip,
|
|
136
|
+
publish: publish?
|
|
137
|
+
}
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def handler
|
|
141
|
+
Handler.new(runtime, module_name, handler_name).to_s if handler_name?
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def function_zip
|
|
145
|
+
Zip.new(zip, tmp_filename, opts).zip
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def vpc_config
|
|
149
|
+
compact(subnet_ids:, security_group_ids:)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def environment
|
|
153
|
+
{ variables: split_vars(super) } if environment?
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def dead_letter_arn
|
|
157
|
+
{ target_arn: super } if dead_letter_arn?
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def tracing_config
|
|
161
|
+
{ mode: tracing_mode } if tracing_mode?
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def function_tags
|
|
165
|
+
split_vars(super) if function_tags?
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def description
|
|
169
|
+
interpolate(super || msg(:description), vars:)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def client
|
|
173
|
+
@client ||= Aws::Lambda::Client.new(region:, credentials:)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def credentials
|
|
177
|
+
Aws::Credentials.new(access_key_id, secret_access_key)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def split_vars(vars)
|
|
181
|
+
vars.map { |var| var.split('=', 2) }.to_h
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def tmp_filename
|
|
185
|
+
@tmp_filename ||= "#{tmp_dir}/#{repo_name}.zip"
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
class Handler < Struct.new(:runtime, :module_name, :handler_name)
|
|
189
|
+
SEP = {
|
|
190
|
+
default: '.',
|
|
191
|
+
java: '::',
|
|
192
|
+
dotnet: '::',
|
|
193
|
+
go: ''
|
|
194
|
+
}.freeze
|
|
195
|
+
|
|
196
|
+
def to_s
|
|
197
|
+
[go? ? nil : module_name, sep, handler_name].compact.join
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def sep
|
|
201
|
+
key = SEP.keys.detect { |key| runtime.start_with?(key.to_s) }
|
|
202
|
+
SEP[key || :default]
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def go?
|
|
206
|
+
runtime.start_with?('go')
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dpl
|
|
4
|
+
module Providers
|
|
5
|
+
class Launchpad < Provider
|
|
6
|
+
register :launchpad
|
|
7
|
+
|
|
8
|
+
status :alpha
|
|
9
|
+
|
|
10
|
+
description sq(<<-STR)
|
|
11
|
+
tbd
|
|
12
|
+
STR
|
|
13
|
+
|
|
14
|
+
env :launchpad
|
|
15
|
+
|
|
16
|
+
opt '--oauth_token TOKEN', 'Launchpad OAuth token', secret: true
|
|
17
|
+
opt '--oauth_token_secret SECRET', 'Launchpad OAuth token secret', secret: true
|
|
18
|
+
opt '--slug SLUG', 'Launchpad project slug', format: %r{^~[^/]+/[^/]+/[^/]+$}, example: '~user-name/project-name/branch-name'
|
|
19
|
+
|
|
20
|
+
msgs invalid_credentials: 'Invalid credentials (%s)',
|
|
21
|
+
unknown_error: 'Error: %s (%s)'
|
|
22
|
+
|
|
23
|
+
def deploy
|
|
24
|
+
handle_response(post)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def post
|
|
30
|
+
req = Net::HTTP::Post.new(path)
|
|
31
|
+
req['Authorization'] = authorization
|
|
32
|
+
req.set_form_data(data)
|
|
33
|
+
http.request(req)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def handle_response(res)
|
|
37
|
+
error :invalid_credentials, res.code if res.code == '401'
|
|
38
|
+
error :unknown_error, res.body, res.code unless res.is_a?(Net::HTTPSuccess)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def http
|
|
42
|
+
http = Net::HTTP.new('api.launchpad.net', 443)
|
|
43
|
+
http.use_ssl = true
|
|
44
|
+
http
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def path
|
|
48
|
+
"/1.0/#{slug}/+code-import"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def data
|
|
52
|
+
{ 'ws.op' => 'requestImport' }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def authorization
|
|
56
|
+
squish(<<-AUTH)
|
|
57
|
+
OAuth oauth_consumer_key="Travis%20Deploy",
|
|
58
|
+
oauth_nonce="#{nonce}",
|
|
59
|
+
oauth_signature="%26#{oauth_token_secret}",
|
|
60
|
+
oauth_signature_method="PLAINTEXT",
|
|
61
|
+
oauth_timestamp="#{now}",
|
|
62
|
+
oauth_token="#{oauth_token}",
|
|
63
|
+
oauth_version="1.0"
|
|
64
|
+
AUTH
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def nonce
|
|
68
|
+
rand(36**32).to_s(36)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def now
|
|
72
|
+
Time.now.to_i
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def squish(str)
|
|
76
|
+
str.strip.gsub(/\s+/, ' ')
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dpl
|
|
4
|
+
module Providers
|
|
5
|
+
class Netlify < Provider
|
|
6
|
+
register :netlify
|
|
7
|
+
|
|
8
|
+
status :stable
|
|
9
|
+
|
|
10
|
+
description sq(<<-STR)
|
|
11
|
+
tbd
|
|
12
|
+
STR
|
|
13
|
+
|
|
14
|
+
node_js '>= 12.0.0'
|
|
15
|
+
|
|
16
|
+
npm 'netlify-cli', 'netlify'
|
|
17
|
+
|
|
18
|
+
env :netlify
|
|
19
|
+
|
|
20
|
+
opt '--site ID', 'A site ID to deploy to', required: true
|
|
21
|
+
opt '--auth TOKEN', 'An auth token to log in with', required: true, secret: true
|
|
22
|
+
opt '--dir DIR', 'Specify a folder to deploy'
|
|
23
|
+
opt '--functions FUNCS', 'Specify a functions folder to deploy'
|
|
24
|
+
opt '--message MSG', 'A message to include in the deploy log'
|
|
25
|
+
opt '--prod', 'Deploy to production'
|
|
26
|
+
|
|
27
|
+
def deploy
|
|
28
|
+
shell "netlify deploy #{deploy_opts}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def deploy_opts
|
|
34
|
+
opts_for(%i[site auth dir functions message prod])
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dpl
|
|
4
|
+
module Providers
|
|
5
|
+
class Npm < Provider
|
|
6
|
+
register :npm
|
|
7
|
+
|
|
8
|
+
status :stable
|
|
9
|
+
|
|
10
|
+
full_name 'npm'
|
|
11
|
+
|
|
12
|
+
description sq(<<-STR)
|
|
13
|
+
tbd
|
|
14
|
+
STR
|
|
15
|
+
|
|
16
|
+
gem 'json'
|
|
17
|
+
|
|
18
|
+
env :npm
|
|
19
|
+
|
|
20
|
+
opt '--email EMAIL', 'npm account email'
|
|
21
|
+
opt '--api_token TOKEN', 'npm api token', alias: :api_key, required: true, secret: true, note: 'can be retrieved from your local ~/.npmrc file', see: 'https://docs.npmjs.com/creating-and-viewing-authentication-tokens'
|
|
22
|
+
opt '--access ACCESS', 'Access level', enum: %w[public private]
|
|
23
|
+
opt '--registry URL', 'npm registry url'
|
|
24
|
+
opt '--src SRC', 'directory or tarball to publish', default: '.'
|
|
25
|
+
opt '--tag TAGS', 'distribution tags to add'
|
|
26
|
+
opt '--run_script SCRIPT', 'run the given script from package.json', type: :array, note: 'skips running npm publish'
|
|
27
|
+
opt '--dry_run', 'performs test run without uploading to registry'
|
|
28
|
+
opt '--auth_method METHOD', 'Authentication method', enum: %w[auth]
|
|
29
|
+
|
|
30
|
+
REGISTRY = 'https://registry.npmjs.org'
|
|
31
|
+
NPMRC = '~/.npmrc'
|
|
32
|
+
|
|
33
|
+
msgs version: 'npm version: %{npm_version}',
|
|
34
|
+
login: 'Authenticated with API token %{api_token}'
|
|
35
|
+
|
|
36
|
+
cmds registry: 'npm config set registry "%{registry}"',
|
|
37
|
+
publish: 'npm publish %{src} %{publish_opts}',
|
|
38
|
+
run: 'npm run %{script}'
|
|
39
|
+
|
|
40
|
+
errs registry: 'Failed to set registry config',
|
|
41
|
+
publish: 'Failed to publish',
|
|
42
|
+
run: 'Failed to run script %{script}'
|
|
43
|
+
|
|
44
|
+
def login
|
|
45
|
+
info :version
|
|
46
|
+
info :login
|
|
47
|
+
write_npmrc
|
|
48
|
+
shell :registry
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def deploy
|
|
52
|
+
if run_script?
|
|
53
|
+
run_scripts
|
|
54
|
+
else
|
|
55
|
+
shell :publish
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def finish
|
|
60
|
+
remove_npmrc
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def run_scripts
|
|
66
|
+
run_script.each do |script|
|
|
67
|
+
shell :run, script:
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def publish_opts
|
|
72
|
+
opts_for(%i[access tag dry_run], dashed: true)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def write_npmrc
|
|
76
|
+
write_file(npmrc_path, npmrc)
|
|
77
|
+
info "#{NPMRC} size: #{file_size(npmrc_path)}"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def remove_npmrc
|
|
81
|
+
rm_f npmrc_path
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def npmrc_path
|
|
85
|
+
expand(NPMRC)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def npmrc
|
|
89
|
+
if npm_version =~ /^1/ || auth_method == 'auth'
|
|
90
|
+
"_auth = #{api_token}\nemail = #{email}"
|
|
91
|
+
else
|
|
92
|
+
"//#{auth_endpoint}/:_authToken=#{api_token}"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def auth_endpoint
|
|
97
|
+
str = registry
|
|
98
|
+
str = strip_path(str) if str.include?('npm.pkg.github.com')
|
|
99
|
+
str = strip_protocol(str).sub(%r{/$}, '')
|
|
100
|
+
str
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def registry
|
|
104
|
+
super || registry_from_package_json || REGISTRY
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def registry_from_package_json
|
|
108
|
+
return unless data = package_json
|
|
109
|
+
|
|
110
|
+
data && data.fetch('publishConfig', {})['registry']
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def strip_path(url)
|
|
114
|
+
url.sub(URI(url).path, '')
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def strip_protocol(url)
|
|
118
|
+
url.sub("#{URI(url).scheme}://", '')
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def host(url)
|
|
122
|
+
URI(url).host
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def package_json
|
|
126
|
+
File.exist?('package.json') ? JSON.parse(File.read('package.json')) : {}
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dpl
|
|
4
|
+
module Providers
|
|
5
|
+
class Nuget < Provider
|
|
6
|
+
status :alpha
|
|
7
|
+
|
|
8
|
+
full_name 'nuget'
|
|
9
|
+
|
|
10
|
+
description sq(<<-STR)
|
|
11
|
+
tbd
|
|
12
|
+
STR
|
|
13
|
+
|
|
14
|
+
env :nuget, :dotnet
|
|
15
|
+
|
|
16
|
+
opt '--api_key KEY', 'NuGet registry API key', required: true, secret: true, note: 'can be retrieved from your NuGet registry provider', see: 'https://docs.npmjs.com/creating-and-viewing-authentication-tokens'
|
|
17
|
+
opt '--registry URL', 'NuGet registry url', required: true, eg: 'https://www.myget.org/F/org-name/api/v2/package'
|
|
18
|
+
opt '--src SRC', 'The nupkg file(s) to publish', default: '*.nupkg'
|
|
19
|
+
opt '--no_symbols', 'Do not push symbols, even if present'
|
|
20
|
+
opt '--skip_duplicate', 'Do not overwrite existing packages'
|
|
21
|
+
|
|
22
|
+
msgs login: 'Authenticating with API key %{api_key}',
|
|
23
|
+
push: 'Pushing package %{src} to %{registry}'
|
|
24
|
+
|
|
25
|
+
cmds push: 'dotnet nuget push %{src} -k %{api_key} -s %{registry} %{push_opts}'
|
|
26
|
+
|
|
27
|
+
errs push: 'Failed to push'
|
|
28
|
+
|
|
29
|
+
def deploy
|
|
30
|
+
info :login
|
|
31
|
+
shell :push
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def push_opts
|
|
37
|
+
opts_for(%i[no_symbols skip_duplicate], dashed: true)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dpl
|
|
4
|
+
module Providers
|
|
5
|
+
class Openshift < Provider
|
|
6
|
+
register :openshift
|
|
7
|
+
|
|
8
|
+
status :stable
|
|
9
|
+
|
|
10
|
+
full_name 'OpenShift'
|
|
11
|
+
|
|
12
|
+
description sq(<<-STR)
|
|
13
|
+
tbd
|
|
14
|
+
STR
|
|
15
|
+
|
|
16
|
+
env :openshift
|
|
17
|
+
|
|
18
|
+
opt '--server SERVER', 'OpenShift server', required: true
|
|
19
|
+
opt '--token TOKEN', 'OpenShift token', required: true, secret: true
|
|
20
|
+
opt '--project PROJECT', 'OpenShift project', required: true
|
|
21
|
+
opt '--app APP', 'OpenShift application', default: :repo_name
|
|
22
|
+
|
|
23
|
+
cmds install: 'curl %{URL} | tar xz',
|
|
24
|
+
login: './oc login --token=%{token} --server=%{server}',
|
|
25
|
+
prepare: './oc project %{project}',
|
|
26
|
+
deploy: './oc start-build %{app} --follow --commit %{git_sha}'
|
|
27
|
+
|
|
28
|
+
errs install: 'CLI tool installation failed',
|
|
29
|
+
login: 'Authentication failed',
|
|
30
|
+
prepare: 'Unable to select project %{project}',
|
|
31
|
+
deploy: 'Deployment failed'
|
|
32
|
+
|
|
33
|
+
URL = 'https://mirror.openshift.com/pub/openshift-v4/clients/oc/4.1/linux/oc.tar.gz'
|
|
34
|
+
|
|
35
|
+
def install
|
|
36
|
+
shell :install
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def login
|
|
40
|
+
shell :login
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def prepare
|
|
44
|
+
shell :prepare
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def deploy
|
|
48
|
+
shell :deploy
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|