dapp 0.19.11 → 0.20.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
- SHA1:
3
- metadata.gz: 3886b35e5f607e9753dfc72ca24008f6cc7c2723
4
- data.tar.gz: 11ba036e48859960e826cc769b8df3e4e60b98b6
2
+ SHA256:
3
+ metadata.gz: 25371f86eea9f7d1896fc258be654241cf1021c05bfdc472da2cd676e2bdda56
4
+ data.tar.gz: d2c8a9e2f4e116ab34ae80c8dae3cca09d31715cc0d80da2c71d06c323f04818
5
5
  SHA512:
6
- metadata.gz: 36cb56f06eadb64c74d13d423f50a2b737e2160919951463bf24c3bc3df0444b45779088a28ceb2c07169f056c6152f6c1720ad08e1b372cbf9a54a38d5751c6
7
- data.tar.gz: eb23d51a61669705e76103320b21f16e18fc1ead511c3daa1df28866901d1235c631ba548d382e7db0f6cf8ffaeef02328dad9311a8b3f5a1e6acadde5b3f5fa
6
+ metadata.gz: f89fc98080749f41fdf250897010079dd0aaa38c8ffabd1dbfc1874d5c30a40ff303521b2af0c3bc61781cafd93e97acf28562a0bd0cbccdd6c14da4a085d34e
7
+ data.tar.gz: e8c81970d2f75f1339aab19900874725f3147be4d82ad6febbaafa2863414065d64d65bdc79839bb62005e422d3f1d1b84ae4325d9f2aa3208e4975a74c83a25
data/bin/dapp CHANGED
@@ -26,10 +26,6 @@ begin
26
26
  $stderr.puts "\033[1m\033[90mStacktrace dumped to #{filename}\033[0m"
27
27
  end
28
28
 
29
- if Dapp::CLI.dapp_object
30
- Dapp::CLI.dapp_object.sentry_exception(e)
31
- end
32
-
33
29
  raise
34
30
  end
35
31
  rescue Dapp::Error::Shellout => e
data/config/en/common.yml CHANGED
@@ -17,9 +17,10 @@ en:
17
17
  git_artifact_fetch: "fetching remote git_artifact `%{url}`"
18
18
  vendoring_builder_cookbooks: 'vendoring builder cookbooks'
19
19
  waiting_resouce_lock: "waiting for locked resource `%{name}`"
20
- gitartifact_container_creating: 'creating dappdeps/gitartifact container'
21
- base_container_creating: 'creating dappdeps/base container'
22
- chefdk_container_creating: 'creating dappdeps/chefdk container'
20
+ gitartifact_container_creating: 'creating dappdeps/gitartifact container `%{name}`'
21
+ toolchain_container_creating: 'creating dappdeps/toolchain container `%{name}`'
22
+ base_container_creating: 'creating dappdeps/base container `%{name}`'
23
+ chefdk_container_creating: 'creating dappdeps/chefdk container `%{name}`'
23
24
  image_pull: "pulling image `%{name}`"
24
25
  image_push: "pushing image `%{name}`"
25
26
  image_save: "saving image `%{name}`"
data/lib/dapp.rb CHANGED
@@ -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'
@@ -61,6 +57,7 @@ require 'dapp/dapp/logging/base'
61
57
  require 'dapp/dapp/logging/process'
62
58
  require 'dapp/dapp/logging/paint'
63
59
  require 'dapp/dapp/logging/i18n'
60
+ require 'dapp/dapp/deps/toolchain'
64
61
  require 'dapp/dapp/deps/base'
65
62
  require 'dapp/dapp/deps/gitartifact'
66
63
  require 'dapp/dapp/shellout/streaming'
data/lib/dapp/cli.rb CHANGED
@@ -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
 
@@ -11,10 +11,6 @@ module Dapp
11
11
  long: '--build-dir PATH',
12
12
  description: 'Directory where build cache stored (DIR/.dapp_build by default)'
13
13
 
14
- option :name,
15
- long: "--name NAME",
16
- description: "Use custom dapp name. Chaging default name will cause full cache rebuild. By default dapp name is the last element of remote.origin.url from project git, or it is the name of the directory where Dappfile resides."
17
-
18
14
  option :quiet,
19
15
  short: '-q',
20
16
  long: '--quiet',
@@ -62,8 +58,6 @@ module Dapp
62
58
 
63
59
  def run_dapp_command(run_method, options: {}, log_running_time: true)
64
60
  dapp = ::Dapp::Dapp.new(options: options)
65
- ::Dapp::CLI.dapp_object = dapp
66
- dapp.sentry_message("Manual usage: `#{options[:dapp_command]}` command") unless ENV['CI']
67
61
 
68
62
  log_dapp_running_time(dapp, ignore: !log_running_time) do
69
63
  if block_given?
@@ -74,10 +68,6 @@ module Dapp
74
68
  end
75
69
  end
76
70
 
77
- def run_method
78
- class_to_lowercase
79
- end
80
-
81
71
  def log_dapp_running_time(dapp, ignore: false)
82
72
  return yield if ignore
83
73
 
@@ -94,7 +84,7 @@ module Dapp
94
84
  end
95
85
 
96
86
  def cli_options(**kwargs)
97
- config.merge(dapp_command: run_method, **kwargs)
87
+ config.merge(**kwargs)
98
88
  end
99
89
  end
100
90
  end
data/lib/dapp/dapp.rb CHANGED
@@ -12,14 +12,12 @@ 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
 
20
+ include Deps::Toolchain
23
21
  include Deps::Gitartifact
24
22
  include Deps::Base
25
23
 
@@ -38,23 +36,9 @@ module Dapp
38
36
  self.class.options
39
37
  end
40
38
 
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
39
  def name
54
40
  @name ||= begin
55
- if name = options[:name]
56
- name
57
- elsif git_url
41
+ if git_url
58
42
  repo_name = git_url.split('/').last
59
43
  repo_name = repo_name[/.*(?=\.git)/] if repo_name.end_with? '.git'
60
44
  repo_name
@@ -92,18 +76,15 @@ module Dapp
92
76
  self.class.tmp_base_dir
93
77
  end
94
78
 
95
- def build_dir
96
- @build_dir ||= begin
79
+ def build_path(*path)
80
+ @build_path ||= begin
97
81
  if option_build_dir
98
82
  Pathname.new(option_build_dir)
99
83
  else
100
84
  path('.dapp_build')
101
85
  end.expand_path.tap(&:mkpath)
102
86
  end
103
- end
104
-
105
- def build_path(*path)
106
- make_path(build_dir, *path)
87
+ make_path(@build_path, *path)
107
88
  end
108
89
 
109
90
  def local_git_artifact_exclude_paths(&blk)
@@ -149,10 +130,6 @@ module Dapp
149
130
  end
150
131
 
151
132
  class << self
152
- def home_dir
153
- File.join(Dir.home, ".dapp")
154
- end
155
-
156
133
  def options
157
134
  @options ||= {}
158
135
  end
@@ -2,7 +2,7 @@ module Dapp
2
2
  class Dapp
3
3
  module Deps
4
4
  module Base
5
- BASE_VERSION = '0.1.15'.freeze
5
+ BASE_VERSION = "0.2.1"
6
6
 
7
7
  def base_container_name # FIXME: hashsum(image) or dockersafe()
8
8
  "dappdeps_base_#{BASE_VERSION}"
@@ -10,13 +10,18 @@ module Dapp
10
10
 
11
11
  def base_container
12
12
  @base_container ||= begin
13
- if shellout("#{host_docker} inspect #{base_container_name}").exitstatus.nonzero?
14
- log_secondary_process(t(code: 'process.base_container_creating'), short: true) do
15
- shellout!(
16
- ["#{host_docker} create",
17
- "--name #{base_container_name}",
18
- "--volume /.dapp/deps/base/#{BASE_VERSION} dappdeps/base:#{BASE_VERSION}"].join(' ')
19
- )
13
+ is_container_exist = proc{shellout("#{host_docker} inspect #{base_container_name}").exitstatus.zero?}
14
+ if !is_container_exist.call
15
+ lock("dappdeps.container.#{base_container_name}", default_timeout: 120, type: :global) do
16
+ if !is_container_exist.call
17
+ log_secondary_process(t(code: 'process.base_container_creating', data: {name: base_container_name}), short: true) do
18
+ shellout!(
19
+ ["#{host_docker} create",
20
+ "--name #{base_container_name}",
21
+ "--volume /.dapp/deps/base/#{BASE_VERSION} dappdeps/base:#{BASE_VERSION}"].join(' ')
22
+ )
23
+ end
24
+ end
20
25
  end
21
26
  end
22
27
  base_container_name
@@ -26,7 +31,7 @@ module Dapp
26
31
  %w(rm rsync diff date cat
27
32
  stat readlink test sleep mkdir
28
33
  install sed cp true find
29
- bash tar sudo).each do |cmd|
34
+ bash tar sudo base64).each do |cmd|
30
35
  define_method("#{cmd}_bin") { "/.dapp/deps/base/#{BASE_VERSION}/bin/#{cmd}" }
31
36
  end
32
37
 
@@ -2,7 +2,7 @@ module Dapp
2
2
  class Dapp
3
3
  module Deps
4
4
  module Gitartifact
5
- GITARTIFACT_VERSION = '0.1.7'.freeze
5
+ GITARTIFACT_VERSION = "0.2.1"
6
6
 
7
7
  def gitartifact_container_name # FIXME: hashsum(image) or dockersafe()
8
8
  "dappdeps_gitartifact_#{GITARTIFACT_VERSION}"
@@ -10,14 +10,19 @@ module Dapp
10
10
 
11
11
  def gitartifact_container
12
12
  @gitartifact_container ||= begin
13
- if shellout("#{host_docker} inspect #{gitartifact_container_name}").exitstatus.nonzero?
14
- log_secondary_process(t(code: 'process.gitartifact_container_creating'), short: true) do
15
- shellout!(
16
- ["#{host_docker} create",
17
- "--name #{gitartifact_container_name}",
18
- "--volume /.dapp/deps/gitartifact/#{GITARTIFACT_VERSION}",
19
- "dappdeps/gitartifact:#{GITARTIFACT_VERSION}"].join(' ')
20
- )
13
+ is_container_exist = proc{shellout("#{host_docker} inspect #{gitartifact_container_name}").exitstatus.zero?}
14
+ if !is_container_exist.call
15
+ lock("dappdeps.container.#{gitartifact_container_name}", default_timeout: 120, type: :global) do
16
+ if !is_container_exist.call
17
+ log_secondary_process(t(code: 'process.gitartifact_container_creating', data: {name: gitartifact_container_name}), short: true) do
18
+ shellout!(
19
+ ["#{host_docker} create",
20
+ "--name #{gitartifact_container_name}",
21
+ "--volume /.dapp/deps/gitartifact/#{GITARTIFACT_VERSION}",
22
+ "dappdeps/gitartifact:#{GITARTIFACT_VERSION}"].join(' ')
23
+ )
24
+ end
25
+ end
21
26
  end
22
27
  end
23
28
  gitartifact_container_name
@@ -0,0 +1,33 @@
1
+ module Dapp
2
+ class Dapp
3
+ module Deps
4
+ module Toolchain
5
+ TOOLCHAIN_VERSION = "0.1.1"
6
+
7
+ def toolchain_container_name # FIXME: hashsum(image) or dockersafe()
8
+ "dappdeps_toolchain_#{TOOLCHAIN_VERSION}"
9
+ end
10
+
11
+ def toolchain_container
12
+ @toolchain_container ||= begin
13
+ is_container_exist = proc {shellout("#{host_docker} inspect #{toolchain_container_name}").exitstatus.zero?}
14
+ if !is_container_exist.call
15
+ lock("dappdeps.container.#{toolchain_container_name}", default_timeout: 300, type: :global) do
16
+ if !is_container_exist.call
17
+ log_secondary_process(t(code: 'process.toolchain_container_creating', data: {name: toolchain_container_name}), short: true) do
18
+ shellout!(
19
+ ["#{host_docker} create",
20
+ "--name #{toolchain_container_name}",
21
+ "--volume /.dapp/deps/toolchain/#{TOOLCHAIN_VERSION} dappdeps/toolchain:#{TOOLCHAIN_VERSION}"].join(' ')
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
27
+ toolchain_container_name
28
+ end
29
+ end
30
+ end # Toolchain
31
+ end # Deps
32
+ end # Dapp
33
+ end # Dapp
@@ -1,21 +1,31 @@
1
1
  module Dapp
2
2
  class Dapp
3
3
  module Lock
4
- def lock_path
5
- build_path.join('locks')
4
+ def lock_path(type)
5
+ case type
6
+ when :dapp
7
+ build_path.join('locks')
8
+ when :global
9
+ Pathname.new("/tmp/dapp.global.locks").tap do |p|
10
+ FileUtils.mkdir_p p.to_s
11
+ end
12
+ else
13
+ raise
14
+ end
6
15
  end
7
16
 
8
- def _lock(name)
17
+ def _lock(name, type)
9
18
  @_locks ||= {}
10
- @_locks[name] ||= ::Dapp::Dimg::Lock::File.new(lock_path, name)
19
+ @_locks[type] ||= {}
20
+ @_locks[type][name] ||= ::Dapp::Dimg::Lock::File.new(lock_path(type), name)
11
21
  end
12
22
 
13
- def lock(name, *_args, default_timeout: 300, **kwargs, &blk)
23
+ def lock(name, *_args, default_timeout: 300, type: :dapp, **kwargs, &blk)
14
24
  if dry_run?
15
25
  yield if block_given?
16
26
  else
17
27
  timeout = options[:lock_timeout] || default_timeout
18
- _lock(name).synchronize(
28
+ _lock(name, type).synchronize(
19
29
  timeout: timeout,
20
30
  on_wait: proc do |&do_wait|
21
31
  log_secondary_process(
@@ -37,7 +37,7 @@ module Dapp
37
37
  end
38
38
 
39
39
  def shellout_pack(command)
40
- "eval $(echo #{Base64.strict_encode64(command)} | base64 --decode)"
40
+ "eval $(echo #{Base64.strict_encode64(command)} | #{base64_bin} --decode)"
41
41
  end
42
42
 
43
43
  class << self
@@ -58,6 +58,7 @@ module Dapp
58
58
  def run_artifact_dimg(artifact_dimg, artifact_name, commands)
59
59
  docker_options = ['--rm',
60
60
  "--volume #{dimg.tmp_path('artifact', artifact_name)}:#{artifact_dimg.container_tmp_path(artifact_name)}",
61
+ "--volumes-from #{dimg.dapp.toolchain_container}",
61
62
  "--volumes-from #{dimg.dapp.base_container}",
62
63
  "--entrypoint #{dimg.dapp.bash_bin}"]
63
64
  dimg.dapp.log_secondary_process(dimg.dapp.t(code: 'process.artifact_copy', data: { name: artifact_name }), short: true) do
@@ -80,6 +80,8 @@ module Dapp
80
80
 
81
81
  def prepare_image
82
82
  return if dimg.dapp.dry_run?
83
+
84
+ image.add_volumes_from dimg.dapp.toolchain_container
83
85
  image.add_volumes_from dimg.dapp.base_container
84
86
 
85
87
  image_add_mounts
@@ -188,7 +190,7 @@ module Dapp
188
190
 
189
191
  def layer_commit(git_artifact)
190
192
  commits[git_artifact] ||= begin
191
- if image.built?
193
+ if image.tagged?
192
194
  image.labels["dapp-git-#{git_artifact.paramshash}-commit"]
193
195
  else
194
196
  git_artifact.latest_commit
@@ -1,7 +1,15 @@
1
1
  module Dapp
2
2
  module Dimg
3
3
  class Builder::Chef < Builder::Base
4
- DEFAULT_CHEFDK_IMAGE = 'dappdeps/chefdk:1.2.22-1'.freeze # TODO: config, DSL, DEFAULT_CHEFDK_IMAGE
4
+ CHEFDK_VERSION = "2.3.17-2"
5
+
6
+ def chef_solo_bin
7
+ "/.dapp/deps/chefdk/#{CHEFDK_VERSION}/bin/chef-solo"
8
+ end
9
+
10
+ def berks_bin
11
+ "/.dapp/deps/chefdk/#{CHEFDK_VERSION}/bin/berks"
12
+ end
5
13
 
6
14
  %i(before_install install before_setup setup build_artifact).each do |stage|
7
15
  define_method("#{stage}?") {!stage_empty?(stage)}
@@ -16,7 +24,7 @@ module Dapp
16
24
  unless stage_empty?(stage)
17
25
  image.add_volumes_from(chefdk_container)
18
26
  image.add_volume "#{stage_build_path(stage)}:#{container_stage_build_path(stage)}:ro"
19
- image.add_command ['/.dapp/deps/chefdk/bin/chef-solo',
27
+ image.add_command [chef_solo_bin,
20
28
  '--legacy-mode',
21
29
  "--config #{container_stage_config_path(stage)}",
22
30
  "--json-attributes #{container_stage_json_attributes_path(stage)}",
@@ -45,25 +53,29 @@ module Dapp
45
53
  end
46
54
 
47
55
  def chefdk_image
48
- DEFAULT_CHEFDK_IMAGE # TODO: config, DSL, DEFAULT_CHEFDK_IMAGE
56
+ "dappdeps/chefdk:#{CHEFDK_VERSION}" # TODO: config, DSL, DEFAULT_CHEFDK_IMAGE
49
57
  end
50
58
 
51
59
  def chefdk_container_name # FIXME: hashsum(image) or dockersafe()
52
- chefdk_image.tr('/', '_').tr(':', '_')
60
+ "dappdeps_chefdk_#{CHEFDK_VERSION}"
53
61
  end
54
62
 
55
63
  def chefdk_container
56
64
  @chefdk_container ||= begin
57
- if dimg.dapp.shellout("#{dimg.dapp.host_docker} inspect #{chefdk_container_name}").exitstatus.nonzero?
58
- dimg.dapp.log_secondary_process(dimg.dapp.t(code: 'process.chefdk_container_creating'), short: true) do
59
- dimg.dapp.shellout!(
60
- ["#{dimg.dapp.host_docker} create",
61
- "--name #{chefdk_container_name}",
62
- "--volume /.dapp/deps/chefdk #{chefdk_image}"].join(' ')
63
- )
65
+ is_container_exist = proc{dimg.dapp.shellout("#{dimg.dapp.host_docker} inspect #{chefdk_container_name}").exitstatus.zero?}
66
+ if !is_container_exist.call
67
+ dimg.dapp.lock("dappdeps.container.#{chefdk_container_name}", default_timeout: 120, type: :global) do
68
+ if !is_container_exist.call
69
+ dimg.dapp.log_secondary_process(dimg.dapp.t(code: 'process.chefdk_container_creating', data: {name: chefdk_container_name}), short: true) do
70
+ dimg.dapp.shellout!(
71
+ ["#{dimg.dapp.host_docker} create",
72
+ "--name #{chefdk_container_name}",
73
+ "--volume /.dapp/deps/chefdk/#{CHEFDK_VERSION} #{chefdk_image}"].join(' ')
74
+ )
75
+ end
76
+ end
64
77
  end
65
78
  end
66
-
67
79
  chefdk_container_name
68
80
  end
69
81
  end
@@ -74,11 +74,9 @@ module Dapp
74
74
 
75
75
  # rubocop:disable Metrics/AbcSize
76
76
  def vendor!
77
- volumes_from = [builder.dimg.dapp.base_container, builder.chefdk_container]
77
+ volumes_from = [builder.dimg.dapp.toolchain_container, builder.dimg.dapp.base_container, builder.chefdk_container]
78
78
 
79
79
  builder.dimg.dapp.log_secondary_process(builder.dimg.dapp.t(code: _vendor_process_name)) do
80
- volumes_from = [builder.dimg.dapp.base_container, builder.chefdk_container]
81
-
82
80
  tmp_berksfile_path = builder.dimg.tmp_path.join("Berksfile.#{SecureRandom.uuid}")
83
81
  File.open(tmp_berksfile_path, 'w') {|file| file.write berksfile.dump}
84
82
 
@@ -93,7 +91,7 @@ module Dapp
93
91
  "cd /tmp/local_cookbooks/#{path}",
94
92
  "cp #{tmp_berksfile_path} Berksfile",
95
93
  "cp #{tmp_metadata_path} metadata.rb",
96
- '/.dapp/deps/chefdk/bin/berks vendor /tmp/cookbooks',
94
+ "#{builder.berks_bin} vendor /tmp/cookbooks",
97
95
  ["#{builder.dimg.dapp.find_bin} /tmp/cookbooks -type d -exec #{builder.dimg.dapp.bash_bin} -ec '",
98
96
  "#{builder.dimg.dapp.install_bin} -o #{Process.uid} -g #{Process.gid} ",
99
97
  "--mode $(#{builder.dimg.dapp.stat_bin} -c %a {}) -d ",
@@ -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
@@ -59,14 +59,7 @@ module Dapp
59
59
  end
60
60
 
61
61
  watch_hooks_thr = Thread.new do
62
- watch_hooks.each {|job|
63
- begin
64
- Kubernetes::Manager::Job.new(self, job.name).watch_till_done!
65
- rescue ::Exception => e
66
- sentry_exception(e, extra: {"job-spec" => job.spec})
67
- raise
68
- end
69
- }
62
+ watch_hooks.each {|job| Kubernetes::Manager::Job.new(self, job.name).watch_till_done!}
70
63
  end
71
64
 
72
65
  deployment_managers = release.deployments.values
data/lib/dapp/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = '0.19.11'.freeze
3
- BUILD_CACHE_VERSION = 22.1
2
+ VERSION = '0.20.0'.freeze
3
+ BUILD_CACHE_VERSION = 23
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.19.11
4
+ version: 0.20.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-11-24 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
@@ -465,13 +437,13 @@ files:
465
437
  - lib/dapp/dapp/dappfile.rb
466
438
  - lib/dapp/dapp/deps/base.rb
467
439
  - lib/dapp/dapp/deps/gitartifact.rb
440
+ - lib/dapp/dapp/deps/toolchain.rb
468
441
  - lib/dapp/dapp/git_artifact.rb
469
442
  - lib/dapp/dapp/lock.rb
470
443
  - lib/dapp/dapp/logging/base.rb
471
444
  - lib/dapp/dapp/logging/i18n.rb
472
445
  - lib/dapp/dapp/logging/paint.rb
473
446
  - lib/dapp/dapp/logging/process.rb
474
- - lib/dapp/dapp/sentry.rb
475
447
  - lib/dapp/dapp/shellout/base.rb
476
448
  - lib/dapp/dapp/shellout/streaming.rb
477
449
  - lib/dapp/dapp/ssh_agent.rb
@@ -663,7 +635,6 @@ files:
663
635
  - lib/dapp/helper/sha256.rb
664
636
  - lib/dapp/helper/tar.rb
665
637
  - lib/dapp/helper/trivia.rb
666
- - lib/dapp/helper/url.rb
667
638
  - lib/dapp/helper/yaml.rb
668
639
  - lib/dapp/kube.rb
669
640
  - lib/dapp/kube/cli/cli.rb
@@ -735,7 +706,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
735
706
  version: 2.5.0
736
707
  requirements: []
737
708
  rubyforge_project:
738
- rubygems_version: 2.5.1
709
+ rubygems_version: 2.7.2
739
710
  signing_key:
740
711
  specification_version: 4
741
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