dapp 0.7.36 → 0.8.0
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/config/en/common.yml +1 -3
- data/config/en/net_status.yml +7 -9
- data/lib/dapp.rb +3 -1
- data/lib/dapp/artifact.rb +7 -2
- data/lib/dapp/build/stage/after_setup_artifact.rb +1 -1
- data/lib/dapp/build/stage/artifact_base.rb +1 -1
- data/lib/dapp/build/stage/artifact_default.rb +24 -43
- data/lib/dapp/build/stage/base.rb +35 -31
- data/lib/dapp/build/stage/build_artifact.rb +1 -1
- data/lib/dapp/build/stage/from.rb +1 -1
- data/lib/dapp/build/stage/ga_archive_dependencies.rb +10 -1
- data/lib/dapp/build/stage/ga_artifact_patch.rb +2 -2
- data/lib/dapp/build/stage/ga_base.rb +18 -5
- data/lib/dapp/build/stage/ga_dependencies_base.rb +1 -1
- data/lib/dapp/build/stage/ga_latest_patch.rb +10 -2
- data/lib/dapp/build/stage/import_artifact.rb +1 -1
- data/lib/dapp/build/stage/install/ga_pre_install_patch_dependencies.rb +0 -4
- data/lib/dapp/build/stage/install/install.rb +1 -1
- data/lib/dapp/build/stage/mod/logging.rb +2 -2
- data/lib/dapp/build/stage/setup/ga_post_setup_patch.rb +0 -4
- data/lib/dapp/build/stage/setup/ga_post_setup_patch_dependencies.rb +2 -2
- data/lib/dapp/build/stage/setup/ga_pre_setup_patch.rb +0 -4
- data/lib/dapp/build/stage/setup/setup.rb +1 -1
- data/lib/dapp/builder/base.rb +0 -7
- data/lib/dapp/builder/chef.rb +67 -408
- data/lib/dapp/builder/chef/berksfile.rb +78 -69
- data/lib/dapp/builder/chef/cookbook.rb +257 -0
- data/lib/dapp/builder/chef/cookbook_metadata.rb +54 -52
- data/lib/dapp/builder/none.rb +0 -6
- data/lib/dapp/cli/build.rb +8 -1
- data/lib/dapp/cli/stage_image.rb +1 -1
- data/lib/dapp/config/directive/base.rb +1 -3
- data/lib/dapp/config/directive/git_artifact_remote.rb +3 -6
- data/lib/dapp/dimg.rb +13 -14
- data/lib/dapp/dimg/path.rb +1 -9
- data/lib/dapp/error/tar_writer.rb +6 -0
- data/lib/dapp/git_artifact.rb +136 -37
- data/lib/dapp/git_repo/base.rb +44 -28
- data/lib/dapp/git_repo/own.rb +11 -7
- data/lib/dapp/git_repo/remote.rb +8 -45
- data/lib/dapp/image/docker.rb +9 -11
- data/lib/dapp/image/stage.rb +1 -1
- data/lib/dapp/project/chef.rb +2 -7
- data/lib/dapp/project/command/stages/cleanup_local.rb +1 -2
- data/lib/dapp/project/command/stages/cleanup_repo.rb +1 -2
- data/lib/dapp/version.rb +2 -2
- metadata +4 -3
- data/lib/dapp/build/stage/setup/chef_cookbooks.rb +0 -36
data/lib/dapp/git_repo/own.rb
CHANGED
@@ -10,23 +10,27 @@ module Dapp
|
|
10
10
|
dimg.project.local_git_artifact_exclude_paths
|
11
11
|
end
|
12
12
|
|
13
|
-
def container_path
|
14
|
-
dimg.container_dapp_path('git_repo_own', "#{name}.git")
|
15
|
-
end
|
16
|
-
|
17
13
|
def path
|
18
14
|
@path ||= Rugged::Repository.discover(dimg.home_path.to_s).path
|
19
15
|
rescue Rugged::RepositoryError => _e
|
20
16
|
raise Error::Rugged, code: :local_git_repository_does_not_exist
|
21
17
|
end
|
22
18
|
|
23
|
-
def
|
24
|
-
|
19
|
+
def diff(from, to, **kwargs)
|
20
|
+
if to.nil?
|
21
|
+
git.lookup(from).diff_workdir
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def latest_commit(_branch = nil)
|
28
|
+
git.head.target_id
|
25
29
|
end
|
26
30
|
|
27
31
|
def lookup_commit(commit)
|
28
32
|
super
|
29
|
-
rescue Rugged::OdbError
|
33
|
+
rescue Rugged::OdbError => _e
|
30
34
|
raise Error::Rugged, code: :commit_not_found_in_local_git_repository, data: { commit: commit }
|
31
35
|
end
|
32
36
|
end
|
data/lib/dapp/git_repo/remote.rb
CHANGED
@@ -9,66 +9,31 @@ module Dapp
|
|
9
9
|
|
10
10
|
dimg.project.log_secondary_process(dimg.project.t(code: 'process.git_artifact_clone', data: { name: name }), short: true) do
|
11
11
|
begin
|
12
|
-
Rugged::Repository.clone_at(url, path, bare: true
|
12
|
+
Rugged::Repository.clone_at(url, path, bare: true)
|
13
13
|
rescue Rugged::NetworkError, Rugged::SslError => e
|
14
14
|
raise Error::Rugged, code: :rugged_remote_error, data: { message: e.message, url: url }
|
15
15
|
end
|
16
16
|
end unless File.directory?(path)
|
17
17
|
end
|
18
18
|
|
19
|
-
def _rugged_credentials
|
20
|
-
@_rugged_credentials ||= begin
|
21
|
-
ssh_url = begin
|
22
|
-
URI.parse(@url)
|
23
|
-
false
|
24
|
-
rescue URI::InvalidURIError
|
25
|
-
true
|
26
|
-
end
|
27
|
-
|
28
|
-
if ssh_url
|
29
|
-
host_with_user = @url.split(':', 2).first
|
30
|
-
username = host_with_user.split('@', 2).reverse.last
|
31
|
-
Rugged::Credentials::SshKeyFromAgent.new(username: username)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
19
|
def path
|
37
|
-
dimg.build_path(
|
38
|
-
end
|
39
|
-
|
40
|
-
def container_path
|
41
|
-
dimg.container_tmp_path('git_repo_remote', name, Digest::MD5.hexdigest(@url)).to_s
|
42
|
-
end
|
43
|
-
|
44
|
-
def git_bare
|
45
|
-
@git_bare ||= Rugged::Repository.new(path, bare: true, credentials: _rugged_credentials)
|
20
|
+
dimg.build_path("#{name}.git").to_s
|
46
21
|
end
|
47
22
|
|
48
23
|
def fetch!(branch = nil)
|
49
24
|
branch ||= self.branch
|
50
25
|
dimg.project.log_secondary_process(dimg.project.t(code: 'process.git_artifact_fetch', data: { name: name }), short: true) do
|
51
|
-
|
52
|
-
raise Error::Rugged, code: :branch_not_exist_in_remote_git_repository, data: { branch: branch, url: url } unless branch_exist?(branch)
|
26
|
+
git.fetch('origin', [branch])
|
53
27
|
end unless dimg.ignore_git_fetch || dimg.project.dry_run?
|
54
28
|
end
|
55
29
|
|
56
|
-
def
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
def latest_commit(name)
|
61
|
-
git_bare.ref("refs/remotes/#{branch_format(name)}").target_id
|
62
|
-
end
|
63
|
-
|
64
|
-
def cleanup!
|
65
|
-
super
|
66
|
-
FileUtils.rm_rf path
|
30
|
+
def latest_commit(branch)
|
31
|
+
git.ref("refs/remotes/origin/#{branch}").target_id
|
67
32
|
end
|
68
33
|
|
69
34
|
def lookup_commit(commit)
|
70
35
|
super
|
71
|
-
rescue Rugged::OdbError
|
36
|
+
rescue Rugged::OdbError => _e
|
72
37
|
raise Error::Rugged, code: :commit_not_found_in_remote_git_repository, data: { commit: commit, url: url }
|
73
38
|
end
|
74
39
|
|
@@ -76,10 +41,8 @@ module Dapp
|
|
76
41
|
|
77
42
|
attr_reader :url
|
78
43
|
|
79
|
-
|
80
|
-
|
81
|
-
def branch_format(name)
|
82
|
-
"origin/#{name.reverse.chomp('origin/'.reverse).reverse}"
|
44
|
+
def git
|
45
|
+
super(bare: true)
|
83
46
|
end
|
84
47
|
end
|
85
48
|
end
|
data/lib/dapp/image/docker.rb
CHANGED
@@ -7,6 +7,10 @@ module Dapp
|
|
7
7
|
attr_reader :name
|
8
8
|
attr_reader :project
|
9
9
|
|
10
|
+
def self.image_by_name(name:, **kwargs)
|
11
|
+
(@images ||= {})[name] ||= new(name: name, **kwargs)
|
12
|
+
end
|
13
|
+
|
10
14
|
def initialize(name:, project:, from: nil)
|
11
15
|
@from = from
|
12
16
|
@name = name
|
@@ -90,23 +94,17 @@ module Dapp
|
|
90
94
|
def cache_reset(name = '')
|
91
95
|
cache.delete(name)
|
92
96
|
Project.shellout!("docker images --format='{{.Repository}}:{{.Tag}};{{.ID}};{{.CreatedAt}};{{.Size}}' --no-trunc #{name}").stdout.lines.each do |l|
|
93
|
-
name, id, created_at, size_field = l.split(';')
|
97
|
+
name, id, created_at, size_field = l.split(';')
|
94
98
|
size = begin
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
number = match[1].to_f
|
99
|
-
unit = match[3].downcase
|
100
|
-
|
101
|
-
coef = case unit
|
102
|
-
when 'b' then 0
|
99
|
+
number, unit = size_field.split
|
100
|
+
coef = case unit.to_s.downcase
|
101
|
+
when 'b' then return number.to_f
|
103
102
|
when 'kb' then 1
|
104
103
|
when 'mb' then 2
|
105
104
|
when 'gb' then 3
|
106
105
|
when 'tb' then 4
|
107
106
|
end
|
108
|
-
|
109
|
-
number * (1000**coef)
|
107
|
+
number.to_f * (1000 ** coef)
|
110
108
|
end
|
111
109
|
cache[name] = { id: id, created_at: created_at, size: size }
|
112
110
|
end
|
data/lib/dapp/image/stage.rb
CHANGED
data/lib/dapp/project/chef.rb
CHANGED
@@ -6,18 +6,13 @@ module Dapp
|
|
6
6
|
def local_git_artifact_exclude_paths(&blk)
|
7
7
|
super do |exclude_paths|
|
8
8
|
exclude_paths << '.dapp_chef'
|
9
|
-
exclude_paths << '.chefinit'
|
10
9
|
|
11
10
|
yield exclude_paths if block_given?
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def chefinit_cookbook_path
|
20
|
-
File.join(path, '.chefinit')
|
14
|
+
def builder_cookbook_path
|
15
|
+
Pathname.new(path).join('.dapp_chef')
|
21
16
|
end
|
22
17
|
end # Chef
|
23
18
|
end # Project
|
@@ -99,8 +99,7 @@ module Dapp
|
|
99
99
|
project_images_detailed.each do |_, attrs|
|
100
100
|
attrs['Config']['Labels'].each do |repo_name, commit|
|
101
101
|
next if (repo = project_git_repositories[repo_name]).nil?
|
102
|
-
|
103
|
-
unproper_images_names.concat(image_hierarchy_by_id(attrs['Id'])) unless repo.send(git).exists?(commit)
|
102
|
+
unproper_images_names.concat(image_hierarchy_by_id(attrs['Id'])) unless repo.commit_exists?(commit)
|
104
103
|
end
|
105
104
|
end
|
106
105
|
remove_images(unproper_images_names.uniq)
|
@@ -73,8 +73,7 @@ module Dapp
|
|
73
73
|
repo_project_dappstage_images_detailed(registry).each do |_, attrs|
|
74
74
|
attrs[:labels].each do |repo_name, commit|
|
75
75
|
next if (repo = project_git_repositories[repo_name]).nil?
|
76
|
-
|
77
|
-
unproper_images.concat(repo_image_tags_hierarchy(registry, attrs[:id])) unless repo.send(git).exists?(commit)
|
76
|
+
unproper_images.concat(repo_image_tags_hierarchy(registry, attrs[:id])) unless repo.commit_exists?(commit)
|
78
77
|
end
|
79
78
|
end
|
80
79
|
remove_repo_images(registry, unproper_images.uniq)
|
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.8.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: 2017-
|
11
|
+
date: 2017-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -401,7 +401,6 @@ files:
|
|
401
401
|
- lib/dapp/build/stage/install/install.rb
|
402
402
|
- lib/dapp/build/stage/mod/group.rb
|
403
403
|
- lib/dapp/build/stage/mod/logging.rb
|
404
|
-
- lib/dapp/build/stage/setup/chef_cookbooks.rb
|
405
404
|
- lib/dapp/build/stage/setup/ga_post_setup_patch.rb
|
406
405
|
- lib/dapp/build/stage/setup/ga_post_setup_patch_dependencies.rb
|
407
406
|
- lib/dapp/build/stage/setup/ga_pre_setup_patch.rb
|
@@ -410,6 +409,7 @@ files:
|
|
410
409
|
- lib/dapp/builder/base.rb
|
411
410
|
- lib/dapp/builder/chef.rb
|
412
411
|
- lib/dapp/builder/chef/berksfile.rb
|
412
|
+
- lib/dapp/builder/chef/cookbook.rb
|
413
413
|
- lib/dapp/builder/chef/cookbook_metadata.rb
|
414
414
|
- lib/dapp/builder/chef/error.rb
|
415
415
|
- lib/dapp/builder/none.rb
|
@@ -476,6 +476,7 @@ files:
|
|
476
476
|
- lib/dapp/error/registry.rb
|
477
477
|
- lib/dapp/error/rugged.rb
|
478
478
|
- lib/dapp/error/shellout.rb
|
479
|
+
- lib/dapp/error/tar_writer.rb
|
479
480
|
- lib/dapp/exception/base.rb
|
480
481
|
- lib/dapp/exception/introspect_image.rb
|
481
482
|
- lib/dapp/exception/registry.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
module Build
|
3
|
-
module Stage
|
4
|
-
module SetupGroup
|
5
|
-
# ChefCookbooks
|
6
|
-
class ChefCookbooks < Base
|
7
|
-
include Mod::Group
|
8
|
-
|
9
|
-
def initialize(dimg, next_stage)
|
10
|
-
@prev_stage = Setup.new(dimg, self)
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
def dependencies
|
15
|
-
[dimg.builder.chef_cookbooks_checksum]
|
16
|
-
end
|
17
|
-
|
18
|
-
def prepare_image
|
19
|
-
super
|
20
|
-
dimg.builder.chef_cookbooks(image)
|
21
|
-
end
|
22
|
-
|
23
|
-
protected
|
24
|
-
|
25
|
-
def should_not_be_detailed?
|
26
|
-
true
|
27
|
-
end
|
28
|
-
|
29
|
-
def ignore_log_commands?
|
30
|
-
true
|
31
|
-
end
|
32
|
-
end # ChefCookbooks
|
33
|
-
end
|
34
|
-
end # Stage
|
35
|
-
end # Build
|
36
|
-
end # Dapp
|