dapp 0.26.12 → 0.26.13
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 +4 -4
- data/bin/dapp +4 -0
- data/lib/dapp.rb +4 -0
- data/lib/dapp/cli.rb +4 -0
- data/lib/dapp/cli/command/base.rb +7 -1
- data/lib/dapp/dapp.rb +22 -4
- data/lib/dapp/dapp/option_tags.rb +7 -1
- data/lib/dapp/dapp/sentry.rb +106 -0
- data/lib/dapp/dimg/cli/command/base.rb +0 -4
- data/lib/dapp/dimg/config/directive/git_artifact_remote.rb +3 -4
- data/lib/dapp/helper/url.rb +23 -0
- data/lib/dapp/kube/dapp/command/deploy.rb +1 -0
- data/lib/dapp/version.rb +1 -1
- metadata +32 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5d412d73ba9ef9e52304ba44ec6dff7e3d4061da
|
|
4
|
+
data.tar.gz: 8389156770f560f2795986f5d761fe258b006c1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eefabcec93c03e9510070449c1a426a32381b572b38df7a366b68d714a68c390e006d4d0b4f5eb5cbe1fa2299be1936d533225333d328032711eef11152b5794
|
|
7
|
+
data.tar.gz: 4719564edff45d34bc4e4ec1273679d817464b7dc492f76a83c19c1d41aec032220fb8dce36dc1fd6f8673dd464a5b26ec13f92598c4780da0812a6f4fb8fd7d
|
data/bin/dapp
CHANGED
data/lib/dapp.rb
CHANGED
|
@@ -28,6 +28,8 @@ require 'base64'
|
|
|
28
28
|
require 'io/console'
|
|
29
29
|
require 'net/http'
|
|
30
30
|
require 'progressbar'
|
|
31
|
+
require 'sentry-raven'
|
|
32
|
+
require 'toml-rb'
|
|
31
33
|
|
|
32
34
|
require 'dapp/version'
|
|
33
35
|
require 'dapp/core_ext/hash'
|
|
@@ -38,6 +40,7 @@ require 'dapp/helper/sha256'
|
|
|
38
40
|
require 'dapp/helper/net_status'
|
|
39
41
|
require 'dapp/helper/tar'
|
|
40
42
|
require 'dapp/helper/yaml'
|
|
43
|
+
require 'dapp/helper/url'
|
|
41
44
|
require 'dapp/prctl'
|
|
42
45
|
require 'dapp/error/mod/user'
|
|
43
46
|
require 'dapp/error/base'
|
|
@@ -58,6 +61,7 @@ require 'dapp/config/directive/base'
|
|
|
58
61
|
require 'dapp/config/config'
|
|
59
62
|
require 'dapp/dapp/lock'
|
|
60
63
|
require 'dapp/dapp/ssh_agent'
|
|
64
|
+
require 'dapp/dapp/sentry'
|
|
61
65
|
require 'dapp/dapp/git_artifact'
|
|
62
66
|
require 'dapp/dapp/dappfile'
|
|
63
67
|
require 'dapp/dapp/chef'
|
data/lib/dapp/cli.rb
CHANGED
|
@@ -58,6 +58,8 @@ module Dapp
|
|
|
58
58
|
|
|
59
59
|
def run_dapp_command(run_method, options: {}, log_running_time: true, try_host_docker_login: false)
|
|
60
60
|
dapp = ::Dapp::Dapp.new(options: options)
|
|
61
|
+
::Dapp::CLI.dapp_object = dapp
|
|
62
|
+
dapp.sentry_message("Manual usage: `#{options[:dapp_command]}` command") unless ENV['CI']
|
|
61
63
|
|
|
62
64
|
log_dapp_running_time(dapp, ignore: !log_running_time) do
|
|
63
65
|
begin
|
|
@@ -74,6 +76,10 @@ module Dapp
|
|
|
74
76
|
end
|
|
75
77
|
end
|
|
76
78
|
|
|
79
|
+
def run_method
|
|
80
|
+
class_to_lowercase
|
|
81
|
+
end
|
|
82
|
+
|
|
77
83
|
def log_dapp_running_time(dapp, ignore: false)
|
|
78
84
|
return yield if ignore
|
|
79
85
|
|
|
@@ -95,7 +101,7 @@ module Dapp
|
|
|
95
101
|
self.class.print_error_with_help_and_die! self, "cannot use alias options --run-dir, --build-dir, --deploy-dir at the same time"
|
|
96
102
|
end
|
|
97
103
|
|
|
98
|
-
config.merge(build_dir: dirs.compact.first, **kwargs)
|
|
104
|
+
config.merge(build_dir: dirs.compact.first, dapp_command: run_method, **kwargs)
|
|
99
105
|
end
|
|
100
106
|
end
|
|
101
107
|
end
|
data/lib/dapp/dapp.rb
CHANGED
|
@@ -17,10 +17,13 @@ module Dapp
|
|
|
17
17
|
include Logging::Paint
|
|
18
18
|
|
|
19
19
|
include SshAgent
|
|
20
|
+
include Sentry
|
|
21
|
+
|
|
20
22
|
include Helper::Sha256
|
|
21
|
-
extend
|
|
23
|
+
extend Helper::Trivia
|
|
22
24
|
include Helper::Trivia
|
|
23
25
|
include Helper::Tar
|
|
26
|
+
include Helper::Url
|
|
24
27
|
|
|
25
28
|
include Deps::Toolchain
|
|
26
29
|
include Deps::Gitartifact
|
|
@@ -43,6 +46,18 @@ module Dapp
|
|
|
43
46
|
self.class.options
|
|
44
47
|
end
|
|
45
48
|
|
|
49
|
+
def settings
|
|
50
|
+
@settings ||= begin
|
|
51
|
+
settings_path = File.join(self.class.home_dir, "settings.toml")
|
|
52
|
+
|
|
53
|
+
if File.exists? settings_path
|
|
54
|
+
TomlRB.load_file(settings_path)
|
|
55
|
+
else
|
|
56
|
+
{}
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
46
61
|
def name
|
|
47
62
|
@name ||= begin
|
|
48
63
|
n = begin
|
|
@@ -96,8 +111,8 @@ module Dapp
|
|
|
96
111
|
self.class.tmp_base_dir
|
|
97
112
|
end
|
|
98
113
|
|
|
99
|
-
def
|
|
100
|
-
@
|
|
114
|
+
def build_dir
|
|
115
|
+
@build_dir ||= begin
|
|
101
116
|
if option_build_dir
|
|
102
117
|
Pathname.new(option_build_dir)
|
|
103
118
|
else
|
|
@@ -105,7 +120,10 @@ module Dapp
|
|
|
105
120
|
Pathname.new(dir)
|
|
106
121
|
end.expand_path.tap(&:mkpath)
|
|
107
122
|
end
|
|
108
|
-
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def build_path(*path)
|
|
126
|
+
make_path(build_dir, *path)
|
|
109
127
|
end
|
|
110
128
|
|
|
111
129
|
def local_git_artifact_exclude_paths(&blk)
|
|
@@ -7,6 +7,12 @@ module Dapp
|
|
|
7
7
|
|
|
8
8
|
def tags_by_scheme
|
|
9
9
|
@tags_by_scheme_name ||= begin
|
|
10
|
+
if slug_tags[:custom].any?
|
|
11
|
+
if settings.fetch("sentry", {}).fetch("detect-push-tag-usage", false)
|
|
12
|
+
sentry_message("--tag or --tag-slug usage detected", extra: {"slug_tags" => slug_tags})
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
10
16
|
{}.tap do |tags_by_scheme|
|
|
11
17
|
[slug_tags, branch_tags, ci_tags].each do |_tags_by_scheme|
|
|
12
18
|
_tags_by_scheme.each do |scheme, tags|
|
|
@@ -89,4 +95,4 @@ module Dapp
|
|
|
89
95
|
end
|
|
90
96
|
end # Tags
|
|
91
97
|
end # Dapp
|
|
92
|
-
end # Dapp
|
|
98
|
+
end # Dapp
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
"build-dir" => self.build_dir,
|
|
51
|
+
"options" => self.options,
|
|
52
|
+
"env-options" => {
|
|
53
|
+
"DAPP_FORCE_SAVE_CACHE" => ENV["DAPP_FORCE_SAVE_CACHE"],
|
|
54
|
+
"DAPP_BIN_DAPPFILE_YML" => ENV["DAPP_BIN_DAPPFILE_YML"],
|
|
55
|
+
"ANSIBLE_ARGS" => ENV["ANSIBLE_ARGS"],
|
|
56
|
+
"DAPP_CHEF_DEBUG" => ENV["DAPP_CHEF_DEBUG"],
|
|
57
|
+
},
|
|
58
|
+
}.tap {|extra|
|
|
59
|
+
if git_own_repo_exist?
|
|
60
|
+
extra["git"] = {
|
|
61
|
+
"remote_origin_url" => git_own_repo.remote_origin_url, # may contain https token
|
|
62
|
+
"name" => self.git_url_to_name(git_own_repo.remote_origin_url),
|
|
63
|
+
"path" => git_own_repo.path,
|
|
64
|
+
"workdir_path" => git_own_repo.workdir_path,
|
|
65
|
+
"latest_commit" => git_own_repo.latest_commit,
|
|
66
|
+
}
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
extra["ci-env"] = {"CI" => ENV["CI"]}
|
|
70
|
+
ENV.select {|k, v| k.start_with?("CI_")}.each do |k, v|
|
|
71
|
+
extra["ci-env"][k] = v
|
|
72
|
+
end
|
|
73
|
+
}
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def _sentry_tags_context
|
|
77
|
+
@_sentry_tags_context ||= {
|
|
78
|
+
"dapp-name" => self.name,
|
|
79
|
+
"dapp-short-version" => ::Dapp::VERSION.split(".")[0..1].join("."),
|
|
80
|
+
"dapp-version" => ::Dapp::VERSION,
|
|
81
|
+
"dapp-build-cache-version" => ::Dapp::BUILD_CACHE_VERSION,
|
|
82
|
+
"dapp-command" => self.options[:dapp_command],
|
|
83
|
+
}.tap {|tags|
|
|
84
|
+
if git_own_repo_exist?
|
|
85
|
+
tags["git-host"] = self.get_host_from_git_url(git_own_repo.remote_origin_url)
|
|
86
|
+
|
|
87
|
+
git_name = self.git_url_to_name(git_own_repo.remote_origin_url)
|
|
88
|
+
|
|
89
|
+
tags["git-group"] = git_name.partition("/")[0]
|
|
90
|
+
tags["git-name"] = git_name
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
begin
|
|
94
|
+
ver = self.class.host_docker_minor_version
|
|
95
|
+
tags["docker-minor-version"] = ver.to_s
|
|
96
|
+
rescue ::Exception
|
|
97
|
+
end
|
|
98
|
+
}
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def _sentry_user_context
|
|
102
|
+
@__sentry_user_context ||= {}
|
|
103
|
+
end
|
|
104
|
+
end # Sentry
|
|
105
|
+
end # Dapp
|
|
106
|
+
end # Dapp
|
|
@@ -3,14 +3,13 @@ module Dapp
|
|
|
3
3
|
module Config
|
|
4
4
|
module Directive
|
|
5
5
|
class GitArtifactRemote < GitArtifactLocal
|
|
6
|
+
include ::Dapp::Helper::Url
|
|
7
|
+
|
|
6
8
|
attr_reader :_url, :_name, :_branch, :_commit
|
|
7
9
|
|
|
8
10
|
def initialize(url, **kwargs, &blk)
|
|
9
11
|
@_url = url
|
|
10
|
-
|
|
11
|
-
url_without_scheme = url.split("://", 2).last
|
|
12
|
-
url_without_creds = url_without_scheme.split(":", 2).last
|
|
13
|
-
@_name = url_without_creds.gsub(%r{.*?([^\/ ]+\/[^\/ ]+)\.git}, '\\1')
|
|
12
|
+
@_name = git_url_to_name(url)
|
|
14
13
|
|
|
15
14
|
super(**kwargs, &blk)
|
|
16
15
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -165,6 +165,7 @@ module Dapp
|
|
|
165
165
|
# Поэтому перехватываем и просто отображаем произошедшую
|
|
166
166
|
# ошибку для информации пользователю без завершения работы dapp.
|
|
167
167
|
$stderr.puts(::Dapp::Dapp.paint_string(::Dapp::Helper::NetStatus.message(e), :warning))
|
|
168
|
+
sentry_exception(e, extra: {"job-spec" => job.spec})
|
|
168
169
|
end
|
|
169
170
|
|
|
170
171
|
end # Thread
|
data/lib/dapp/version.rb
CHANGED
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.26.
|
|
4
|
+
version: 0.26.13
|
|
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-
|
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mixlib-shellout
|
|
@@ -200,6 +200,34 @@ dependencies:
|
|
|
200
200
|
- - "~>"
|
|
201
201
|
- !ruby/object:Gem::Version
|
|
202
202
|
version: 1.9.0
|
|
203
|
+
- !ruby/object:Gem::Dependency
|
|
204
|
+
name: sentry-raven
|
|
205
|
+
requirement: !ruby/object:Gem::Requirement
|
|
206
|
+
requirements:
|
|
207
|
+
- - "~>"
|
|
208
|
+
- !ruby/object:Gem::Version
|
|
209
|
+
version: 2.7.2
|
|
210
|
+
type: :runtime
|
|
211
|
+
prerelease: false
|
|
212
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
213
|
+
requirements:
|
|
214
|
+
- - "~>"
|
|
215
|
+
- !ruby/object:Gem::Version
|
|
216
|
+
version: 2.7.2
|
|
217
|
+
- !ruby/object:Gem::Dependency
|
|
218
|
+
name: toml-rb
|
|
219
|
+
requirement: !ruby/object:Gem::Requirement
|
|
220
|
+
requirements:
|
|
221
|
+
- - "~>"
|
|
222
|
+
- !ruby/object:Gem::Version
|
|
223
|
+
version: 1.1.1
|
|
224
|
+
type: :runtime
|
|
225
|
+
prerelease: false
|
|
226
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
227
|
+
requirements:
|
|
228
|
+
- - "~>"
|
|
229
|
+
- !ruby/object:Gem::Version
|
|
230
|
+
version: 1.1.1
|
|
203
231
|
- !ruby/object:Gem::Dependency
|
|
204
232
|
name: bundler
|
|
205
233
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -462,6 +490,7 @@ files:
|
|
|
462
490
|
- lib/dapp/dapp/logging/paint.rb
|
|
463
491
|
- lib/dapp/dapp/logging/process.rb
|
|
464
492
|
- lib/dapp/dapp/option_tags.rb
|
|
493
|
+
- lib/dapp/dapp/sentry.rb
|
|
465
494
|
- lib/dapp/dapp/shellout/base.rb
|
|
466
495
|
- lib/dapp/dapp/shellout/streaming.rb
|
|
467
496
|
- lib/dapp/dapp/slug.rb
|
|
@@ -666,6 +695,7 @@ files:
|
|
|
666
695
|
- lib/dapp/helper/sha256.rb
|
|
667
696
|
- lib/dapp/helper/tar.rb
|
|
668
697
|
- lib/dapp/helper/trivia.rb
|
|
698
|
+
- lib/dapp/helper/url.rb
|
|
669
699
|
- lib/dapp/helper/yaml.rb
|
|
670
700
|
- lib/dapp/kube.rb
|
|
671
701
|
- lib/dapp/kube/cli/cli.rb
|