dapp 0.17.3 → 0.17.4
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 +5 -5
- 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 +8 -1
- data/lib/dapp/dapp.rb +26 -4
- data/lib/dapp/dapp/sentry.rb +112 -0
- data/lib/dapp/dimg/cli/command/base.rb +0 -4
- data/lib/dapp/dimg/config/directive/git_artifact_remote.rb +3 -1
- data/lib/dapp/helper/url.rb +23 -0
- data/lib/dapp/kube/dapp/command/deploy.rb +8 -1
- data/lib/dapp/version.rb +1 -1
- metadata +33 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 383aa5782985c5ec53607b5c9d802cb1213cdbc4
|
|
4
|
+
data.tar.gz: a5c8847516cb0359fb82c17731ddd56244860214
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 065aa5ccf4a7cd01db71db4a05364db97cc3177fc3781920a95d000c963c3286bffd193e5ee45e91e3b0ed6e52ab682b32c812d7fd9d6e53a07fbba08a4253f5
|
|
7
|
+
data.tar.gz: a30bf5b6583baa077adf31c316b3796bf0688aa5d722eadea1a4bcf580208087d7dce1cc9507ca1ff783a1c4f56813408e040e5d6d1108250f926cb539f52280
|
data/bin/dapp
CHANGED
data/lib/dapp.rb
CHANGED
|
@@ -24,6 +24,8 @@ require 'openssl'
|
|
|
24
24
|
require 'etc'
|
|
25
25
|
require 'zlib'
|
|
26
26
|
require 'slugify'
|
|
27
|
+
require 'sentry-raven'
|
|
28
|
+
require 'toml-rb'
|
|
27
29
|
|
|
28
30
|
require 'dapp/version'
|
|
29
31
|
require 'dapp/core_ext/hash'
|
|
@@ -34,6 +36,7 @@ require 'dapp/helper/sha256'
|
|
|
34
36
|
require 'dapp/helper/net_status'
|
|
35
37
|
require 'dapp/helper/tar'
|
|
36
38
|
require 'dapp/helper/yaml'
|
|
39
|
+
require 'dapp/helper/url'
|
|
37
40
|
require 'dapp/prctl'
|
|
38
41
|
require 'dapp/error/base'
|
|
39
42
|
require 'dapp/error/dapp'
|
|
@@ -49,6 +52,7 @@ require 'dapp/config/config'
|
|
|
49
52
|
require 'dapp/config/error/config'
|
|
50
53
|
require 'dapp/dapp/lock'
|
|
51
54
|
require 'dapp/dapp/ssh_agent'
|
|
55
|
+
require 'dapp/dapp/sentry'
|
|
52
56
|
require 'dapp/dapp/git_artifact'
|
|
53
57
|
require 'dapp/dapp/dappfile'
|
|
54
58
|
require 'dapp/dapp/chef'
|
data/lib/dapp/cli.rb
CHANGED
|
@@ -58,6 +58,9 @@ 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
|
+
|
|
61
64
|
begin
|
|
62
65
|
if block_given?
|
|
63
66
|
yield dapp
|
|
@@ -67,12 +70,16 @@ module Dapp
|
|
|
67
70
|
end
|
|
68
71
|
end
|
|
69
72
|
|
|
73
|
+
def run_method
|
|
74
|
+
class_to_lowercase
|
|
75
|
+
end
|
|
76
|
+
|
|
70
77
|
def run(_argv = ARGV)
|
|
71
78
|
raise
|
|
72
79
|
end
|
|
73
80
|
|
|
74
81
|
def cli_options(**kwargs)
|
|
75
|
-
config.merge(**kwargs)
|
|
82
|
+
config.merge(dapp_command: run_method, **kwargs)
|
|
76
83
|
end
|
|
77
84
|
end
|
|
78
85
|
end
|
data/lib/dapp/dapp.rb
CHANGED
|
@@ -12,10 +12,13 @@ module Dapp
|
|
|
12
12
|
include Logging::Paint
|
|
13
13
|
|
|
14
14
|
include SshAgent
|
|
15
|
+
include Sentry
|
|
16
|
+
|
|
15
17
|
include Helper::Sha256
|
|
16
|
-
extend
|
|
18
|
+
extend Helper::Trivia
|
|
17
19
|
include Helper::Trivia
|
|
18
20
|
include Helper::Tar
|
|
21
|
+
include Helper::Url
|
|
19
22
|
|
|
20
23
|
include Deps::Gitartifact
|
|
21
24
|
include Deps::Base
|
|
@@ -35,6 +38,18 @@ module Dapp
|
|
|
35
38
|
self.class.options
|
|
36
39
|
end
|
|
37
40
|
|
|
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
|
+
|
|
38
53
|
def name
|
|
39
54
|
@name ||= begin
|
|
40
55
|
if git_url
|
|
@@ -75,15 +90,18 @@ module Dapp
|
|
|
75
90
|
self.class.tmp_base_dir
|
|
76
91
|
end
|
|
77
92
|
|
|
78
|
-
def
|
|
79
|
-
@
|
|
93
|
+
def build_dir
|
|
94
|
+
@build_dir ||= begin
|
|
80
95
|
if option_build_dir
|
|
81
96
|
Pathname.new(option_build_dir)
|
|
82
97
|
else
|
|
83
98
|
path('.dapp_build')
|
|
84
99
|
end.expand_path.tap(&:mkpath)
|
|
85
100
|
end
|
|
86
|
-
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def build_path(*path)
|
|
104
|
+
make_path(build_dir, *path)
|
|
87
105
|
end
|
|
88
106
|
|
|
89
107
|
def local_git_artifact_exclude_paths(&blk)
|
|
@@ -129,6 +147,10 @@ module Dapp
|
|
|
129
147
|
end
|
|
130
148
|
|
|
131
149
|
class << self
|
|
150
|
+
def home_dir
|
|
151
|
+
File.join(Dir.home, ".dapp")
|
|
152
|
+
end
|
|
153
|
+
|
|
132
154
|
def options
|
|
133
155
|
@options ||= {}
|
|
134
156
|
end
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
|
@@ -3,11 +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
|
-
@_name = url
|
|
12
|
+
@_name = git_url_to_name(url)
|
|
11
13
|
|
|
12
14
|
super(**kwargs, &blk)
|
|
13
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
|
|
@@ -144,7 +144,14 @@ module Dapp
|
|
|
144
144
|
end
|
|
145
145
|
|
|
146
146
|
watch_hooks_thr = Thread.new do
|
|
147
|
-
watch_hooks.each {|job|
|
|
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
|
+
}
|
|
148
155
|
end
|
|
149
156
|
|
|
150
157
|
deployment_managers = release.deployments.values
|
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.17.
|
|
4
|
+
version: 0.17.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Stolyarov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mixlib-shellout
|
|
@@ -186,6 +186,34 @@ 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
|
|
189
217
|
- !ruby/object:Gem::Dependency
|
|
190
218
|
name: bundler
|
|
191
219
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -443,6 +471,7 @@ files:
|
|
|
443
471
|
- lib/dapp/dapp/logging/i18n.rb
|
|
444
472
|
- lib/dapp/dapp/logging/paint.rb
|
|
445
473
|
- lib/dapp/dapp/logging/process.rb
|
|
474
|
+
- lib/dapp/dapp/sentry.rb
|
|
446
475
|
- lib/dapp/dapp/shellout/base.rb
|
|
447
476
|
- lib/dapp/dapp/shellout/streaming.rb
|
|
448
477
|
- lib/dapp/dapp/ssh_agent.rb
|
|
@@ -639,6 +668,7 @@ files:
|
|
|
639
668
|
- lib/dapp/helper/sha256.rb
|
|
640
669
|
- lib/dapp/helper/tar.rb
|
|
641
670
|
- lib/dapp/helper/trivia.rb
|
|
671
|
+
- lib/dapp/helper/url.rb
|
|
642
672
|
- lib/dapp/helper/yaml.rb
|
|
643
673
|
- lib/dapp/kube.rb
|
|
644
674
|
- lib/dapp/kube/cli/cli.rb
|
|
@@ -706,7 +736,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
706
736
|
version: 2.5.0
|
|
707
737
|
requirements: []
|
|
708
738
|
rubyforge_project:
|
|
709
|
-
rubygems_version: 2.
|
|
739
|
+
rubygems_version: 2.5.1
|
|
710
740
|
signing_key:
|
|
711
741
|
specification_version: 4
|
|
712
742
|
summary: Build docker packaged apps using chef or shell
|