dapp 0.14.31 → 0.15.0

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: 6092e38bdbb81a6c55974d8b31bba7222e3b1ffb
4
- data.tar.gz: c44a7a91434f4f618b981612d1fd2711881881a2
3
+ metadata.gz: 42f6d6fce7254c75aa1746062ff9490bb38aaa34
4
+ data.tar.gz: 644155d4d9e2788eb5e0563e26a84b9dcf35b73e
5
5
  SHA512:
6
- metadata.gz: 695205e420bc45641e7d1066176ad4a67f4e837a12927a0e6461139a0d1757901cc1178735a43a6c166b56aa42d95d5f4e95f23a6b0de8639ea3da909bea85bb
7
- data.tar.gz: eba3b705f9836f1ae696c8d7816d1cf1086c19bcd622e4b76a43c5d80945d20991162bdcdc236939e0b0c5d95c4813485204ad75a40d11f1aea522ddc0965884
6
+ metadata.gz: 3db6d327a4f8b90d26674653df5f5c6c1f9733fad3152bee49d228daf452900ccfa823159aa040f123b381560ceb7db2b43fc5618d272cb00680bc6865d3a4d7
7
+ data.tar.gz: 5d0229d66b4643e90cf6531b3326161b5fe2c103875ccba9acc132b66e6a2cd3fecceec5f2bd96a508518694a8df7b0570cbfe586c9b9fc257fb4a1d352f9d77
data/bin/dapp CHANGED
@@ -50,10 +50,6 @@ with_dapp_running_lock do
50
50
  $stderr.puts "\033[1m\033[90mStacktrace dumped to #{filename}\033[0m"
51
51
  end
52
52
 
53
- if Dapp::CLI.dapp_object
54
- Dapp::CLI.dapp_object.sentry_exception(e)
55
- end
56
-
57
53
  raise
58
54
  end
59
55
  rescue Dapp::Error::Shellout => e
@@ -24,8 +24,6 @@ require 'openssl'
24
24
  require 'etc'
25
25
  require 'zlib'
26
26
  require 'slugify'
27
- require 'sentry-raven'
28
- require 'toml-rb'
29
27
 
30
28
  require 'dapp/version'
31
29
  require 'dapp/core_ext/hash'
@@ -36,7 +34,6 @@ require 'dapp/helper/sha256'
36
34
  require 'dapp/helper/net_status'
37
35
  require 'dapp/helper/tar'
38
36
  require 'dapp/helper/yaml'
39
- require 'dapp/helper/url'
40
37
  require 'dapp/prctl'
41
38
  require 'dapp/error/base'
42
39
  require 'dapp/error/dapp'
@@ -52,7 +49,6 @@ require 'dapp/config/config'
52
49
  require 'dapp/config/error/config'
53
50
  require 'dapp/dapp/lock'
54
51
  require 'dapp/dapp/ssh_agent'
55
- require 'dapp/dapp/sentry'
56
52
  require 'dapp/dapp/git_artifact'
57
53
  require 'dapp/dapp/dappfile'
58
54
  require 'dapp/dapp/chef'
@@ -37,10 +37,6 @@ BANNER
37
37
  show_options: true,
38
38
  exit: 0
39
39
 
40
- class << self
41
- attr_accessor :dapp_object
42
- end
43
-
44
40
  def initialize(*args)
45
41
  super(*args)
46
42
 
@@ -58,9 +58,6 @@ module Dapp
58
58
 
59
59
  def run_dapp_command(run_method, *args)
60
60
  dapp = ::Dapp::Dapp.new(*args)
61
- ::Dapp::CLI.dapp_object = dapp
62
- dapp.sentry_message("Manual usage: `#{self.run_method}` command") unless ENV['CI']
63
-
64
61
  begin
65
62
  if block_given?
66
63
  yield dapp
@@ -70,16 +67,12 @@ module Dapp
70
67
  end
71
68
  end
72
69
 
73
- def run_method
74
- class_to_lowercase
75
- end
76
-
77
70
  def run(_argv = ARGV)
78
71
  raise
79
72
  end
80
73
 
81
74
  def cli_options(**kwargs)
82
- config.merge(dapp_command: run_method, **kwargs)
75
+ config.merge(**kwargs)
83
76
  end
84
77
  end
85
78
  end
@@ -12,13 +12,10 @@ module Dapp
12
12
  include Logging::Paint
13
13
 
14
14
  include SshAgent
15
- include Sentry
16
-
17
15
  include Helper::Sha256
18
- extend Helper::Trivia
16
+ extend Helper::Trivia
19
17
  include Helper::Trivia
20
18
  include Helper::Tar
21
- include Helper::Url
22
19
 
23
20
  include Deps::Gitartifact
24
21
  include Deps::Base
@@ -38,18 +35,6 @@ module Dapp
38
35
  self.class.options
39
36
  end
40
37
 
41
- def settings
42
- @settings ||= begin
43
- settings_path = File.join(self.class.home_dir, "settings.toml")
44
-
45
- if File.exists? settings_path
46
- TomlRB.load_file(settings_path)
47
- else
48
- {}
49
- end
50
- end
51
- end
52
-
53
38
  def name
54
39
  @name ||= begin
55
40
  if git_url
@@ -90,18 +75,15 @@ module Dapp
90
75
  self.class.tmp_base_dir
91
76
  end
92
77
 
93
- def build_dir
94
- @build_dir ||= begin
78
+ def build_path(*path)
79
+ @build_path ||= begin
95
80
  if option_build_dir
96
81
  Pathname.new(option_build_dir)
97
82
  else
98
83
  path('.dapp_build')
99
84
  end.expand_path.tap(&:mkpath)
100
85
  end
101
- end
102
-
103
- def build_path(*path)
104
- make_path(build_dir, *path)
86
+ make_path(@build_path, *path)
105
87
  end
106
88
 
107
89
  def local_git_artifact_exclude_paths(&blk)
@@ -147,10 +129,6 @@ module Dapp
147
129
  end
148
130
 
149
131
  class << self
150
- def home_dir
151
- File.join(Dir.home, ".dapp")
152
- end
153
-
154
132
  def options
155
133
  @options ||= {}
156
134
  end
@@ -20,6 +20,10 @@ module Dapp::Dimg::CLI
20
20
  end
21
21
  end
22
22
  end
23
+
24
+ def run_method
25
+ class_to_lowercase
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -3,13 +3,11 @@ module Dapp
3
3
  module Config
4
4
  module Directive
5
5
  class GitArtifactRemote < GitArtifactLocal
6
- include ::Dapp::Helper::Url
7
-
8
6
  attr_reader :_url, :_name, :_branch, :_commit
9
7
 
10
8
  def initialize(url, **kwargs, &blk)
11
9
  @_url = url
12
- @_name = git_url_to_name(url)
10
+ @_name = url.gsub(%r{.*?([^\/ ]+)\.git}, '\\1')
13
11
 
14
12
  super(**kwargs, &blk)
15
13
  end
@@ -68,12 +68,12 @@ module Dapp
68
68
  stage.image.add_service_change_label :"dapp-git-#{paramshash}-type" => 'directory'
69
69
 
70
70
  commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{to}\""
71
- commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C \"#{to}\""
71
+ commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commit(stage))} -C \"#{to}\""
72
72
  when :file
73
73
  stage.image.add_service_change_label :"dapp-git-#{paramshash}-type" => 'file'
74
74
 
75
75
  commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{File.dirname(to)}\""
76
- commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C \"#{File.dirname(to)}\""
76
+ commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commit(stage))} -C \"#{File.dirname(to)}\""
77
77
  end
78
78
  end
79
79
  end
@@ -121,30 +121,34 @@ module Dapp
121
121
  def stage_dependencies_checksum(stage)
122
122
  return [] if (stage_dependencies = stages_dependencies[stage.name]).empty?
123
123
 
124
- paths = (include_paths(true) + base_paths(stage_dependencies, true)).uniq
125
- to_commit = dev_mode? ? nil : latest_commit
124
+ paths = base_paths(stage_dependencies, true)
125
+ commit = dev_mode? ? nil : latest_commit
126
126
 
127
- stage_dependencies_key = [stage.name, to_commit]
127
+ stage_dependencies_key = [stage.name, commit]
128
128
  @stage_dependencies_checksums ||= {}
129
129
  @stage_dependencies_checksums[stage_dependencies_key] = begin
130
130
  if @stage_dependencies_checksums.key?(stage_dependencies_key)
131
131
  @stage_dependencies_checksums[stage_dependencies_key]
132
132
  else
133
- if (patches = diff_patches(nil, to_commit, paths: paths)).empty?
133
+ if (entries = repo_entries(commit, paths: paths)).empty?
134
134
  repo.dimg.dapp.log_warning(desc: { code: :stage_dependencies_not_found,
135
135
  data: { repo: repo.respond_to?(:url) ? repo.url : 'local',
136
136
  dependencies: stage_dependencies.join(', ') } })
137
137
  end
138
138
 
139
- patches.sort_by {|patch| patch.delta.new_file[:path]}
140
- .reduce(nil) {|prev_hash, patch|
141
- Digest::SHA256.hexdigest [
142
- prev_hash,
143
- patch.delta.new_file[:path],
144
- patch.delta.new_file[:mode].to_s,
145
- patch.to_s
146
- ].compact.join(':::')
147
- }
139
+ entries
140
+ .sort_by {|root, entry| File.join(root, entry[:name])}
141
+ .reduce(nil) {|prev_hash, (root, entry)|
142
+ content = nil
143
+ content = repo.lookup_object(entry[:oid]).content if entry[:type] == :blob
144
+
145
+ Digest::SHA256.hexdigest [
146
+ prev_hash,
147
+ File.join(root, entry[:name]),
148
+ entry[:filemode].to_s,
149
+ content
150
+ ].compact.join(':::')
151
+ }
148
152
  end
149
153
  end
150
154
  end
@@ -187,7 +191,7 @@ module Dapp
187
191
  end
188
192
 
189
193
  def archive_any_changes?(stage)
190
- any_changes?(*archive_stage_commits(stage))
194
+ repo_entries(archive_stage_commit(stage)).any?
191
195
  end
192
196
 
193
197
  def patch_any_changes?(stage)
@@ -212,18 +216,18 @@ module Dapp
212
216
  [:owner, :group].map { |attr| "--#{attr}=#{send(attr)}" unless send(attr).nil? }.compact
213
217
  end
214
218
 
215
- def archive_file(stage, from_commit, to_commit)
219
+ def archive_file(stage, commit)
216
220
  if repo.dimg.dapp.options[:use_system_tar]
217
- archive_file_with_system_tar(stage, from_commit, to_commit)
221
+ archive_file_with_system_tar(stage, commit)
218
222
  else
219
- archive_file_with_tar_writer(stage, from_commit, to_commit)
223
+ archive_file_with_tar_writer(stage, commit)
220
224
  end
221
- repo.dimg.container_tmp_path('archives', archive_file_name(from_commit, to_commit))
225
+ repo.dimg.container_tmp_path('archives', archive_file_name(commit))
222
226
  end
223
227
 
224
- def archive_file_with_tar_writer(stage, from_commit, to_commit)
225
- tar_write(repo.dimg.tmp_path('archives', archive_file_name(from_commit, to_commit))) do |tar|
226
- archive_diff_pathes(stage,from_commit, to_commit) do |path, content, mode|
228
+ def archive_file_with_tar_writer(stage, commit)
229
+ tar_write(repo.dimg.tmp_path('archives', archive_file_name(commit))) do |tar|
230
+ each_archive_entry(stage, commit) do |path, content, mode|
227
231
  if mode == 40960 # symlink
228
232
  tar.add_symlink path, content, mode
229
233
  else
@@ -237,10 +241,10 @@ module Dapp
237
241
  raise Error::TarWriter, message: e.message
238
242
  end
239
243
 
240
- def archive_file_with_system_tar(stage, from_commit, to_commit)
241
- repo.dimg.tmp_path('archives', archive_file_name(from_commit, to_commit)).tap do |archive_path|
242
- relative_archive_file_path = File.join('archives_files', file_name(from_commit, to_commit))
243
- archive_diff_pathes(stage, from_commit, to_commit) do |path, content, mode|
244
+ def archive_file_with_system_tar(stage, commit)
245
+ repo.dimg.tmp_path('archives', archive_file_name(commit)).tap do |archive_path|
246
+ relative_archive_file_path = File.join('archives_files', file_name(commit))
247
+ each_archive_entry(stage, commit) do |path, content, mode|
244
248
  file_path = repo.dimg.tmp_path(relative_archive_file_path, path)
245
249
 
246
250
  if mode == 40960 # symlink
@@ -255,23 +259,6 @@ module Dapp
255
259
  end
256
260
  end
257
261
 
258
- def archive_diff_pathes(stage, from_commit, to_commit)
259
- diff_patches(from_commit, to_commit).each do |patch|
260
- entry = patch.delta.new_file
261
- raise_if_submodule_patch!(patch)
262
- content = begin
263
- if to_commit == nil
264
- next unless (path = repo.path.dirname.join(entry[:path])).file?
265
- File.read(path)
266
- else
267
- repo.lookup_object(entry[:oid]).content
268
- end
269
- end
270
-
271
- yield slice_cwd(stage, entry[:path]), content, entry[:mode]
272
- end
273
- end
274
-
275
262
  def slice_cwd(stage, path)
276
263
  return path if cwd.empty?
277
264
 
@@ -289,22 +276,21 @@ module Dapp
289
276
  end
290
277
  end
291
278
 
292
- def archive_file_name(from_commit, to_commit)
293
- file_name(from_commit, to_commit, ext: 'tar')
279
+ def archive_file_name(commit)
280
+ file_name(commit, ext: 'tar')
294
281
  end
295
282
 
296
283
  def patch_file(stage, from_commit, to_commit)
297
284
  File.open(repo.dimg.tmp_path('patches', patch_file_name(from_commit, to_commit)), File::RDWR | File::CREAT) do |f|
298
285
  diff_patches(from_commit, to_commit).each do |patch|
299
- raise_if_submodule_patch!(patch)
286
+ raise_if_submodule_entry!(patch.delta.new_file)
300
287
  f.write change_patch_new_file_path(stage, patch)
301
288
  end
302
289
  end
303
290
  repo.dimg.container_tmp_path('patches', patch_file_name(from_commit, to_commit))
304
291
  end
305
292
 
306
- def raise_if_submodule_patch!(patch) # FIXME
307
- entry = patch.delta.new_file
293
+ def raise_if_submodule_entry!(entry) # FIXME
308
294
  if entry[:mode] == 57344 # submodule
309
295
  raise Error::Rugged, code: :submodule_not_supported, data: { path: repo.path.dirname.join(entry[:path]) }
310
296
  end
@@ -371,6 +357,24 @@ module Dapp
371
357
  "#{[paramshash, args].flatten.compact.join('_')}#{".#{ext}" unless ext.nil? }"
372
358
  end
373
359
 
360
+ def repo_entries(commit, paths: include_paths_or_cwd)
361
+ (@repo_entries ||= {})[[commit, paths]] ||= begin
362
+ repo.entries(commit, paths: paths, exclude_paths: exclude_paths(true))
363
+ end
364
+ end
365
+
366
+ def each_archive_entry(stage, commit, &blk)
367
+ repo_entries(commit).each do |root, entry|
368
+ raise_if_submodule_entry!(entry)
369
+
370
+ if entry[:type] == :blob
371
+ content = repo.lookup_object(entry[:oid]).content
372
+
373
+ yield slice_cwd(stage, File.join(root, entry[:name])), content, entry[:filemode]
374
+ end
375
+ end
376
+ end
377
+
374
378
  def diff_patches(from_commit, to_commit, paths: include_paths_or_cwd)
375
379
  (@diff_patches ||= {})[[from_commit, to_commit, paths]] ||= begin
376
380
  options = {}.tap do |opts|
@@ -414,8 +418,8 @@ module Dapp
414
418
  end
415
419
  end
416
420
 
417
- def archive_stage_commits(stage)
418
- [nil, stage.layer_commit(self)]
421
+ def archive_stage_commit(stage)
422
+ stage.layer_commit(self)
419
423
  end
420
424
 
421
425
  def patch_stage_commits(stage)
@@ -31,6 +31,24 @@ module Dapp
31
31
  end
32
32
  end
33
33
 
34
+ def entries(commit, paths: [], exclude_paths: [])
35
+ [].tap do |entries|
36
+ lookup_commit(commit).tree.walk(:preorder) do |root, entry|
37
+ fullpath = File.join(root, entry[:name]).reverse.chomp('/').reverse
38
+
39
+ is_exclude_path = exclude_paths.any? { |p| check_path?(fullpath, p) }
40
+ is_include_path = begin
41
+ paths.empty? ||
42
+ paths.any? { |p| check_path?(fullpath, p) || check_subpath?(fullpath, p) }
43
+ end
44
+
45
+ next false if is_exclude_path || !is_include_path
46
+
47
+ entries << [root, entry]
48
+ end
49
+ end
50
+ end
51
+
34
52
  def diff(from, to, **kwargs)
35
53
  if to.nil?
36
54
  raise "Workdir diff not supported for #{self.class}"
@@ -89,12 +107,24 @@ module Dapp
89
107
  private
90
108
 
91
109
  def check_path?(path, format)
110
+ path_checker(path) do |checking_path|
111
+ File.fnmatch(format, checking_path)
112
+ end
113
+ end
114
+
115
+ def check_subpath?(path, format)
116
+ path_checker(format) do |checking_path|
117
+ File.fnmatch(checking_path, path)
118
+ end
119
+ end
120
+
121
+ def path_checker(path)
92
122
  path_parts = path.split('/')
93
123
  checking_path = nil
94
124
 
95
125
  until path_parts.empty?
96
126
  checking_path = [checking_path, path_parts.shift].compact.join('/')
97
- return true if File.fnmatch(format, checking_path)
127
+ return true if yield checking_path
98
128
  end
99
129
  false
100
130
  end
@@ -144,14 +144,7 @@ module Dapp
144
144
  end
145
145
 
146
146
  watch_hooks_thr = Thread.new do
147
- watch_hooks.each {|job|
148
- begin
149
- Kubernetes::Manager::Job.new(self, job.name).watch_till_done!
150
- rescue ::Exception => e
151
- sentry_exception(e, extra: {"job-spec" => job.spec})
152
- raise
153
- end
154
- }
147
+ watch_hooks.each {|job| Kubernetes::Manager::Job.new(self, job.name).watch_till_done!}
155
148
  end
156
149
 
157
150
  deployment_managers = release.deployments.values
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = '0.14.31'.freeze
3
- BUILD_CACHE_VERSION = 16
2
+ VERSION = '0.15.0'.freeze
3
+ BUILD_CACHE_VERSION = 17
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.31
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-16 00:00:00.000000000 Z
11
+ date: 2017-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -186,34 +186,6 @@ dependencies:
186
186
  - - ">="
187
187
  - !ruby/object:Gem::Version
188
188
  version: 1.0.6
189
- - !ruby/object:Gem::Dependency
190
- name: sentry-raven
191
- requirement: !ruby/object:Gem::Requirement
192
- requirements:
193
- - - "~>"
194
- - !ruby/object:Gem::Version
195
- version: 2.7.2
196
- type: :runtime
197
- prerelease: false
198
- version_requirements: !ruby/object:Gem::Requirement
199
- requirements:
200
- - - "~>"
201
- - !ruby/object:Gem::Version
202
- version: 2.7.2
203
- - !ruby/object:Gem::Dependency
204
- name: toml-rb
205
- requirement: !ruby/object:Gem::Requirement
206
- requirements:
207
- - - "~>"
208
- - !ruby/object:Gem::Version
209
- version: 1.1.1
210
- type: :runtime
211
- prerelease: false
212
- version_requirements: !ruby/object:Gem::Requirement
213
- requirements:
214
- - - "~>"
215
- - !ruby/object:Gem::Version
216
- version: 1.1.1
217
189
  - !ruby/object:Gem::Dependency
218
190
  name: bundler
219
191
  requirement: !ruby/object:Gem::Requirement
@@ -471,7 +443,6 @@ files:
471
443
  - lib/dapp/dapp/logging/i18n.rb
472
444
  - lib/dapp/dapp/logging/paint.rb
473
445
  - lib/dapp/dapp/logging/process.rb
474
- - lib/dapp/dapp/sentry.rb
475
446
  - lib/dapp/dapp/shellout/base.rb
476
447
  - lib/dapp/dapp/shellout/streaming.rb
477
448
  - lib/dapp/dapp/ssh_agent.rb
@@ -668,7 +639,6 @@ files:
668
639
  - lib/dapp/helper/sha256.rb
669
640
  - lib/dapp/helper/tar.rb
670
641
  - lib/dapp/helper/trivia.rb
671
- - lib/dapp/helper/url.rb
672
642
  - lib/dapp/helper/yaml.rb
673
643
  - lib/dapp/kube.rb
674
644
  - lib/dapp/kube/cli/cli.rb
@@ -736,7 +706,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
736
706
  version: 2.5.0
737
707
  requirements: []
738
708
  rubyforge_project:
739
- rubygems_version: 2.5.1
709
+ rubygems_version: 2.6.14
740
710
  signing_key:
741
711
  specification_version: 4
742
712
  summary: Build docker packaged apps using chef or shell
@@ -1,112 +0,0 @@
1
- module Dapp
2
- class Dapp
3
- module Sentry
4
- def sentry_message(msg, **kwargs)
5
- return if not ensure_sentry_configured
6
- kwargs[:level] ||= "info"
7
- Raven.capture_message(msg, _make_sentry_params(**kwargs))
8
- end
9
-
10
- def sentry_exception(exception, **kwargs)
11
- return if not ensure_sentry_configured
12
- (kwargs[:tags] ||= {})['error-code'] = begin
13
- net_status = exception.net_status
14
- [net_status[:context], net_status[:code]].compact.join('_')
15
- end
16
- Raven.capture_exception(exception, _make_sentry_params(**kwargs))
17
- end
18
-
19
- def ensure_sentry_configured
20
- return false unless sentry_settings = settings["sentry"]
21
-
22
- unless @sentry_settings_configured
23
- Raven.configure do |config|
24
- logger = ::Logger.new(STDOUT)
25
- logger.level = ::Logger::WARN
26
-
27
- config.logger = logger
28
- config.dsn = sentry_settings["dsn"]
29
- end
30
-
31
- @sentry_settings_configured = true
32
- end
33
-
34
- return true
35
- end
36
-
37
- def _make_sentry_params(level: nil, tags: {}, extra: {}, user: {})
38
- {
39
- level: level,
40
- tags: _sentry_tags_context.merge(tags),
41
- extra: _sentry_extra_context.merge(extra),
42
- user: _sentry_user_context.merge(user),
43
- }
44
- end
45
-
46
- def _sentry_extra_context
47
- @_sentry_extra_context ||= {
48
- "pwd" => Dir.pwd,
49
- "dapp-dir" => self.work_dir,
50
- "options" => self.options,
51
- "env-options" => {
52
- "DAPP_FORCE_SAVE_CACHE" => ENV["DAPP_FORCE_SAVE_CACHE"],
53
- "DAPP_BIN_DAPPFILE_YML" => ENV["DAPP_BIN_DAPPFILE_YML"],
54
- "ANSIBLE_ARGS" => ENV["ANSIBLE_ARGS"],
55
- "DAPP_CHEF_DEBUG" => ENV["DAPP_CHEF_DEBUG"],
56
- },
57
- }.tap {|extra|
58
- extra["ci-env"] = {"CI" => ENV["CI"]}
59
- ENV.select {|k, v| k.start_with?("CI_")}.each do |k, v|
60
- extra["ci-env"][k] = v
61
- end
62
- }
63
- end
64
-
65
- def _sentry_tags_context
66
- name = options[:name] ||
67
- @_sentry_tags_context ||= {
68
- "dapp-short-version" => ::Dapp::VERSION.split(".")[0..1].join("."),
69
- "dapp-version" => ::Dapp::VERSION,
70
- "dapp-build-cache-version" => ::Dapp::BUILD_CACHE_VERSION,
71
- "dapp-command" => self.options[:dapp_command],
72
- }.tap {|tags|
73
- git_config_path = File.join(Dir.pwd, ".git/config")
74
-
75
- tags["dapp-name"] = options[:name]
76
-
77
- if File.exists? git_config_path
78
- cfg = IniFile.load(File.join(Dir.pwd, ".git/config"))
79
- remote_origin_cfg = cfg['remote "origin"']
80
- remote_origin_url = remote_origin_cfg["url"]
81
- if remote_origin_url
82
- tags["dapp-name"] ||= begin
83
- repo_name = remote_origin_url.split('/').last
84
- repo_name = repo_name[/.*(?=\.git)/] if repo_name.end_with? '.git'
85
- repo_name
86
- end
87
-
88
- tags["git-host"] = self.get_host_from_git_url(remote_origin_url)
89
-
90
- git_name = self.git_url_to_name(remote_origin_url)
91
-
92
- tags["git-group"] = git_name.partition("/")[0]
93
- tags["git-name"] = git_name
94
- end
95
- end
96
-
97
- tags["dapp-name"] ||= File.basename(Dir.pwd)
98
-
99
- begin
100
- ver = self.class.host_docker_minor_version
101
- tags["docker-minor-version"] = ver.to_s
102
- rescue ::Exception
103
- end
104
- }
105
- end
106
-
107
- def _sentry_user_context
108
- @_sentry_user_context ||= {}
109
- end
110
- end # Sentry
111
- end # Dapp
112
- end # Dapp
@@ -1,23 +0,0 @@
1
- module Dapp
2
- module Helper
3
- module Url
4
- def git_url_to_name(url)
5
- url_without_scheme = url.split("://", 2).last
6
- # This may be broken, because "@" should delimit creds, not a ":"
7
- url_without_creds = url_without_scheme.split(":", 2).last
8
- url_without_creds.gsub(%r{.*?([^\/ ]+\/[^\/ ]+)\.git}, '\\1')
9
- end
10
-
11
- def get_host_from_git_url(url)
12
- url_without_scheme = url.split("://", 2).last
13
- url_without_creds = url_without_scheme.split("@", 2).last
14
-
15
- # Split out part after ":" in this kind of url: github.com:flant/dapp.git
16
- url_part = url_without_creds.split(":", 2).first
17
-
18
- # Split out part after first "/": github.com/flant/dapp.git
19
- url_part.split("/", 2).first
20
- end
21
- end # Url
22
- end # Helper
23
- end # Dapp