dapp 0.22.17 → 0.23.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/config/en/net_status.yml +1 -1
- data/lib/dapp.rb +0 -4
- data/lib/dapp/cli.rb +0 -4
- data/lib/dapp/cli/command/base.rb +1 -7
- data/lib/dapp/dapp.rb +4 -22
- data/lib/dapp/dapp/logging/base.rb +4 -12
- data/lib/dapp/dapp/option_tags.rb +0 -6
- data/lib/dapp/dimg/build/stage/artifact_default.rb +1 -1
- data/lib/dapp/dimg/build/stage/ga_latest_patch.rb +1 -1
- data/lib/dapp/dimg/build/stage/setup/ga_post_setup_patch.rb +1 -1
- data/lib/dapp/dimg/builder/chef/cookbook.rb +1 -1
- data/lib/dapp/dimg/cli/command/base.rb +4 -0
- data/lib/dapp/dimg/config/directive/artifact_dimg.rb +7 -0
- data/lib/dapp/dimg/config/directive/dimg/instance_methods.rb +0 -1
- data/lib/dapp/dimg/config/directive/dimg/validation.rb +16 -39
- data/lib/dapp/dimg/config/directive/git_artifact_remote.rb +7 -6
- data/lib/dapp/dimg/git_artifact.rb +60 -45
- data/lib/dapp/dimg/git_repo/base.rb +26 -2
- data/lib/dapp/helper/trivia.rb +0 -35
- data/lib/dapp/kube/dapp/command/deploy.rb +1 -8
- data/lib/dapp/kube/dapp/command/render.rb +2 -2
- data/lib/dapp/version.rb +2 -2
- metadata +2 -32
- 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: 501a8c18b049fad1debe8448c6e595e6b6ece898
|
4
|
+
data.tar.gz: c2a3cd337e13baa495acb67d76295608ff7828ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d786163dbf0bc002be691579dd0c6b7835e88201ff37bc77bbc323dcf4bd411e1993677d5603546f094ee932f6799ea4204a7af2da0c166b4dae25c620f35c26
|
7
|
+
data.tar.gz: 2c77b2d54789be940ef323cb6529b1143b12fb2bd82ea915936e0343158e4113c619bc4d710ed73264164c2ef9fcad0941e3638c2e8aee5f6c5fd030a98dab1c
|
data/bin/dapp
CHANGED
data/config/en/net_status.yml
CHANGED
@@ -81,7 +81,7 @@ en:
|
|
81
81
|
stage_artifact_double_associate: "Can't use `%{stage}` stage for artifact; already used in `%{conflict_stage}` stage!"
|
82
82
|
stage_artifact_not_supported_associated_stage: "Bad artifact stage `%{stage}`!"
|
83
83
|
git_artifact_remote_branch_with_commit: "Remote git repo: use `commit` or `branch` directive!"
|
84
|
-
artifact_conflict: "Conflict between artifacts
|
84
|
+
artifact_conflict: "Conflict between artifacts paths!"
|
85
85
|
scratch_unsupported_directive: "Scratch dimg has unsupported directive `%{directive}`!"
|
86
86
|
scratch_artifact_required: "Scratch dimg without artifacts!"
|
87
87
|
scratch_artifact_associated: "Scratch artifact can't be associated: not expected `before`/`after` attribute!"
|
data/lib/dapp.rb
CHANGED
@@ -25,8 +25,6 @@ require 'etc'
|
|
25
25
|
require 'zlib'
|
26
26
|
require 'slugify'
|
27
27
|
require 'base64'
|
28
|
-
require 'sentry-raven'
|
29
|
-
require 'toml-rb'
|
30
28
|
|
31
29
|
require 'dapp/version'
|
32
30
|
require 'dapp/core_ext/hash'
|
@@ -37,7 +35,6 @@ require 'dapp/helper/sha256'
|
|
37
35
|
require 'dapp/helper/net_status'
|
38
36
|
require 'dapp/helper/tar'
|
39
37
|
require 'dapp/helper/yaml'
|
40
|
-
require 'dapp/helper/url'
|
41
38
|
require 'dapp/prctl'
|
42
39
|
require 'dapp/error/mod/user'
|
43
40
|
require 'dapp/error/base'
|
@@ -58,7 +55,6 @@ require 'dapp/config/directive/base'
|
|
58
55
|
require 'dapp/config/config'
|
59
56
|
require 'dapp/dapp/lock'
|
60
57
|
require 'dapp/dapp/ssh_agent'
|
61
|
-
require 'dapp/dapp/sentry'
|
62
58
|
require 'dapp/dapp/git_artifact'
|
63
59
|
require 'dapp/dapp/dappfile'
|
64
60
|
require 'dapp/dapp/chef'
|
data/lib/dapp/cli.rb
CHANGED
@@ -58,8 +58,6 @@ 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']
|
63
61
|
|
64
62
|
log_dapp_running_time(dapp, ignore: !log_running_time) do
|
65
63
|
begin
|
@@ -76,10 +74,6 @@ module Dapp
|
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
79
|
-
def run_method
|
80
|
-
class_to_lowercase
|
81
|
-
end
|
82
|
-
|
83
77
|
def log_dapp_running_time(dapp, ignore: false)
|
84
78
|
return yield if ignore
|
85
79
|
|
@@ -101,7 +95,7 @@ module Dapp
|
|
101
95
|
self.class.print_error_with_help_and_die! self, "cannot use alias options --run-dir, --build-dir, --deploy-dir at the same time"
|
102
96
|
end
|
103
97
|
|
104
|
-
config.merge(build_dir: dirs.compact.first,
|
98
|
+
config.merge(build_dir: dirs.compact.first, **kwargs)
|
105
99
|
end
|
106
100
|
end
|
107
101
|
end
|
data/lib/dapp/dapp.rb
CHANGED
@@ -17,13 +17,10 @@ module Dapp
|
|
17
17
|
include Logging::Paint
|
18
18
|
|
19
19
|
include SshAgent
|
20
|
-
include Sentry
|
21
|
-
|
22
20
|
include Helper::Sha256
|
23
|
-
extend
|
21
|
+
extend Helper::Trivia
|
24
22
|
include Helper::Trivia
|
25
23
|
include Helper::Tar
|
26
|
-
include Helper::Url
|
27
24
|
|
28
25
|
include Deps::Toolchain
|
29
26
|
include Deps::Gitartifact
|
@@ -44,18 +41,6 @@ module Dapp
|
|
44
41
|
self.class.options
|
45
42
|
end
|
46
43
|
|
47
|
-
def settings
|
48
|
-
@settings ||= begin
|
49
|
-
settings_path = File.join(self.class.home_dir, "settings.toml")
|
50
|
-
|
51
|
-
if File.exists? settings_path
|
52
|
-
TomlRB.load_file(settings_path)
|
53
|
-
else
|
54
|
-
{}
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
44
|
def name
|
60
45
|
@name ||= begin
|
61
46
|
n = begin
|
@@ -101,8 +86,8 @@ module Dapp
|
|
101
86
|
self.class.tmp_base_dir
|
102
87
|
end
|
103
88
|
|
104
|
-
def
|
105
|
-
@
|
89
|
+
def build_path(*path)
|
90
|
+
@build_path ||= begin
|
106
91
|
if option_build_dir
|
107
92
|
Pathname.new(option_build_dir)
|
108
93
|
else
|
@@ -110,10 +95,7 @@ module Dapp
|
|
110
95
|
Pathname.new(dir)
|
111
96
|
end.expand_path.tap(&:mkpath)
|
112
97
|
end
|
113
|
-
|
114
|
-
|
115
|
-
def build_path(*path)
|
116
|
-
make_path(build_dir, *path)
|
98
|
+
make_path(@build_path, *path)
|
117
99
|
end
|
118
100
|
|
119
101
|
def local_git_artifact_exclude_paths(&blk)
|
@@ -2,18 +2,6 @@ module Dapp
|
|
2
2
|
class Dapp
|
3
3
|
module Logging
|
4
4
|
module Base
|
5
|
-
class << self
|
6
|
-
def included(base)
|
7
|
-
base.send(:extend, ClassMethods)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
module ClassMethods
|
12
|
-
def log_time
|
13
|
-
"#{DateTime.now.strftime('%Y-%m-%dT%T%z')} "
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
5
|
def log_quiet?
|
18
6
|
option_quiet
|
19
7
|
end
|
@@ -99,6 +87,10 @@ module Dapp
|
|
99
87
|
self.class.log_time
|
100
88
|
end
|
101
89
|
|
90
|
+
def self.log_time
|
91
|
+
"#{DateTime.now.strftime('%Y-%m-%dT%T%z')} "
|
92
|
+
end
|
93
|
+
|
102
94
|
def log_format_string(str, time: true, indent: true, style: nil)
|
103
95
|
str.to_s.lines.map do |line|
|
104
96
|
line = paint_string(line, style) if style
|
@@ -11,12 +11,6 @@ module Dapp
|
|
11
11
|
|
12
12
|
def tags_by_scheme
|
13
13
|
@tags_by_scheme_name ||= begin
|
14
|
-
if simple_tags[:custom].any?
|
15
|
-
if settings.fetch("sentry", {}).fetch("detect-push-tag-usage", false)
|
16
|
-
sentry_message("--tag or --tag-slug usage detected", extra: {"slug_tags" => simple_tags})
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
14
|
[simple_tags, branch_tags, commit_tags, build_tags, ci_tags].reduce({}) do |some_tags_by_scheme, tags_by_scheme|
|
21
15
|
tags_by_scheme.in_depth_merge(some_tags_by_scheme)
|
22
16
|
end.tap do |tags_by_scheme|
|
@@ -32,7 +32,7 @@ module Dapp
|
|
32
32
|
def safe_cp(from, to, owner, group, include_paths = [], exclude_paths = [])
|
33
33
|
''.tap do |cmd|
|
34
34
|
cmd << dimg.dapp.rsync_bin
|
35
|
-
cmd << ' --archive --links
|
35
|
+
cmd << ' --archive --links'
|
36
36
|
cmd << " --chown=#{owner}:#{group}" if owner or group
|
37
37
|
|
38
38
|
if include_paths.any?
|
@@ -27,7 +27,7 @@ module Dapp
|
|
27
27
|
def changes_size_since_g_a_pre_setup_patch
|
28
28
|
dimg.git_artifacts.map do |git_artifact|
|
29
29
|
if git_artifact.repo.commit_exists? prev_stage.layer_commit(git_artifact)
|
30
|
-
git_artifact.patch_size(prev_stage.layer_commit(git_artifact)
|
30
|
+
git_artifact.patch_size(prev_stage.layer_commit(git_artifact))
|
31
31
|
else
|
32
32
|
0
|
33
33
|
end
|
@@ -87,7 +87,7 @@ module Dapp
|
|
87
87
|
"#{builder.dimg.dapp.mkdir_bin} -p ~/.ssh",
|
88
88
|
'echo "Host *" >> ~/.ssh/config',
|
89
89
|
'echo " StrictHostKeyChecking no" >> ~/.ssh/config',
|
90
|
-
*local_paths.map {|path| "#{builder.dimg.dapp.rsync_bin} --
|
90
|
+
*local_paths.map {|path| "#{builder.dimg.dapp.rsync_bin} --archive --relative #{path} /tmp/local_cookbooks"},
|
91
91
|
"cd /tmp/local_cookbooks/#{path}",
|
92
92
|
"cp #{tmp_berksfile_path} Berksfile",
|
93
93
|
"cp #{tmp_metadata_path} metadata.rb",
|
@@ -4,8 +4,6 @@ module Dapp
|
|
4
4
|
module Directive
|
5
5
|
class Dimg < Base
|
6
6
|
module Validation
|
7
|
-
include Helper::Trivia
|
8
|
-
|
9
7
|
def validate!
|
10
8
|
directives_validate!
|
11
9
|
validate_scratch!
|
@@ -73,39 +71,12 @@ module Dapp
|
|
73
71
|
verifiable_artifact = artifacts.shift
|
74
72
|
artifacts.select { |a| a[:to] == verifiable_artifact[:to] }.each do |artifact|
|
75
73
|
next if verifiable_artifact[:index] == artifact[:index]
|
76
|
-
|
77
|
-
|
78
|
-
validate_artifact!(artifact, verifiable_artifact)
|
79
|
-
rescue ::Dapp::Error::Config => e
|
80
|
-
conflict_between_artifacts!(artifact, verifiable_artifact) if e.net_status[:code] == :artifact_conflict
|
81
|
-
raise
|
82
|
-
end
|
74
|
+
validate_artifact!(verifiable_artifact, artifact)
|
75
|
+
validate_artifact!(artifact, verifiable_artifact)
|
83
76
|
end
|
84
77
|
end
|
85
78
|
end
|
86
79
|
|
87
|
-
def conflict_between_artifacts!(*formatted_artifacts)
|
88
|
-
artifacts = formatted_artifacts.flatten.map { |formatted_artifact| formatted_artifact[:related_artifact] }
|
89
|
-
dappfile_context = artifacts.map do |artifact|
|
90
|
-
artifact_directive = []
|
91
|
-
artifact_directive << begin
|
92
|
-
if artifact.is_a? Artifact::Export
|
93
|
-
"artifact.export('#{artifact._cwd}') do"
|
94
|
-
else
|
95
|
-
"git#{"('#{artifact._url}')" if artifact.respond_to?(:_url)}.add('#{artifact._cwd}') do"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
[:include_paths, :exclude_paths].each do |directive|
|
99
|
-
next if (paths = artifact.send("_#{directive}")).empty?
|
100
|
-
artifact_directive << " #{directive} '#{paths.join("', '")}'"
|
101
|
-
end
|
102
|
-
artifact_directive << " to '#{artifact._to}'"
|
103
|
-
artifact_directive << 'end'
|
104
|
-
artifact_directive.join("\n")
|
105
|
-
end.join("\n\n")
|
106
|
-
raise ::Dapp::Error::Config, code: :artifact_conflict, data: { dappfile_context: dappfile_context }
|
107
|
-
end
|
108
|
-
|
109
80
|
def validate_artifact_format(artifacts)
|
110
81
|
artifacts.map do |a|
|
111
82
|
path_format = proc { |path| File.expand_path(File.join('/', path, '/'))[1..-1] }
|
@@ -133,20 +104,26 @@ module Dapp
|
|
133
104
|
index: artifacts.index(a),
|
134
105
|
to: to,
|
135
106
|
include_paths: include_paths,
|
136
|
-
exclude_paths: exclude_paths
|
137
|
-
related_artifact: a
|
107
|
+
exclude_paths: exclude_paths
|
138
108
|
}
|
139
109
|
end
|
140
110
|
end
|
141
111
|
|
142
112
|
def validate_artifact!(verifiable_artifact, artifact)
|
143
|
-
|
144
|
-
|
145
|
-
!
|
146
|
-
end
|
147
|
-
|
113
|
+
verifiable_artifact[:include_paths].each do |verifiable_path|
|
114
|
+
potential_conflicts = artifact[:include_paths].select { |path| path.start_with?(verifiable_path) }
|
115
|
+
validate_artifact_path!(verifiable_artifact, potential_conflicts)
|
116
|
+
end.empty? && verifiable_artifact[:exclude_paths].empty? && raise(::Dapp::Error::Config, code: :artifact_conflict)
|
117
|
+
validate_artifact_path!(verifiable_artifact, artifact[:include_paths]) if verifiable_artifact[:include_paths].empty?
|
118
|
+
end
|
148
119
|
|
149
|
-
|
120
|
+
def validate_artifact_path!(verifiable_artifact, potential_conflicts)
|
121
|
+
potential_conflicts.all? do |path|
|
122
|
+
loop do
|
123
|
+
break if verifiable_artifact[:exclude_paths].include?(path) || ((path = File.dirname(path)) == '.')
|
124
|
+
end
|
125
|
+
verifiable_artifact[:exclude_paths].include?(path)
|
126
|
+
end.tap { |res| res || raise(::Dapp::Error::Config, code: :artifact_conflict) }
|
150
127
|
end
|
151
128
|
|
152
129
|
def _associated_artifacts
|
@@ -3,13 +3,14 @@ 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
|
-
|
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')
|
13
14
|
|
14
15
|
super(**kwargs, &blk)
|
15
16
|
end
|
@@ -19,7 +20,7 @@ module Dapp
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def commit(value)
|
22
|
-
sub_directive_eval { @_commit = value
|
23
|
+
sub_directive_eval { @_commit = value }
|
23
24
|
end
|
24
25
|
|
25
26
|
def _export
|
@@ -41,11 +42,11 @@ module Dapp
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def branch(value)
|
44
|
-
sub_directive_eval { @_branch = value
|
45
|
+
sub_directive_eval { @_branch = value }
|
45
46
|
end
|
46
47
|
|
47
48
|
def commit(value)
|
48
|
-
sub_directive_eval { @_commit = value
|
49
|
+
sub_directive_eval { @_commit = value }
|
49
50
|
end
|
50
51
|
|
51
52
|
def validate!
|
@@ -70,12 +70,12 @@ module Dapp
|
|
70
70
|
stage.image.add_service_change_label(repo.dapp.dimgstage_g_a_type_label(paramshash).to_sym => 'directory')
|
71
71
|
|
72
72
|
commands << "#{repo.dapp.install_bin} #{credentials.join(' ')} -d \"#{to}\""
|
73
|
-
commands << "#{sudo}#{repo.dapp.tar_bin} -xf #{archive_file(stage
|
73
|
+
commands << "#{sudo}#{repo.dapp.tar_bin} -xf #{archive_file(stage)} -C \"#{to}\""
|
74
74
|
when :file
|
75
75
|
stage.image.add_service_change_label(repo.dapp.dimgstage_g_a_type_label(paramshash).to_sym => 'file')
|
76
76
|
|
77
77
|
commands << "#{repo.dapp.install_bin} #{credentials.join(' ')} -d \"#{File.dirname(to)}\""
|
78
|
-
commands << "#{sudo}#{repo.dapp.tar_bin} -xf #{archive_file(stage
|
78
|
+
commands << "#{sudo}#{repo.dapp.tar_bin} -xf #{archive_file(stage)} -C \"#{File.dirname(to)}\""
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -94,11 +94,11 @@ module Dapp
|
|
94
94
|
changed_files = diff_patches(*dev_patch_stage_commits(stage)).map {|p| "\"#{File.join(to, cwd, p.delta.new_file[:path])}\""}
|
95
95
|
commands << "#{repo.dapp.rm_bin} -rf #{changed_files.join(' ')}"
|
96
96
|
commands << "#{repo.dapp.install_bin} #{credentials.join(' ')} -d \"#{to}\""
|
97
|
-
commands << "#{sudo}#{repo.dapp.tar_bin} -xf #{archive_file(stage
|
97
|
+
commands << "#{sudo}#{repo.dapp.tar_bin} -xf #{archive_file(stage)} -C \"#{to}\""
|
98
98
|
when :file
|
99
99
|
commands << "#{repo.dapp.rm_bin} -rf \"#{to}\""
|
100
100
|
commands << "#{repo.dapp.install_bin} #{credentials.join(' ')} -d \"#{File.dirname(to)}\""
|
101
|
-
commands << "#{sudo}#{repo.dapp.tar_bin} -xf #{archive_file(stage
|
101
|
+
commands << "#{sudo}#{repo.dapp.tar_bin} -xf #{archive_file(stage)} -C \"#{File.dirname(to)}\""
|
102
102
|
else
|
103
103
|
raise
|
104
104
|
end
|
@@ -130,44 +130,44 @@ module Dapp
|
|
130
130
|
|
131
131
|
@stage_dependencies_checksums ||= {}
|
132
132
|
@stage_dependencies_checksums[stage_dependencies_key] ||= begin
|
133
|
-
if
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
133
|
+
if dev_mode?
|
134
|
+
dev_patch_hash(paths: paths)
|
135
|
+
else
|
136
|
+
if (entries = repo_entries(commit, paths: paths)).empty?
|
137
|
+
repo.dapp.log_warning(desc: { code: :stage_dependencies_not_found,
|
138
|
+
data: { repo: repo.respond_to?(:url) ? repo.url : 'local',
|
139
|
+
dependencies: stage_dependencies.join(', ') } })
|
140
|
+
end
|
138
141
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
142
|
+
entries
|
143
|
+
.sort_by {|root, entry| File.join(root, entry[:name])}
|
144
|
+
.reduce(nil) {|prev_hash, (root, entry)|
|
145
|
+
content = nil
|
146
|
+
content = repo.lookup_object(entry[:oid]).content if entry[:type] == :blob
|
144
147
|
|
145
|
-
|
146
|
-
|
148
|
+
hexdigest prev_hash, File.join(root, entry[:name]), entry[:filemode].to_s, content
|
149
|
+
}
|
150
|
+
end
|
147
151
|
end
|
148
152
|
end
|
149
153
|
|
150
|
-
def patch_size(from_commit
|
154
|
+
def patch_size(from_commit)
|
155
|
+
to_commit = dev_mode? ? nil : latest_commit
|
151
156
|
diff_patches(from_commit, to_commit).reduce(0) do |bytes, patch|
|
152
|
-
patch.
|
153
|
-
hunk.lines.each do |l|
|
154
|
-
bytes +=
|
155
|
-
case l.line_origin
|
156
|
-
when :eof_newline_added, :eof_newline_removed then 1
|
157
|
-
when :addition, :deletion, :binary then l.content.size
|
158
|
-
else # :context, :file_header, :hunk_header, :eof_no_newline
|
159
|
-
0
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
157
|
+
bytes += patch.delta.deleted? ? patch.delta.old_file[:size] : patch.delta.new_file[:size]
|
163
158
|
bytes
|
164
159
|
end
|
165
160
|
end
|
166
161
|
|
167
|
-
def dev_patch_hash(
|
162
|
+
def dev_patch_hash(**options)
|
168
163
|
return unless dev_mode?
|
169
|
-
|
170
|
-
|
164
|
+
hexdigest begin
|
165
|
+
diff_patches(nil, nil, **options).map do |patch|
|
166
|
+
file = patch.delta.new_file
|
167
|
+
raise_if_submodule!(file[:path], file[:mode])
|
168
|
+
[file[:path], File.read(File.join(repo.workdir_path, file[:path])), file[:mode]]
|
169
|
+
end
|
170
|
+
end
|
171
171
|
end
|
172
172
|
|
173
173
|
def latest_commit
|
@@ -183,7 +183,7 @@ module Dapp
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def archive_any_changes?(stage)
|
186
|
-
repo_entries(
|
186
|
+
repo_entries(stage_commit(stage)).any?
|
187
187
|
end
|
188
188
|
|
189
189
|
def patch_any_changes?(stage)
|
@@ -212,7 +212,8 @@ module Dapp
|
|
212
212
|
[:owner, :group].map { |attr| "--#{attr}=#{send(attr)}" unless send(attr).nil? }.compact
|
213
213
|
end
|
214
214
|
|
215
|
-
def archive_file(stage
|
215
|
+
def archive_file(stage)
|
216
|
+
commit = stage_commit(stage)
|
216
217
|
if repo.dapp.options[:use_system_tar]
|
217
218
|
archive_file_with_system_tar(stage, commit)
|
218
219
|
else
|
@@ -279,17 +280,17 @@ module Dapp
|
|
279
280
|
def patch_file(stage, from_commit, to_commit)
|
280
281
|
File.open(repo.dimg.tmp_path('patches', patch_file_name(from_commit, to_commit)), File::RDWR | File::CREAT) do |f|
|
281
282
|
diff_patches(from_commit, to_commit).each do |patch|
|
282
|
-
|
283
|
+
file = patch.delta.new_file
|
284
|
+
raise_if_submodule!(file[:path], file[:mode])
|
283
285
|
f.write change_patch_new_file_path(stage, patch)
|
284
286
|
end
|
285
287
|
end
|
286
288
|
repo.dimg.container_tmp_path('patches', patch_file_name(from_commit, to_commit))
|
287
289
|
end
|
288
290
|
|
289
|
-
def
|
290
|
-
|
291
|
-
|
292
|
-
end
|
291
|
+
def raise_if_submodule!(relative_file_path, mode) # FIXME
|
292
|
+
return unless mode == 57344
|
293
|
+
raise Error::Rugged, code: :submodule_not_supported, data: { path: repo.path.dirname.join(relative_file_path) }
|
293
294
|
end
|
294
295
|
|
295
296
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -359,14 +360,28 @@ module Dapp
|
|
359
360
|
end
|
360
361
|
end
|
361
362
|
|
362
|
-
def each_archive_entry(stage, commit
|
363
|
-
|
364
|
-
|
363
|
+
def each_archive_entry(stage, commit)
|
364
|
+
if dev_mode? && stage.name != :g_a_archive
|
365
|
+
diff_patches(commit, nil).each do |patch|
|
366
|
+
file = patch.delta.new_file
|
367
|
+
host_file_path = File.join(repo.workdir_path, file[:path])
|
365
368
|
|
366
|
-
|
367
|
-
|
369
|
+
next unless File.exist?(host_file_path)
|
370
|
+
raise_if_submodule!(file[:path], file[:mode])
|
368
371
|
|
369
|
-
|
372
|
+
content = File.read(host_file_path)
|
373
|
+
yield slice_cwd(stage, file[:path]), content, file[:mode]
|
374
|
+
end
|
375
|
+
else
|
376
|
+
repo_entries(commit).each do |root, entry|
|
377
|
+
next unless entry[:type] == :blob
|
378
|
+
|
379
|
+
entry_file_path = File.join(root, entry[:name])
|
380
|
+
|
381
|
+
raise_if_submodule!(entry_file_path, entry[:filemode])
|
382
|
+
|
383
|
+
content = repo.lookup_object(entry[:oid]).content
|
384
|
+
yield slice_cwd(stage, entry_file_path), content, entry[:filemode]
|
370
385
|
end
|
371
386
|
end
|
372
387
|
end
|
@@ -414,7 +429,7 @@ module Dapp
|
|
414
429
|
end
|
415
430
|
end
|
416
431
|
|
417
|
-
def
|
432
|
+
def stage_commit(stage)
|
418
433
|
stage.layer_commit(self)
|
419
434
|
end
|
420
435
|
|
@@ -3,8 +3,6 @@ module Dapp
|
|
3
3
|
module GitRepo
|
4
4
|
# Base class for any Git repo (remote, gitkeeper, etc)
|
5
5
|
class Base
|
6
|
-
include Helper::Trivia
|
7
|
-
|
8
6
|
attr_reader :name
|
9
7
|
|
10
8
|
def initialize(manager, name)
|
@@ -134,6 +132,32 @@ module Dapp
|
|
134
132
|
def git(**kwargs)
|
135
133
|
@git ||= Rugged::Repository.new(path.to_s, **kwargs)
|
136
134
|
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
def ignore_path?(path, paths: [], exclude_paths: [])
|
139
|
+
is_exclude_path = exclude_paths.any? { |p| check_path?(path, p) }
|
140
|
+
is_include_path = begin
|
141
|
+
paths.empty? ||
|
142
|
+
paths.any? do |p|
|
143
|
+
File.fnmatch?(p, path, File::FNM_PATHNAME) ||
|
144
|
+
File.fnmatch?(File.join(p, '**', '*'), path, File::FNM_PATHNAME)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
is_exclude_path || !is_include_path
|
149
|
+
end
|
150
|
+
|
151
|
+
def check_path?(path, format)
|
152
|
+
path_parts = path.split('/')
|
153
|
+
checking_path = nil
|
154
|
+
|
155
|
+
until path_parts.empty?
|
156
|
+
checking_path = [checking_path, path_parts.shift].compact.join('/')
|
157
|
+
return true if File.fnmatch?(format, checking_path, File::FNM_PATHNAME)
|
158
|
+
end
|
159
|
+
false
|
160
|
+
end
|
137
161
|
end
|
138
162
|
end
|
139
163
|
end
|
data/lib/dapp/helper/trivia.rb
CHANGED
@@ -28,41 +28,6 @@ module Dapp
|
|
28
28
|
Pathname.new(File.join(base.to_s, *path.compact.map(&:to_s)))
|
29
29
|
end
|
30
30
|
|
31
|
-
def ignore_path?(path, paths: [], exclude_paths: [])
|
32
|
-
ignore_path_base(path, exclude_paths: exclude_paths) do
|
33
|
-
paths.empty? ||
|
34
|
-
paths.any? do |p|
|
35
|
-
File.fnmatch?(p, path, File::FNM_PATHNAME|File::FNM_DOTMATCH) ||
|
36
|
-
File.fnmatch?(File.join(p, '**', '*'), path, File::FNM_PATHNAME|File::FNM_DOTMATCH)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def ignore_path_base(path, exclude_paths: [])
|
42
|
-
is_exclude_path = exclude_paths.any? { |p| check_path?(path, p) }
|
43
|
-
is_include_path = yield
|
44
|
-
is_exclude_path || !is_include_path
|
45
|
-
end
|
46
|
-
|
47
|
-
def check_path?(path, format)
|
48
|
-
path_checker(path) { |checking_path| File.fnmatch(format, checking_path, File::FNM_PATHNAME|File::FNM_DOTMATCH) }
|
49
|
-
end
|
50
|
-
|
51
|
-
def check_subpath?(path, format)
|
52
|
-
path_checker(format) { |checking_path| File.fnmatch(checking_path, path, File::FNM_PATHNAME|File::FNM_DOTMATCH) }
|
53
|
-
end
|
54
|
-
|
55
|
-
def path_checker(path)
|
56
|
-
path_parts = path.split('/')
|
57
|
-
checking_path = nil
|
58
|
-
|
59
|
-
until path_parts.empty?
|
60
|
-
checking_path = [checking_path, path_parts.shift].compact.join('/')
|
61
|
-
return true if yield checking_path
|
62
|
-
end
|
63
|
-
false
|
64
|
-
end
|
65
|
-
|
66
31
|
def self.class_to_lowercase(class_name = self)
|
67
32
|
class_name.to_s.split('::').last.split(/(?=[[:upper:]]|[0-9])/).join('_').downcase.to_s
|
68
33
|
end
|
@@ -71,14 +71,7 @@ module Dapp
|
|
71
71
|
watch_hooks_thr = nil
|
72
72
|
unless dry_run?
|
73
73
|
watch_hooks_thr = Thread.new do
|
74
|
-
watch_hooks.each {|job|
|
75
|
-
begin
|
76
|
-
Kubernetes::Manager::Job.new(self, job.name).watch_till_done!
|
77
|
-
rescue ::Exception => e
|
78
|
-
sentry_exception(e, extra: {"job-spec" => job.spec})
|
79
|
-
raise
|
80
|
-
end
|
81
|
-
}
|
74
|
+
watch_hooks.each {|job| Kubernetes::Manager::Job.new(self, job.name).watch_till_done!}
|
82
75
|
end
|
83
76
|
end
|
84
77
|
|
@@ -13,8 +13,8 @@ module Dapp
|
|
13
13
|
template_relative_path_pattern = Pathname(File.expand_path(template_path_pattern)).subpath_of(path('.helm'))
|
14
14
|
template_relative_path_pattern ||= template_path_pattern
|
15
15
|
|
16
|
-
File.fnmatch?(template_relative_path_pattern, template_path_without_chart_name, File::FNM_PATHNAME
|
17
|
-
File.fnmatch?(template_relative_path_pattern, template_path, File::FNM_PATHNAME
|
16
|
+
File.fnmatch?(template_relative_path_pattern, template_path_without_chart_name, File::FNM_PATHNAME) ||
|
17
|
+
File.fnmatch?(template_relative_path_pattern, template_path, File::FNM_PATHNAME)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
else
|
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.23.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-12-29 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
|
@@ -476,7 +448,6 @@ files:
|
|
476
448
|
- lib/dapp/dapp/logging/paint.rb
|
477
449
|
- lib/dapp/dapp/logging/process.rb
|
478
450
|
- lib/dapp/dapp/option_tags.rb
|
479
|
-
- lib/dapp/dapp/sentry.rb
|
480
451
|
- lib/dapp/dapp/shellout/base.rb
|
481
452
|
- lib/dapp/dapp/shellout/streaming.rb
|
482
453
|
- lib/dapp/dapp/slug.rb
|
@@ -676,7 +647,6 @@ files:
|
|
676
647
|
- lib/dapp/helper/sha256.rb
|
677
648
|
- lib/dapp/helper/tar.rb
|
678
649
|
- lib/dapp/helper/trivia.rb
|
679
|
-
- lib/dapp/helper/url.rb
|
680
650
|
- lib/dapp/helper/yaml.rb
|
681
651
|
- lib/dapp/kube.rb
|
682
652
|
- lib/dapp/kube/cli/cli.rb
|
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
|