dapp 0.5.13 → 0.6.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/bin/dapp +3 -0
- data/config/en/common.yml +35 -6
- data/config/en/net_status.yml +20 -6
- data/lib/dapp.rb +53 -27
- data/lib/dapp/application.rb +48 -27
- data/lib/dapp/application/git_artifact.rb +1 -1
- data/lib/dapp/application/path.rb +2 -18
- data/lib/dapp/application/tags.rb +5 -5
- data/lib/dapp/build/stage/artifact.rb +8 -3
- data/lib/dapp/build/stage/base.rb +43 -30
- data/lib/dapp/build/stage/{infra_install.rb → before_install.rb} +6 -6
- data/lib/dapp/build/stage/before_setup.rb +27 -0
- data/lib/dapp/build/stage/docker_instructions.rb +12 -1
- data/lib/dapp/build/stage/from.rb +4 -3
- data/lib/dapp/build/stage/{source_1_archive.rb → ga_archive.rb} +7 -7
- data/lib/dapp/build/stage/{source_1_archive_dependencies.rb → ga_archive_dependencies.rb} +4 -4
- data/lib/dapp/build/stage/{source_base.rb → ga_base.rb} +31 -7
- data/lib/dapp/build/stage/{source_dependencies_base.rb → ga_dependencies_base.rb} +5 -6
- data/lib/dapp/build/stage/{source_5.rb → ga_latest_patch.rb} +6 -6
- data/lib/dapp/build/stage/install/ga_post_install_patch.rb +21 -0
- data/lib/dapp/build/stage/install/ga_post_install_patch_dependencies.rb +21 -0
- data/lib/dapp/build/stage/install/ga_pre_install_patch.rb +21 -0
- data/lib/dapp/build/stage/install/ga_pre_install_patch_dependencies.rb +31 -0
- data/lib/dapp/build/stage/install/install.rb +31 -0
- data/lib/dapp/build/stage/mod/artifact.rb +9 -19
- data/lib/dapp/build/stage/mod/group.rb +42 -0
- data/lib/dapp/build/stage/mod/logging.rb +62 -26
- data/lib/dapp/build/stage/setup/chef_cookbooks.rb +37 -0
- data/lib/dapp/build/stage/setup/ga_post_setup_patch.rb +25 -0
- data/lib/dapp/build/stage/setup/ga_post_setup_patch_dependencies.rb +31 -0
- data/lib/dapp/build/stage/setup/ga_pre_setup_patch.rb +25 -0
- data/lib/dapp/build/stage/setup/ga_pre_setup_patch_dependencies.rb +27 -0
- data/lib/dapp/build/stage/setup/setup.rb +31 -0
- data/lib/dapp/builder/base.rb +9 -6
- data/lib/dapp/builder/chef.rb +128 -107
- data/lib/dapp/builder/chef/berksfile.rb +3 -0
- data/lib/dapp/builder/shell.rb +4 -3
- data/lib/dapp/cli.rb +8 -6
- data/lib/dapp/cli/base.rb +6 -1
- data/lib/dapp/cli/bp.rb +41 -0
- data/lib/dapp/cli/build.rb +17 -4
- data/lib/dapp/cli/cleanup.rb +24 -0
- data/lib/dapp/cli/list.rb +2 -2
- data/lib/dapp/cli/push.rb +8 -9
- data/lib/dapp/cli/run.rb +3 -4
- data/lib/dapp/cli/spush.rb +20 -0
- data/lib/dapp/cli/stages.rb +2 -0
- data/lib/dapp/cli/stages/cleanup.rb +7 -3
- data/lib/dapp/cli/stages/flush.rb +6 -3
- data/lib/dapp/config/application.rb +17 -11
- data/lib/dapp/config/chef.rb +4 -0
- data/lib/dapp/config/docker.rb +3 -2
- data/lib/dapp/config/git_artifact.rb +1 -2
- data/lib/dapp/config/main.rb +5 -2
- data/lib/dapp/config/shell.rb +20 -16
- data/lib/dapp/docker_registry.rb +32 -0
- data/lib/dapp/docker_registry/base.rb +47 -0
- data/lib/dapp/docker_registry/default.rb +18 -0
- data/lib/dapp/docker_registry/mod/authorization.rb +62 -0
- data/lib/dapp/docker_registry/mod/request.rb +44 -0
- data/lib/dapp/error/image.rb +6 -0
- data/lib/dapp/error/project.rb +6 -0
- data/lib/dapp/error/registry.rb +6 -0
- data/lib/dapp/exception/registry.rb +6 -0
- data/lib/dapp/git_artifact.rb +6 -7
- data/lib/dapp/git_repo/base.rb +1 -1
- data/lib/dapp/git_repo/remote.rb +6 -38
- data/lib/dapp/helper/sha256.rb +3 -3
- data/lib/dapp/helper/shellout.rb +25 -7
- data/lib/dapp/helper/streaming.rb +1 -3
- data/lib/dapp/image/argument.rb +31 -18
- data/lib/dapp/image/docker.rb +15 -8
- data/lib/dapp/image/stage.rb +10 -12
- data/lib/dapp/lock/base.rb +44 -0
- data/lib/dapp/lock/error.rb +14 -0
- data/lib/dapp/lock/file.rb +33 -0
- data/lib/dapp/prctl.rb +22 -0
- data/lib/dapp/project.rb +75 -0
- data/lib/dapp/project/command/bp.rb +24 -0
- data/lib/dapp/project/command/build.rb +21 -0
- data/lib/dapp/project/command/cleanup.rb +24 -0
- data/lib/dapp/project/command/common.rb +51 -0
- data/lib/dapp/project/command/list.rb +14 -0
- data/lib/dapp/project/command/push.rb +21 -0
- data/lib/dapp/project/command/run.rb +15 -0
- data/lib/dapp/project/command/spush.rb +17 -0
- data/lib/dapp/project/command/stages_cleanup.rb +70 -0
- data/lib/dapp/project/command/stages_flush.rb +18 -0
- data/lib/dapp/project/dappfile.rb +70 -0
- data/lib/dapp/project/lock.rb +27 -0
- data/lib/dapp/project/logging/base.rb +107 -0
- data/lib/dapp/project/logging/process.rb +104 -0
- data/lib/dapp/project/paint.rb +16 -0
- data/lib/dapp/project/ssh_agent.rb +77 -0
- data/lib/dapp/version.rb +1 -1
- metadata +74 -27
- data/lib/dapp/application/deps/gitartifact.rb +0 -39
- data/lib/dapp/application/logging.rb +0 -120
- data/lib/dapp/application/system_shellout.rb +0 -63
- data/lib/dapp/build/stage/chef_cookbooks.rb +0 -33
- data/lib/dapp/build/stage/infra_setup.rb +0 -27
- data/lib/dapp/build/stage/install.rb +0 -27
- data/lib/dapp/build/stage/setup.rb +0 -27
- data/lib/dapp/build/stage/source_1.rb +0 -21
- data/lib/dapp/build/stage/source_1_dependencies.rb +0 -27
- data/lib/dapp/build/stage/source_2.rb +0 -17
- data/lib/dapp/build/stage/source_2_dependencies.rb +0 -17
- data/lib/dapp/build/stage/source_3.rb +0 -17
- data/lib/dapp/build/stage/source_3_dependencies.rb +0 -23
- data/lib/dapp/build/stage/source_4.rb +0 -21
- data/lib/dapp/build/stage/source_4_dependencies.rb +0 -27
- data/lib/dapp/cli/smartpush.rb +0 -19
- data/lib/dapp/controller.rb +0 -119
- data/lib/dapp/error/controller.rb +0 -6
- data/lib/dapp/helper/log.rb +0 -73
data/lib/dapp/config/main.rb
CHANGED
|
@@ -2,8 +2,10 @@ module Dapp
|
|
|
2
2
|
module Config
|
|
3
3
|
# Main
|
|
4
4
|
class Main < Application
|
|
5
|
-
def initialize(
|
|
6
|
-
@
|
|
5
|
+
def initialize(dappfile_path:, project:)
|
|
6
|
+
@project = project
|
|
7
|
+
|
|
8
|
+
@_home_path = Pathname.new(dappfile_path).parent.expand_path.to_s
|
|
7
9
|
@_basename = Pathname.new(@_home_path).basename.to_s
|
|
8
10
|
@_builder = Pathname.new(@_home_path).join('Berksfile').exist? ? :chef : :shell
|
|
9
11
|
|
|
@@ -16,6 +18,7 @@ module Dapp
|
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def name(value)
|
|
21
|
+
project.log_warning(desc: { code: 'excess_name_instruction', context: 'warning' }) if @_basename == value.to_s
|
|
19
22
|
@_basename = value
|
|
20
23
|
end
|
|
21
24
|
end
|
data/lib/dapp/config/shell.rb
CHANGED
|
@@ -2,24 +2,24 @@ module Dapp
|
|
|
2
2
|
module Config
|
|
3
3
|
# Shell
|
|
4
4
|
class Shell
|
|
5
|
-
attr_reader :
|
|
6
|
-
attr_reader :
|
|
5
|
+
attr_reader :_before_install, :_before_setup, :_install, :_setup
|
|
6
|
+
attr_reader :_before_install_cache_version, :_before_setup_cache_version, :_install_cache_version, :_setup_cache_version
|
|
7
7
|
|
|
8
8
|
def initialize
|
|
9
|
-
@
|
|
10
|
-
@
|
|
11
|
-
@_install
|
|
12
|
-
@_setup
|
|
9
|
+
@_before_install = []
|
|
10
|
+
@_before_setup = []
|
|
11
|
+
@_install = []
|
|
12
|
+
@_setup = []
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def
|
|
16
|
-
@
|
|
17
|
-
@
|
|
15
|
+
def before_install(*args, cache_version: nil)
|
|
16
|
+
@_before_install.concat(args)
|
|
17
|
+
@_before_install_cache_version = cache_version
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def
|
|
21
|
-
@
|
|
22
|
-
@
|
|
20
|
+
def before_setup(*args, cache_version: nil)
|
|
21
|
+
@_before_setup.concat(args)
|
|
22
|
+
@_before_setup_cache_version = cache_version
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def install(*args, cache_version: nil)
|
|
@@ -32,12 +32,12 @@ module Dapp
|
|
|
32
32
|
@_setup_cache_version = cache_version
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def
|
|
36
|
-
@
|
|
35
|
+
def reset_before_install
|
|
36
|
+
@_before_install = []
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
def
|
|
40
|
-
@
|
|
39
|
+
def reset_before_setup
|
|
40
|
+
@_before_setup = []
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def reset_install
|
|
@@ -52,6 +52,10 @@ module Dapp
|
|
|
52
52
|
methods.tap { |arr| arr.delete(__method__) }.grep(/^reset_/).each(&method(:send))
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
def empty?
|
|
56
|
+
@_before_install.empty? && @_before_setup.empty? && @_install.empty? && @_setup.empty?
|
|
57
|
+
end
|
|
58
|
+
|
|
55
59
|
def clone
|
|
56
60
|
Marshal.load(Marshal.dump(self))
|
|
57
61
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Dapp
|
|
2
|
+
# DockerRegistry
|
|
3
|
+
module DockerRegistry
|
|
4
|
+
def self.new(repo)
|
|
5
|
+
repo_regex =~ repo
|
|
6
|
+
expected_hostname = Regexp.last_match(1)
|
|
7
|
+
expected_repo_suffix = Regexp.last_match(2)
|
|
8
|
+
expected_hostname_url = expected_hostname ? "http://#{expected_hostname}" : nil
|
|
9
|
+
|
|
10
|
+
if hostname_exist?(expected_hostname_url)
|
|
11
|
+
Base.new(repo, expected_hostname_url, expected_repo_suffix)
|
|
12
|
+
else
|
|
13
|
+
Default.new(repo, File.join(*[expected_hostname, expected_repo_suffix].compact))
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.repo_regex
|
|
18
|
+
separator = /[_.]|__|[-]*/
|
|
19
|
+
alpha_numeric = /[[:alnum:]]*/
|
|
20
|
+
component = /#{alpha_numeric}[#{separator}#{alpha_numeric}]*/
|
|
21
|
+
port_number = /[0-9]+/
|
|
22
|
+
hostcomponent = /[[:alnum:]-]*[[:alnum:]]/
|
|
23
|
+
hostname = /#{hostcomponent}[\.#{hostcomponent}]*[:#{port_number}]?/
|
|
24
|
+
%r{^(#{hostname}/)?(#{component}[/#{component}]*)$}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.hostname_exist?(url)
|
|
28
|
+
return false unless url
|
|
29
|
+
Mod::Request.url_available?(url)
|
|
30
|
+
end
|
|
31
|
+
end # DockerRegistry
|
|
32
|
+
end # Dapp
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Dapp
|
|
2
|
+
# DockerRegistry
|
|
3
|
+
module DockerRegistry
|
|
4
|
+
# Base
|
|
5
|
+
class Base
|
|
6
|
+
include Mod::Request
|
|
7
|
+
include Mod::Authorization
|
|
8
|
+
|
|
9
|
+
API_VERSION = 'v2'.freeze
|
|
10
|
+
|
|
11
|
+
attr_accessor :repo
|
|
12
|
+
attr_accessor :hostname_url
|
|
13
|
+
attr_accessor :repo_suffix
|
|
14
|
+
|
|
15
|
+
def initialize(repo, hostname_url, repo_suffix)
|
|
16
|
+
self.repo = repo
|
|
17
|
+
self.hostname_url = hostname_url
|
|
18
|
+
self.repo_suffix = repo_suffix
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def repo_exist?
|
|
22
|
+
tags.any?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def tags
|
|
26
|
+
@tags ||= api_request(repo_suffix, 'tags/list')['tags']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def image_id_by_tag(tag)
|
|
30
|
+
response = api_request(repo_suffix, "/manifests/#{tag}", headers: { Accept: 'application/vnd.docker.distribution.manifest.v2+json' })
|
|
31
|
+
response['config']['digest'] if response['schemaVersion'] == 2
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
protected
|
|
35
|
+
|
|
36
|
+
def api_request(*uri, **options)
|
|
37
|
+
JSON.load(request(api_url(*uri), expects: [200], **options).body)
|
|
38
|
+
rescue Excon::Error::NotFound
|
|
39
|
+
raise Error::Registry, code: :not_found
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def api_url(*uri)
|
|
43
|
+
File.join(hostname_url, API_VERSION, '/', *uri)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end # DockerRegistry
|
|
47
|
+
end # Dapp
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Dapp
|
|
2
|
+
# DockerRegistry
|
|
3
|
+
module DockerRegistry
|
|
4
|
+
# Default
|
|
5
|
+
class Default < Base
|
|
6
|
+
DEFAULT_HOSTNAME_URL = 'https://registry.hub.docker.com'.freeze
|
|
7
|
+
|
|
8
|
+
def initialize(repo, repo_suffix)
|
|
9
|
+
super(repo, DEFAULT_HOSTNAME_URL, repo_suffix)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def repo_suffix=(val)
|
|
13
|
+
val = "library/#{val}" if val.split('/').one?
|
|
14
|
+
super(val)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end # Dapp
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module Dapp
|
|
2
|
+
# DockerRegistry
|
|
3
|
+
module DockerRegistry
|
|
4
|
+
module Mod
|
|
5
|
+
# Authorization
|
|
6
|
+
module Authorization
|
|
7
|
+
def authorization_options(url)
|
|
8
|
+
@authorization_options ||= begin
|
|
9
|
+
case authenticate_header = raw_request(url).headers['Www-Authenticate']
|
|
10
|
+
when /Bearer/ then { headers: { Authorization: "Bearer #{authorization_token(authenticate_header)}" } }
|
|
11
|
+
when /Basic/ then { headers: { Authorization: "Basic #{authorization_auth}" } }
|
|
12
|
+
else raise Error::Registry, code: :authenticate_type_not_supported
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def authorization_token(authenticate_header)
|
|
18
|
+
options = parse_authenticate_header(authenticate_header)
|
|
19
|
+
realm = options.delete(:realm)
|
|
20
|
+
begin
|
|
21
|
+
response = raw_request(realm, headers: { Authorization: "Basic #{authorization_auth}" }, query: options, expects: [200])
|
|
22
|
+
rescue Error::Registry
|
|
23
|
+
raise unless (response = raw_request(realm, query: options)).status == 200
|
|
24
|
+
end
|
|
25
|
+
JSON.load(response.body)['token']
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def parse_authenticate_header(header)
|
|
29
|
+
[:realm, :service, :scope].map do |option|
|
|
30
|
+
/#{option}="([[^"].]*)/ =~ header
|
|
31
|
+
next unless Regexp.last_match(1)
|
|
32
|
+
[option, Regexp.last_match(1)]
|
|
33
|
+
end.compact.to_h
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def authorization_auth
|
|
37
|
+
auths = auths_section_from_docker_config
|
|
38
|
+
r = repo
|
|
39
|
+
loop do
|
|
40
|
+
break unless r.include?('/') && !auths.keys.any? { |auth| auth.start_with?(r) }
|
|
41
|
+
r = chomp_name(r)
|
|
42
|
+
end
|
|
43
|
+
credential = (auths[r] || auths.find { |repo, _| repo == r })
|
|
44
|
+
raise Error::Registry, code: :user_not_authorized if credential.nil?
|
|
45
|
+
credential['auth']
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def auths_section_from_docker_config
|
|
49
|
+
file = Pathname(File.join(Dir.home, '.docker', 'config.json'))
|
|
50
|
+
raise Error::Registry, code: :user_not_authorized unless file.exist?
|
|
51
|
+
JSON.load(file.read)['auths'].tap { |auths| raise Error::Registry, code: :user_not_authorized if auths.nil? }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
def chomp_name(r)
|
|
57
|
+
r.split('/')[0..-2].join('/')
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end # Mod
|
|
61
|
+
end # DockerRegistry
|
|
62
|
+
end # Dapp
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Dapp
|
|
2
|
+
# DockerRegistry
|
|
3
|
+
module DockerRegistry
|
|
4
|
+
module Mod
|
|
5
|
+
# Request
|
|
6
|
+
module Request
|
|
7
|
+
def request(url, **options)
|
|
8
|
+
raw_request(url, deep_merge(options, authorization_options(url)))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def raw_request(url, **options)
|
|
12
|
+
Excon.new(url).request(deep_merge(default_request_options, options))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def url_available?(url)
|
|
16
|
+
raw_request(url, expects: [200])
|
|
17
|
+
true
|
|
18
|
+
rescue Excon::Error
|
|
19
|
+
false
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
protected
|
|
23
|
+
|
|
24
|
+
def default_request_options
|
|
25
|
+
{ method: :get, omit_default_port: true }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def deep_merge(hash1, hash2)
|
|
31
|
+
hash1.merge(hash2) do |_, v1, v2|
|
|
32
|
+
if v1.is_a?(Hash) && v2.is_a?(Hash)
|
|
33
|
+
v1.merge(v2)
|
|
34
|
+
else
|
|
35
|
+
[v1, v2].flatten
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end # Mod
|
|
41
|
+
end # DockerRegistry
|
|
42
|
+
end # Dapp
|
|
43
|
+
|
|
44
|
+
Dapp::DockerRegistry::Mod::Request.extend Dapp::DockerRegistry::Mod::Request
|
data/lib/dapp/git_artifact.rb
CHANGED
|
@@ -12,10 +12,9 @@ module Dapp
|
|
|
12
12
|
|
|
13
13
|
@where_to_add = where_to_add
|
|
14
14
|
|
|
15
|
-
@branch = branch || repo.application.cli_options[:git_artifact_branch] || repo.branch
|
|
15
|
+
@branch = branch || repo.application.project.cli_options[:git_artifact_branch] || repo.branch
|
|
16
16
|
@commit = commit
|
|
17
17
|
|
|
18
|
-
cwd = File.expand_path(File.join('/', cwd))[1..-1] unless cwd.nil? || cwd.empty?
|
|
19
18
|
@cwd = cwd
|
|
20
19
|
@paths = paths
|
|
21
20
|
@owner = owner
|
|
@@ -27,17 +26,17 @@ module Dapp
|
|
|
27
26
|
credentials = [:owner, :group].map { |attr| "--#{attr}=#{send(attr)}" unless send(attr).nil? }.compact
|
|
28
27
|
|
|
29
28
|
["install #{credentials.join(' ')} -d #{where_to_add}",
|
|
30
|
-
["
|
|
29
|
+
["git --git-dir=#{repo.container_path} archive #{stage.layer_commit(self)}:#{cwd} #{paths}",
|
|
31
30
|
"#{sudo}tar -x -C #{where_to_add}"].join(' | ')]
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
def apply_patch_command(stage)
|
|
35
34
|
current_commit = stage.layer_commit(self)
|
|
36
|
-
prev_commit = stage.
|
|
35
|
+
prev_commit = stage.prev_g_a_stage.layer_commit(self)
|
|
37
36
|
|
|
38
37
|
if prev_commit != current_commit || any_changes?(prev_commit, current_commit)
|
|
39
|
-
[["
|
|
40
|
-
"#{sudo}
|
|
38
|
+
[["git --git-dir=#{repo.container_path} #{diff_command(prev_commit, current_commit)}",
|
|
39
|
+
"#{sudo}git apply --whitespace=nowarn --directory=#{where_to_add} --unsafe-paths"].join(' | ')]
|
|
41
40
|
else
|
|
42
41
|
[]
|
|
43
42
|
end
|
|
@@ -84,7 +83,7 @@ module Dapp
|
|
|
84
83
|
sudo = ''
|
|
85
84
|
|
|
86
85
|
if owner || group
|
|
87
|
-
sudo =
|
|
86
|
+
sudo = 'sudo -E '
|
|
88
87
|
sudo += "-u #{sudo_format_user(owner)} " if owner
|
|
89
88
|
sudo += "-g #{sudo_format_user(group)} " if group
|
|
90
89
|
end
|
data/lib/dapp/git_repo/base.rb
CHANGED
data/lib/dapp/git_repo/remote.rb
CHANGED
|
@@ -2,28 +2,20 @@ module Dapp
|
|
|
2
2
|
module GitRepo
|
|
3
3
|
# Normal Git repo
|
|
4
4
|
class Remote < Base
|
|
5
|
-
def initialize(application, name, url
|
|
5
|
+
def initialize(application, name, url:)
|
|
6
6
|
super(application, name)
|
|
7
7
|
|
|
8
8
|
@url = url
|
|
9
|
-
@ssh_key_path = File.expand_path(ssh_key_path, application.home_path) if ssh_key_path
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
with_ssh_key do
|
|
15
|
-
application.log_secondary_process(application.t(code: 'process.git_artifact_clone', data: { name: name }), short: true) do
|
|
16
|
-
git "clone --bare --depth 1 #{url} #{path}"
|
|
17
|
-
end
|
|
10
|
+
application.project.log_secondary_process(application.project.t(code: 'process.git_artifact_clone', data: { name: name }), short: true) do
|
|
11
|
+
git "clone --bare --depth 1 #{url} #{path}"
|
|
18
12
|
end unless File.directory?(path)
|
|
19
13
|
end
|
|
20
14
|
|
|
21
15
|
def fetch!(branch = 'master')
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
end unless application.ignore_git_fetch || application.dry_run?
|
|
16
|
+
application.project.log_secondary_process(application.project.t(code: 'process.git_artifact_fetch', data: { name: name }), short: true) do
|
|
17
|
+
git_bare "fetch origin #{branch}:#{branch}"
|
|
18
|
+
end unless application.ignore_git_fetch || application.project.dry_run?
|
|
27
19
|
end
|
|
28
20
|
|
|
29
21
|
def cleanup!
|
|
@@ -34,30 +26,6 @@ module Dapp
|
|
|
34
26
|
protected
|
|
35
27
|
|
|
36
28
|
attr_reader :url
|
|
37
|
-
attr_reader :ssh_key_path
|
|
38
|
-
|
|
39
|
-
attr_accessor :use_ssh_key
|
|
40
|
-
def use_ssh_key
|
|
41
|
-
@use_ssh_key ||= false
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def with_ssh_key
|
|
45
|
-
original = use_ssh_key
|
|
46
|
-
self.use_ssh_key = true
|
|
47
|
-
|
|
48
|
-
yield
|
|
49
|
-
ensure
|
|
50
|
-
self.use_ssh_key = original
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def git(command, **kwargs)
|
|
54
|
-
if use_ssh_key && ssh_key_path
|
|
55
|
-
cmd = application.shellout_pack("/tmp/dapp_system_shellout/usr/bin/ssh-agent bash -ec '/tmp/dapp_system_shellout/usr/bin/ssh-add #{ssh_key_path}; #{application.git_path} #{command}'")
|
|
56
|
-
application.system_shellout!("bash -ec '#{cmd}'")
|
|
57
|
-
else
|
|
58
|
-
super
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
29
|
end
|
|
62
30
|
end
|
|
63
31
|
end
|
data/lib/dapp/helper/sha256.rb
CHANGED
|
@@ -8,9 +8,9 @@ module Dapp
|
|
|
8
8
|
|
|
9
9
|
def paths_content_hashsum(paths)
|
|
10
10
|
paths.map(&:to_s)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
.reject { |path| File.directory?(path) }
|
|
12
|
+
.sort
|
|
13
|
+
.reduce(nil) { |hash, path| hashsum [hash, File.read(path)].compact }
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def sha256(arg)
|