dapp 0.13.26 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dapp +0 -4
- data/lib/dapp.rb +0 -4
- data/lib/dapp/cli.rb +0 -4
- data/lib/dapp/cli/command/base.rb +1 -5
- data/lib/dapp/config/config.rb +4 -0
- data/lib/dapp/dapp.rb +3 -29
- data/lib/dapp/dapp/dappfile.rb +1 -0
- data/lib/dapp/dimg/build/stage/ga_latest_patch.rb +1 -1
- data/lib/dapp/dimg/cli/command/base.rb +4 -0
- data/lib/dapp/dimg/config/config.rb +4 -0
- data/lib/dapp/dimg/config/directive/dimg/instance_methods.rb +40 -0
- data/lib/dapp/dimg/config/directive/dimg/validation.rb +1 -5
- data/lib/dapp/dimg/config/directive/git_artifact_remote.rb +1 -3
- data/lib/dapp/dimg/git_artifact.rb +108 -23
- data/lib/dapp/dimg/git_repo/own.rb +4 -0
- data/lib/dapp/kube/dapp/command/deploy.rb +1 -8
- data/lib/dapp/kube/kubernetes/client.rb +1 -6
- data/lib/dapp/version.rb +2 -2
- metadata +3 -33
- data/lib/dapp/dapp/sentry.rb +0 -112
- data/lib/dapp/helper/url.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 895148a805cfe81e9fd0b6b11fe3dfc58f746a6f
|
4
|
+
data.tar.gz: a07d1a3ae7209847e5fa836464a5ab9a6f3d4c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb6190e22c37d6f3709cfe881485e994c3084e0480a10548cab4072ef5eeaf66baf2cca6d81638aaf42781b57f92cf3a07b01a7e26bbcbc3eed873e87796bf00
|
7
|
+
data.tar.gz: 62e11ceb271eb71ae7a68e459da907c10f1d8a6ecd08608c99d58a186b7788ac0ce39614a84065dcd1c17963f6cd91ab19a0fba78f544768c87b8fcb4e72ac1e
|
data/bin/dapp
CHANGED
data/lib/dapp.rb
CHANGED
@@ -23,8 +23,6 @@ require 'yaml'
|
|
23
23
|
require 'openssl'
|
24
24
|
require 'etc'
|
25
25
|
require 'zlib'
|
26
|
-
require 'sentry-raven'
|
27
|
-
require 'toml-rb'
|
28
26
|
|
29
27
|
require 'dapp/version'
|
30
28
|
require 'dapp/core_ext/hash'
|
@@ -35,7 +33,6 @@ require 'dapp/helper/sha256'
|
|
35
33
|
require 'dapp/helper/net_status'
|
36
34
|
require 'dapp/helper/tar'
|
37
35
|
require 'dapp/helper/yaml'
|
38
|
-
require 'dapp/helper/url'
|
39
36
|
require 'dapp/prctl'
|
40
37
|
require 'dapp/error/base'
|
41
38
|
require 'dapp/error/dapp'
|
@@ -51,7 +48,6 @@ require 'dapp/config/config'
|
|
51
48
|
require 'dapp/config/error/config'
|
52
49
|
require 'dapp/dapp/lock'
|
53
50
|
require 'dapp/dapp/ssh_agent'
|
54
|
-
require 'dapp/dapp/sentry'
|
55
51
|
require 'dapp/dapp/git_artifact'
|
56
52
|
require 'dapp/dapp/dappfile'
|
57
53
|
require 'dapp/dapp/chef'
|
data/lib/dapp/cli.rb
CHANGED
@@ -56,16 +56,12 @@ module Dapp
|
|
56
56
|
super()
|
57
57
|
end
|
58
58
|
|
59
|
-
def run_method
|
60
|
-
class_to_lowercase
|
61
|
-
end
|
62
|
-
|
63
59
|
def run(_argv = ARGV)
|
64
60
|
raise
|
65
61
|
end
|
66
62
|
|
67
63
|
def cli_options(**kvargs)
|
68
|
-
config.merge(
|
64
|
+
config.merge(**kvargs)
|
69
65
|
end
|
70
66
|
end
|
71
67
|
end
|
data/lib/dapp/config/config.rb
CHANGED
data/lib/dapp/dapp.rb
CHANGED
@@ -12,13 +12,9 @@ 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
|
19
16
|
include Helper::Trivia
|
20
17
|
include Helper::Tar
|
21
|
-
include Helper::Url
|
22
18
|
|
23
19
|
include Deps::Gitartifact
|
24
20
|
include Deps::Base
|
@@ -32,21 +28,6 @@ module Dapp
|
|
32
28
|
Logging::I18n.initialize
|
33
29
|
validate_config_options!
|
34
30
|
Logging::Paint.initialize(option_color)
|
35
|
-
|
36
|
-
::Dapp::CLI.dapp_object = self
|
37
|
-
sentry_message("Manual usage: `#{options[:dapp_command]}` command") unless ENV['CI']
|
38
|
-
end
|
39
|
-
|
40
|
-
def settings
|
41
|
-
@settings ||= begin
|
42
|
-
settings_path = File.join(self.class.home_dir, "settings.toml")
|
43
|
-
|
44
|
-
if File.exists? settings_path
|
45
|
-
TomlRB.load_file(settings_path)
|
46
|
-
else
|
47
|
-
{}
|
48
|
-
end
|
49
|
-
end
|
50
31
|
end
|
51
32
|
|
52
33
|
def name
|
@@ -89,18 +70,15 @@ module Dapp
|
|
89
70
|
File.expand_path(options[:tmp_dir_prefix] || '/tmp')
|
90
71
|
end
|
91
72
|
|
92
|
-
def
|
93
|
-
@
|
73
|
+
def build_path(*path)
|
74
|
+
@build_path ||= begin
|
94
75
|
if option_build_dir
|
95
76
|
Pathname.new(option_build_dir)
|
96
77
|
else
|
97
78
|
path('.dapp_build')
|
98
79
|
end.expand_path.tap(&:mkpath)
|
99
80
|
end
|
100
|
-
|
101
|
-
|
102
|
-
def build_path(*path)
|
103
|
-
make_path(build_dir, *path)
|
81
|
+
make_path(@build_path, *path)
|
104
82
|
end
|
105
83
|
|
106
84
|
def local_git_artifact_exclude_paths(&blk)
|
@@ -124,10 +102,6 @@ module Dapp
|
|
124
102
|
self.class.host_docker_bin
|
125
103
|
end
|
126
104
|
|
127
|
-
def self.home_dir
|
128
|
-
File.join(Dir.home, ".dapp")
|
129
|
-
end
|
130
|
-
|
131
105
|
def self.host_docker_bin
|
132
106
|
@host_docker_bin ||= begin
|
133
107
|
raise Error::Dapp, code: :docker_not_found if (res = shellout('which docker')).exitstatus.nonzero?
|
data/lib/dapp/dapp/dappfile.rb
CHANGED
@@ -33,6 +33,7 @@ module Dapp
|
|
33
33
|
::Dapp::Config::Config.new(dapp: self).tap do |config|
|
34
34
|
begin
|
35
35
|
config.instance_eval File.read(dappfile_path), dappfile_path
|
36
|
+
config.after_parsing!
|
36
37
|
config.validate!
|
37
38
|
rescue SyntaxError, StandardError => e
|
38
39
|
backtrace = e.backtrace.find { |line| line.start_with?(dappfile_path) }
|
@@ -8,6 +8,10 @@ module Dapp
|
|
8
8
|
|
9
9
|
protected
|
10
10
|
|
11
|
+
def dimg_after_parsing!
|
12
|
+
_dimg.each(&:artifacts_after_parsing!)
|
13
|
+
end
|
14
|
+
|
11
15
|
def dimg_config_validate!
|
12
16
|
raise Error::Config, code: :dimg_name_required if _dimg.any? { |dimg| dimg._name.nil? } && _dimg.size > 1
|
13
17
|
_dimg.each(&:validate!)
|
@@ -130,6 +130,10 @@ module Dapp
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
+
def artifacts_after_parsing!
|
134
|
+
_artifacts_auto_excluding!
|
135
|
+
end
|
136
|
+
|
133
137
|
protected
|
134
138
|
|
135
139
|
def builder(type)
|
@@ -140,6 +144,42 @@ module Dapp
|
|
140
144
|
def passed_directives
|
141
145
|
[:@_chef, :@_shell, :@_docker, :@_git_artifact, :@_mount, :@_artifact_groups, :@_builder]
|
142
146
|
end
|
147
|
+
|
148
|
+
def _artifacts_auto_excluding!
|
149
|
+
path_to_relative = proc { |path| path.reverse.chomp('/').reverse }
|
150
|
+
|
151
|
+
all_artifacts.reduce({}) do |hash, artifact|
|
152
|
+
unless artifact._to.nil?
|
153
|
+
to_common = artifact._to[/^\/[^\/]*/]
|
154
|
+
hash[to_common] ||= []
|
155
|
+
hash[to_common] << artifact
|
156
|
+
end
|
157
|
+
hash
|
158
|
+
end.each do |to_common, artifacts|
|
159
|
+
include_paths_common = artifacts.reduce([]) do |arr, artifact|
|
160
|
+
arr << artifact._to.sub(to_common, '')
|
161
|
+
arr.concat(artifact._include_paths.map { |path| File.join(artifact._to.sub(to_common, ''), path) } )
|
162
|
+
arr
|
163
|
+
end.map(&path_to_relative).uniq
|
164
|
+
|
165
|
+
artifacts.each do |artifact|
|
166
|
+
artifact_include_shift = path_to_relative.call(artifact._to.sub(to_common, ''))
|
167
|
+
|
168
|
+
include_paths_common.each do |path|
|
169
|
+
next if artifact_include_shift.start_with? path
|
170
|
+
|
171
|
+
path = path_to_relative.call(path.sub(artifact_include_shift, ''))
|
172
|
+
unless artifact._include_paths.any? { |ipath| ipath.start_with? path } || artifact._exclude_paths.any? { |epath| path.start_with? epath }
|
173
|
+
artifact._exclude_paths << path
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def all_artifacts
|
181
|
+
_artifact + _git_artifact._local + _git_artifact._remote
|
182
|
+
end
|
143
183
|
end # InstanceMethods
|
144
184
|
# rubocop:enable Metrics/ModuleLength
|
145
185
|
end # Dimg
|
@@ -67,7 +67,7 @@ module Dapp
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def validate_artifacts!
|
70
|
-
artifacts = validate_artifact_format(
|
70
|
+
artifacts = validate_artifact_format(all_artifacts)
|
71
71
|
loop do
|
72
72
|
break if artifacts.empty?
|
73
73
|
verifiable_artifact = artifacts.shift
|
@@ -133,10 +133,6 @@ module Dapp
|
|
133
133
|
!(art._before.nil? && art._after.nil?)
|
134
134
|
end
|
135
135
|
end
|
136
|
-
|
137
|
-
def validated_artifacts
|
138
|
-
_artifact + _git_artifact._local + _git_artifact._remote
|
139
|
-
end
|
140
136
|
end # Validation
|
141
137
|
# rubocop:enable Metrics/ModuleLength
|
142
138
|
end # Dimg
|
@@ -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 =
|
10
|
+
@_name = url.gsub(%r{.*?([^\/ ]+)\.git}, '\\1')
|
13
11
|
|
14
12
|
super(**kwargs, &blk)
|
15
13
|
end
|
@@ -7,6 +7,8 @@ module Dapp
|
|
7
7
|
attr_reader :repo
|
8
8
|
attr_reader :name
|
9
9
|
|
10
|
+
# FIXME: переименовать cwd в from
|
11
|
+
|
10
12
|
# rubocop:disable Metrics/ParameterLists
|
11
13
|
def initialize(repo, to:, name: nil, branch: nil, commit: nil,
|
12
14
|
cwd: nil, include_paths: nil, exclude_paths: nil, owner: nil, group: nil,
|
@@ -28,28 +30,89 @@ module Dapp
|
|
28
30
|
end
|
29
31
|
# rubocop:enable Metrics/ParameterLists
|
30
32
|
|
31
|
-
def
|
32
|
-
|
33
|
+
def cwd_type(stage)
|
34
|
+
if dev_mode?
|
35
|
+
p = repo.workdir_path.join(cwd)
|
36
|
+
if p.exist?
|
37
|
+
if p.directory?
|
38
|
+
:directory
|
39
|
+
else
|
40
|
+
:file
|
41
|
+
end
|
42
|
+
end
|
43
|
+
elsif cwd == ''
|
44
|
+
:directory
|
45
|
+
else
|
46
|
+
commit = repo.lookup_commit(stage.layer_commit(self))
|
47
|
+
|
48
|
+
cwd_entry = begin
|
49
|
+
commit.tree.path(cwd)
|
50
|
+
rescue Rugged::TreeError
|
51
|
+
end
|
52
|
+
|
53
|
+
if cwd_entry
|
54
|
+
if cwd_entry[:type] == :tree
|
55
|
+
:directory
|
56
|
+
else
|
57
|
+
:file
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
33
62
|
|
63
|
+
def apply_archive_command(stage)
|
34
64
|
[].tap do |commands|
|
35
|
-
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{to}"
|
36
65
|
if archive_any_changes?(stage)
|
37
|
-
|
66
|
+
case cwd_type(stage)
|
67
|
+
when :directory
|
68
|
+
stage.image.add_service_change_label :"dapp-git-#{paramshash}-type" => 'directory'
|
69
|
+
|
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}"
|
72
|
+
when :file
|
73
|
+
stage.image.add_service_change_label :"dapp-git-#{paramshash}-type" => 'file'
|
74
|
+
|
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)}"
|
77
|
+
end
|
38
78
|
end
|
39
79
|
end
|
40
80
|
end
|
41
81
|
|
82
|
+
def archive_type
|
83
|
+
repo.dimg.stage_by_name(:g_a_archive).image.labels["dapp-git-#{paramshash}-type"].to_s.to_sym
|
84
|
+
end
|
85
|
+
|
42
86
|
def apply_patch_command(stage)
|
43
87
|
[].tap do |commands|
|
44
88
|
if dev_mode?
|
45
89
|
if any_changes?(*dev_patch_stage_commits(stage))
|
46
|
-
|
47
|
-
|
48
|
-
|
90
|
+
case archive_type
|
91
|
+
when :directory
|
92
|
+
changed_files = diff_patches(*dev_patch_stage_commits(stage)).map {|p| File.join(to, cwd, p.delta.new_file[:path])}
|
93
|
+
commands << "#{repo.dimg.dapp.rm_bin} -rf #{changed_files.join(' ')}"
|
94
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{to}"
|
95
|
+
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C #{to}"
|
96
|
+
when :file
|
97
|
+
commands << "#{repo.dimg.dapp.rm_bin} -rf #{to}"
|
98
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{File.dirname(to)}"
|
99
|
+
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C #{File.dirname(to)}"
|
100
|
+
else
|
101
|
+
raise
|
102
|
+
end
|
49
103
|
end
|
50
104
|
else
|
51
105
|
if patch_any_changes?(stage)
|
52
|
-
|
106
|
+
case archive_type
|
107
|
+
when :directory
|
108
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{to}"
|
109
|
+
commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory=#{to} --unsafe-paths #{patch_file(stage, *patch_stage_commits(stage))}"
|
110
|
+
when :file
|
111
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{File.dirname(to)}"
|
112
|
+
commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory=#{File.dirname(to)} --unsafe-paths #{patch_file(stage, *patch_stage_commits(stage))}"
|
113
|
+
else
|
114
|
+
raise
|
115
|
+
end
|
53
116
|
end
|
54
117
|
end
|
55
118
|
end
|
@@ -103,12 +166,11 @@ module Dapp
|
|
103
166
|
end
|
104
167
|
end
|
105
168
|
|
106
|
-
def dev_patch_hash
|
169
|
+
def dev_patch_hash(stage)
|
107
170
|
return unless dev_mode?
|
108
171
|
|
109
172
|
Digest::SHA256.hexdigest(diff_patches(latest_commit, nil).map do |patch|
|
110
|
-
|
111
|
-
File.read(path)
|
173
|
+
change_patch_new_file_path(stage, patch)
|
112
174
|
end.join(':::'))
|
113
175
|
end
|
114
176
|
|
@@ -146,7 +208,11 @@ module Dapp
|
|
146
208
|
repo.dimg.dapp.sudo_command(owner: owner, group: group)
|
147
209
|
end
|
148
210
|
|
149
|
-
def
|
211
|
+
def credentials
|
212
|
+
[:owner, :group].map { |attr| "--#{attr}=#{send(attr)}" unless send(attr).nil? }.compact
|
213
|
+
end
|
214
|
+
|
215
|
+
def archive_file(stage, from_commit, to_commit)
|
150
216
|
tar_write(repo.dimg.tmp_path('archives', archive_file_name(from_commit, to_commit))) do |tar|
|
151
217
|
diff_patches(from_commit, to_commit).each do |patch|
|
152
218
|
entry = patch.delta.new_file
|
@@ -161,9 +227,9 @@ module Dapp
|
|
161
227
|
end
|
162
228
|
|
163
229
|
if entry[:mode] == 40960 # symlink
|
164
|
-
tar.add_symlink slice_cwd(entry[:path]), content, entry[:mode]
|
230
|
+
tar.add_symlink slice_cwd(stage, entry[:path]), content, entry[:mode]
|
165
231
|
else
|
166
|
-
tar.add_file slice_cwd(entry[:path]), entry[:mode] do |tf|
|
232
|
+
tar.add_file slice_cwd(stage, entry[:path]), entry[:mode] do |tf|
|
167
233
|
tf.write content
|
168
234
|
end
|
169
235
|
end
|
@@ -174,35 +240,54 @@ module Dapp
|
|
174
240
|
raise Error::TarWriter, message: e.message
|
175
241
|
end
|
176
242
|
|
177
|
-
def slice_cwd(path)
|
243
|
+
def slice_cwd(stage, path)
|
178
244
|
return path if cwd.empty?
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
245
|
+
|
246
|
+
case cwd_type(stage)
|
247
|
+
when :directory
|
248
|
+
path
|
249
|
+
.reverse
|
250
|
+
.chomp(cwd.reverse)
|
251
|
+
.reverse
|
252
|
+
when :file
|
253
|
+
File.basename(to)
|
254
|
+
else
|
255
|
+
raise
|
256
|
+
end
|
183
257
|
end
|
184
258
|
|
185
259
|
def archive_file_name(from_commit, to_commit)
|
186
260
|
file_name(from_commit, to_commit, 'tar')
|
187
261
|
end
|
188
262
|
|
189
|
-
def patch_file(from_commit, to_commit)
|
263
|
+
def patch_file(stage, from_commit, to_commit)
|
190
264
|
File.open(repo.dimg.tmp_path('patches', patch_file_name(from_commit, to_commit)), File::RDWR | File::CREAT) do |f|
|
191
|
-
diff_patches(from_commit, to_commit).each { |patch| f.write change_patch_new_file_path(patch) }
|
265
|
+
diff_patches(from_commit, to_commit).each { |patch| f.write change_patch_new_file_path(stage, patch) }
|
192
266
|
end
|
193
267
|
repo.dimg.container_tmp_path('patches', patch_file_name(from_commit, to_commit))
|
194
268
|
end
|
195
269
|
|
196
270
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
197
|
-
def change_patch_new_file_path(patch)
|
271
|
+
def change_patch_new_file_path(stage, patch)
|
198
272
|
patch.to_s.lines.tap do |lines|
|
199
273
|
modify_patch_line = proc do |line_number, path_char|
|
200
274
|
action_part, path_part = lines[line_number].split
|
201
275
|
if (path_with_cwd = path_part.partition("#{path_char}/").last).start_with?(cwd)
|
202
|
-
|
276
|
+
native_path = case archive_type
|
277
|
+
when :directory
|
278
|
+
path_with_cwd.sub(cwd, '')
|
279
|
+
when :file
|
280
|
+
File.basename(to)
|
281
|
+
else
|
282
|
+
raise
|
283
|
+
end
|
284
|
+
|
285
|
+
if native_path
|
203
286
|
expected_path = File.join(path_char, native_path)
|
204
287
|
lines[line_number] = [action_part, expected_path].join(' ') + "\n"
|
205
288
|
end
|
289
|
+
|
290
|
+
native_path
|
206
291
|
end
|
207
292
|
end
|
208
293
|
|
@@ -143,14 +143,7 @@ module Dapp
|
|
143
143
|
end
|
144
144
|
|
145
145
|
watch_hooks_thr = Thread.new do
|
146
|
-
watch_hooks.each {|job|
|
147
|
-
begin
|
148
|
-
Kubernetes::Manager::Job.new(self, job.name).watch_till_done!
|
149
|
-
rescue ::Exception => e
|
150
|
-
sentry_exception(e, extra: {"job-spec" => job.spec})
|
151
|
-
raise
|
152
|
-
end
|
153
|
-
}
|
146
|
+
watch_hooks.each {|job| Kubernetes::Manager::Job.new(self, job.name).watch_till_done!}
|
154
147
|
end
|
155
148
|
|
156
149
|
deployment_managers = release.deployments.values
|
@@ -4,8 +4,6 @@ module Dapp
|
|
4
4
|
class Client
|
5
5
|
include Helper::YAML
|
6
6
|
|
7
|
-
::Dapp::Dapp::Shellout::Base.default_env_keys << 'KUBECONFIG'
|
8
|
-
|
9
7
|
def initialize(namespace: nil)
|
10
8
|
@namespace = namespace
|
11
9
|
@query_parameters = {}
|
@@ -255,10 +253,7 @@ module Dapp
|
|
255
253
|
|
256
254
|
def kube_config
|
257
255
|
@kube_config ||= begin
|
258
|
-
kube_config_path = ENV['
|
259
|
-
kube_config_path = File.join(ENV['HOME'], '.kube/config') unless kube_config_path
|
260
|
-
|
261
|
-
if File.exist?(kube_config_path)
|
256
|
+
if File.exist?((kube_config_path = File.join(ENV['HOME'], '.kube/config')))
|
262
257
|
yaml_load_file(kube_config_path)
|
263
258
|
else
|
264
259
|
raise Error::Base, code: :kube_config_not_found, data: { path: kube_config_path }
|
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.
|
4
|
+
version: 0.14.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:
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -166,34 +166,6 @@ dependencies:
|
|
166
166
|
- - "~>"
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: 0.1.6
|
169
|
-
- !ruby/object:Gem::Dependency
|
170
|
-
name: sentry-raven
|
171
|
-
requirement: !ruby/object:Gem::Requirement
|
172
|
-
requirements:
|
173
|
-
- - "~>"
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
version: 2.7.2
|
176
|
-
type: :runtime
|
177
|
-
prerelease: false
|
178
|
-
version_requirements: !ruby/object:Gem::Requirement
|
179
|
-
requirements:
|
180
|
-
- - "~>"
|
181
|
-
- !ruby/object:Gem::Version
|
182
|
-
version: 2.7.2
|
183
|
-
- !ruby/object:Gem::Dependency
|
184
|
-
name: toml-rb
|
185
|
-
requirement: !ruby/object:Gem::Requirement
|
186
|
-
requirements:
|
187
|
-
- - "~>"
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: 1.1.1
|
190
|
-
type: :runtime
|
191
|
-
prerelease: false
|
192
|
-
version_requirements: !ruby/object:Gem::Requirement
|
193
|
-
requirements:
|
194
|
-
- - "~>"
|
195
|
-
- !ruby/object:Gem::Version
|
196
|
-
version: 1.1.1
|
197
169
|
- !ruby/object:Gem::Dependency
|
198
170
|
name: bundler
|
199
171
|
requirement: !ruby/object:Gem::Requirement
|
@@ -451,7 +423,6 @@ files:
|
|
451
423
|
- lib/dapp/dapp/logging/i18n.rb
|
452
424
|
- lib/dapp/dapp/logging/paint.rb
|
453
425
|
- lib/dapp/dapp/logging/process.rb
|
454
|
-
- lib/dapp/dapp/sentry.rb
|
455
426
|
- lib/dapp/dapp/shellout/base.rb
|
456
427
|
- lib/dapp/dapp/shellout/streaming.rb
|
457
428
|
- lib/dapp/dapp/ssh_agent.rb
|
@@ -648,7 +619,6 @@ files:
|
|
648
619
|
- lib/dapp/helper/sha256.rb
|
649
620
|
- lib/dapp/helper/tar.rb
|
650
621
|
- lib/dapp/helper/trivia.rb
|
651
|
-
- lib/dapp/helper/url.rb
|
652
622
|
- lib/dapp/helper/yaml.rb
|
653
623
|
- lib/dapp/kube.rb
|
654
624
|
- lib/dapp/kube/cli/cli.rb
|
@@ -716,7 +686,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
716
686
|
version: 2.5.0
|
717
687
|
requirements: []
|
718
688
|
rubyforge_project:
|
719
|
-
rubygems_version: 2.
|
689
|
+
rubygems_version: 2.6.11
|
720
690
|
signing_key:
|
721
691
|
specification_version: 4
|
722
692
|
summary: Build docker packaged apps using chef or shell
|
data/lib/dapp/dapp/sentry.rb
DELETED
@@ -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
|
data/lib/dapp/helper/url.rb
DELETED
@@ -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
|