dapp 0.6.17 → 0.7.1

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.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/config/en/common.yml +2 -2
  3. data/config/en/net_status.yml +25 -23
  4. data/lib/dapp.rb +24 -16
  5. data/lib/dapp/artifact.rb +1 -1
  6. data/lib/dapp/build/stage/after_install_artifact.rb +2 -2
  7. data/lib/dapp/build/stage/after_setup_artifact.rb +4 -4
  8. data/lib/dapp/build/stage/artifact_base.rb +25 -25
  9. data/lib/dapp/build/stage/artifact_default.rb +16 -16
  10. data/lib/dapp/build/stage/base.rb +36 -31
  11. data/lib/dapp/build/stage/before_install.rb +8 -8
  12. data/lib/dapp/build/stage/before_install_artifact.rb +2 -2
  13. data/lib/dapp/build/stage/before_setup.rb +8 -8
  14. data/lib/dapp/build/stage/before_setup_artifact.rb +2 -2
  15. data/lib/dapp/build/stage/build_artifact.rb +10 -10
  16. data/lib/dapp/build/stage/docker_instructions.rb +3 -3
  17. data/lib/dapp/build/stage/from.rb +7 -3
  18. data/lib/dapp/build/stage/ga_archive.rb +2 -2
  19. data/lib/dapp/build/stage/ga_archive_dependencies.rb +3 -3
  20. data/lib/dapp/build/stage/ga_artifact_patch.rb +2 -2
  21. data/lib/dapp/build/stage/ga_base.rb +2 -2
  22. data/lib/dapp/build/stage/ga_dependencies_base.rb +2 -2
  23. data/lib/dapp/build/stage/ga_latest_patch.rb +3 -3
  24. data/lib/dapp/build/stage/import_artifact.rb +19 -19
  25. data/lib/dapp/build/stage/install/ga_post_install_patch.rb +2 -2
  26. data/lib/dapp/build/stage/install/ga_post_install_patch_dependencies.rb +2 -2
  27. data/lib/dapp/build/stage/install/ga_pre_install_patch.rb +2 -2
  28. data/lib/dapp/build/stage/install/ga_pre_install_patch_dependencies.rb +2 -2
  29. data/lib/dapp/build/stage/install/install.rb +9 -9
  30. data/lib/dapp/build/stage/mod/group.rb +2 -2
  31. data/lib/dapp/build/stage/mod/logging.rb +19 -19
  32. data/lib/dapp/build/stage/setup/chef_cookbooks.rb +4 -4
  33. data/lib/dapp/build/stage/setup/ga_post_setup_patch.rb +2 -2
  34. data/lib/dapp/build/stage/setup/ga_post_setup_patch_dependencies.rb +3 -3
  35. data/lib/dapp/build/stage/setup/ga_pre_setup_patch.rb +2 -2
  36. data/lib/dapp/build/stage/setup/ga_pre_setup_patch_dependencies.rb +2 -2
  37. data/lib/dapp/build/stage/setup/setup.rb +9 -9
  38. data/lib/dapp/builder/base.rb +4 -4
  39. data/lib/dapp/builder/chef.rb +65 -64
  40. data/lib/dapp/builder/none.rb +45 -0
  41. data/lib/dapp/builder/shell.rb +3 -3
  42. data/lib/dapp/cli.rb +9 -10
  43. data/lib/dapp/cli/base.rb +6 -1
  44. data/lib/dapp/cli/bp.rb +2 -2
  45. data/lib/dapp/cli/build.rb +2 -2
  46. data/lib/dapp/cli/cleanup.rb +2 -2
  47. data/lib/dapp/cli/list.rb +2 -2
  48. data/lib/dapp/cli/mrproper.rb +0 -4
  49. data/lib/dapp/cli/push.rb +3 -3
  50. data/lib/dapp/cli/run.rb +3 -3
  51. data/lib/dapp/cli/spush.rb +2 -2
  52. data/lib/dapp/cli/stage_image.rb +2 -2
  53. data/lib/dapp/cli/stages/cleanup_local.rb +3 -3
  54. data/lib/dapp/cli/stages/cleanup_repo.rb +3 -3
  55. data/lib/dapp/cli/stages/flush_local.rb +3 -3
  56. data/lib/dapp/cli/stages/flush_repo.rb +3 -3
  57. data/lib/dapp/cli/stages/pull.rb +3 -3
  58. data/lib/dapp/cli/stages/push.rb +3 -3
  59. data/lib/dapp/config/artifact_dimg.rb +18 -0
  60. data/lib/dapp/config/artifact_group.rb +54 -0
  61. data/lib/dapp/config/base.rb +19 -0
  62. data/lib/dapp/config/dimg.rb +23 -0
  63. data/lib/dapp/config/dimg/instance_methods.rb +179 -0
  64. data/lib/dapp/config/dimg/validation.rb +124 -0
  65. data/lib/dapp/config/dimg_group.rb +56 -0
  66. data/lib/dapp/config/dimg_group_base.rb +36 -0
  67. data/lib/dapp/config/dimg_group_main.rb +21 -0
  68. data/lib/dapp/config/directive/artifact.rb +29 -54
  69. data/lib/dapp/config/directive/artifact_base.rb +92 -0
  70. data/lib/dapp/config/directive/base.rb +22 -0
  71. data/lib/dapp/config/directive/chef.rb +23 -61
  72. data/lib/dapp/config/directive/docker/artifact.rb +3 -14
  73. data/lib/dapp/config/directive/docker/base.rb +3 -78
  74. data/lib/dapp/config/directive/docker/dimg.rb +81 -0
  75. data/lib/dapp/config/directive/git_artifact_local.rb +13 -0
  76. data/lib/dapp/config/directive/git_artifact_remote.rb +55 -0
  77. data/lib/dapp/config/directive/mount.rb +25 -0
  78. data/lib/dapp/config/directive/shell/artifact.rb +3 -24
  79. data/lib/dapp/config/directive/shell/dimg.rb +68 -0
  80. data/lib/dapp/{application.rb → dimg.rb} +12 -33
  81. data/lib/dapp/{application → dimg}/git_artifact.rb +3 -3
  82. data/lib/dapp/{application → dimg}/path.rb +9 -5
  83. data/lib/dapp/{application → dimg}/stages.rb +8 -8
  84. data/lib/dapp/{application → dimg}/tags.rb +6 -6
  85. data/lib/dapp/docker_registry.rb +11 -15
  86. data/lib/dapp/error/dimg.rb +6 -0
  87. data/lib/dapp/git_artifact.rb +19 -20
  88. data/lib/dapp/git_repo/base.rb +6 -6
  89. data/lib/dapp/git_repo/own.rb +4 -4
  90. data/lib/dapp/git_repo/remote.rb +5 -5
  91. data/lib/dapp/image/docker.rb +0 -15
  92. data/lib/dapp/image/stage.rb +12 -22
  93. data/lib/dapp/project.rb +14 -18
  94. data/lib/dapp/project/command/build.rb +2 -2
  95. data/lib/dapp/project/command/cleanup.rb +9 -11
  96. data/lib/dapp/project/command/common.rb +8 -20
  97. data/lib/dapp/project/command/list.rb +7 -1
  98. data/lib/dapp/project/command/mrproper.rb +12 -22
  99. data/lib/dapp/project/command/push.rb +3 -4
  100. data/lib/dapp/project/command/run.rb +2 -2
  101. data/lib/dapp/project/command/spush.rb +3 -4
  102. data/lib/dapp/project/command/stage_image.rb +2 -2
  103. data/lib/dapp/project/command/stages/cleanup_local.rb +20 -24
  104. data/lib/dapp/project/command/stages/cleanup_repo.rb +3 -3
  105. data/lib/dapp/project/command/stages/common.rb +2 -3
  106. data/lib/dapp/project/command/stages/flush_local.rb +5 -7
  107. data/lib/dapp/project/command/stages/flush_repo.rb +2 -2
  108. data/lib/dapp/project/command/stages/pull.rb +3 -4
  109. data/lib/dapp/project/command/stages/push.rb +3 -4
  110. data/lib/dapp/project/dappfile.rb +9 -26
  111. data/lib/dapp/project/logging/base.rb +14 -0
  112. data/lib/dapp/project/logging/process.rb +1 -1
  113. data/lib/dapp/project/shellout/system.rb +2 -4
  114. data/lib/dapp/version.rb +1 -1
  115. metadata +25 -17
  116. data/lib/dapp/cli/tag.rb +0 -24
  117. data/lib/dapp/config/application.rb +0 -288
  118. data/lib/dapp/config/artifact.rb +0 -20
  119. data/lib/dapp/config/directive/build_dir.rb +0 -9
  120. data/lib/dapp/config/directive/git_artifact.rb +0 -59
  121. data/lib/dapp/config/directive/shell/base.rb +0 -85
  122. data/lib/dapp/config/directive/tmp_dir.rb +0 -36
  123. data/lib/dapp/config/main.rb +0 -20
  124. data/lib/dapp/error/application.rb +0 -6
  125. data/lib/dapp/project/command/tag.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e78ed224c52a413cdceeaacf7877326f47dc1dd
4
- data.tar.gz: ec07c5e997ed182b9ccfcf1c8097823ef3294d2e
3
+ metadata.gz: 5421a51c8a7e4aa97dd4366da97409289c335b88
4
+ data.tar.gz: 29d5b0434a33f376ce6809a5c32bfada6ab19528
5
5
  SHA512:
6
- metadata.gz: 7e3e56663b2ee9c215a284a7e59ba2ce71bf1a888c695002f123862d2c8e59676dc5a91ac74fe81082bc1ac4d14498eaab9e7d3e264501912e7f144535a0e0ed
7
- data.tar.gz: b105a61fec8f6b30bb9d9d65ed8621bfaba027e299136fd2f739a1f650453c6af6bca4656d63adc64811ccd65a5c3c7205f578da0dbfdc6a56fa17b7c7481e32
6
+ metadata.gz: 557da43530e8da7dd3051ce4e47de1e20bb3b4bb9d68b7c16e3dca37beebb334fe2be645b07e06a15113f79fc2d58ccb6e7e49383f46f7ffd18636a7d586d3b7
7
+ data.tar.gz: 9db7eea346c214b0990d7c823d7c95fcb179fc948e623ae17d3f09cc5f759f0fdb88cfd401e6bc4f70738f6acf4266f5620bafdb0cd112f24f21034617b5abf3
@@ -28,7 +28,6 @@ en:
28
28
  pulling: '[PULLING]'
29
29
  building: '[BUILDING]'
30
30
  default: '[RUNNING]'
31
- tagging: '[TAGGING]'
32
31
  success:
33
32
  default: '[OK]'
34
33
  failed:
@@ -41,8 +40,9 @@ en:
41
40
  empty: '[EMPTY]'
42
41
  push: '[PUSH]'
43
42
  pull: '[PULL]'
44
- tag: '[TAG]'
45
43
  warning:
44
+ wrong_using_base_directive: "WARNING: Directive '%{directive}' has declared after dimg_group|dimg|artifact!"
45
+ wrong_using_directive: "WARNING: Directive '%{directive}' has declared after dimg_group|dimg!"
46
46
  excess_builder_instruction: "WARNING: Excessive use of the 'builder' instruction. Builder type will be automatically determined by the first use of any builder."
47
47
  excess_name_instruction: "WARNING: Excessive use of the 'name' instruction. Given name corresponds to default name."
48
48
  another_image_already_tagged: 'WARNING: image with other id already exist.'
@@ -3,10 +3,10 @@ en:
3
3
  missing_translation: "Missing translation for code: '%{code}'!"
4
4
  shellout:
5
5
  shell_command_failed: ">>> START STREAM\n%{stream}\n>>> END STREAM"
6
- application:
7
- application_not_built: "Application hasn't been built yet!"
8
- application_not_run: "Application run failed!"
9
- git_branch_without_name: "Application has specific revision that isn't associated with a branch name!"
6
+ dimg:
7
+ dimg_not_built: "Dimg hasn't been built yet!"
8
+ dimg_not_run: "Dimg run failed!"
9
+ git_branch_without_name: "Dimg has specific revision that isn't associated with a branch name!"
10
10
  ci_environment_required: 'CI environment required (Travis or GitLab CI)!'
11
11
  chef_stage_checksum_not_calculated: "Chef stage '%{stage}' checksum is not calculated yet, run build first"
12
12
  dappfile:
@@ -18,38 +18,40 @@ en:
18
18
  built_id_not_defined: '`from.built_id` not defined!'
19
19
  from_image_not_found: 'Image `%{name}` not found!'
20
20
  project:
21
- spush_command_unexpected_apps_number: "Command 'spush' can process only one application!"
22
- tag_command_unexpected_apps_number: "Command 'tag' can process only one application!"
23
- tag_command_incorrect_tag: "Incorrect tag ('%{name}') given!"
24
- repo_name_incorrect: "Incorrect repo ('%{name}') given!"
25
- command_unexpected_apps_number: "Command can process only one application!"
26
- no_such_app: "No such app: '%{apps_patterns}'!"
21
+ spush_command_unexpected_dimgs_number: "Command 'spush' can process only one dimg!"
22
+ command_unexpected_dimgs_number: "Command can process only one dimg!"
23
+ no_such_dimg: "No such dimg: '%{dimgs_patterns}'!"
27
24
  dappfile_not_found: "Dappfile not found!"
28
25
  cannot_run_ssh_agent: "Cannot run ssh-agent"
29
26
  ssh_key_not_found: "Ssh key '%{path}' not exist!"
30
- mrproper_required_option: "Expected command option '--improper-dev-mode-cache', '--improper-cache-version-stages' or '--all'!"
27
+ mrproper_required_option: "Expected command option '--all' or '--improper-cache-version-stages'!"
31
28
  config:
29
+ dimg_name_required: 'Dimg name required!'
30
+ dimg_name_incorrect: "Dimg has incorrect name '%{name}': doesn't match regex '%{reg}'!"
31
+ export_to_required: "Export: 'to' directive required!"
32
+ export_cwd_absolute_path_required: "Export: given cwd path must be absolute!"
33
+ export_to_absolute_path_required: "Export: given 'to' path must be absolute!"
34
+ export_include_paths_relative_path_required: "Export: given 'include_paths' path must be relative!"
35
+ export_exclude_paths_relative_path_required: "Export: given 'exclude_paths' path must be relative!"
36
+ mount_from_absolute_path_required: "Mount: given 'from' path must be absolute!"
37
+ mount_from_type_required: "Mount: 'from' directive expect 'build_dir' or 'tmp_dir' type!"
32
38
  builder_type_conflict: 'Conflict between builder types!'
33
39
  builder_type_unsupported: "Defined unsupported builder type `%{type}`!"
34
- artifact_unexpected_attribute: "Artifact doesn't has attribute '%{attr}'!"
40
+ docker_from_incorrect: "`docker.from` has incorrect value `%{name}`: expected format `image_name:tag`!"
41
+ stage_artifact_not_associated: "Artifact not associated with any stage: expected 'before' or 'after' attribute!"
42
+ stage_artifact_double_associate: "Artifact cannot use with both associated attributes 'before' and 'after'!"
43
+ stage_artifact_not_supported_associated_stage: "Artifact not supported associated stage '%{stage}'!"
35
44
  artifact_conflict: "Conflict between artifacts paths!"
36
- scratch_unsupported_directive: "Scratch application has unsupported directive '%{directive}'!"
37
- scratch_artifact_required: "Scratch application without artifacts!"
38
- scratch_artifact_associated: "Scratch artifact cannot be associated: not expected 'before'/'after' option!"
45
+ scratch_unsupported_directive: "Scratch dimg has unsupported directive '%{directive}'!"
46
+ scratch_artifact_required: "Scratch dimg without artifacts!"
47
+ scratch_artifact_associated: "Scratch artifact cannot be associated: not expected 'before'/'after' attribute!"
39
48
  scratch_artifact_docker_from: "Scratch artifact must have directive 'docker.from'!"
40
- stage_artifact_not_associated: "Artifact not associated with any stage: expected 'before' or 'after' option!"
41
- stage_artifact_double_associate: "Artifact cannot use with both associated options 'before' and 'after'!"
42
- stage_artifact_not_supported_associated_stage: "Artifact not supported associated stage '%{stage}'!"
43
- git_artifact_unexpected_attribute: "'%{type}' git artifact doesn't has attribute '%{attr}'!"
44
- docker_from_incorrect: "`docker.from` has incorrect value `%{name}`: expected format `image_name:tag`!"
45
- docker_from_without_tag: "`docker.from` has incorrect value `%{name}`: expected format `image_name:tag`!"
46
- app_name_incorrect: "Application has incorrect name '%{name}': doesn't match regex '%{reg}'!"
47
49
  chef:
48
50
  stage_path_overlap: "Cannot install '%{cookbook}' cookbook's path %{from} into %{to}: already exists"
49
51
  mdapp_dependency_in_metadata_forbidden: "Using mdapp as dependency in metadata.rb forbidden: detected '%{dependency}'"
50
52
  registry:
51
53
  incorrect_repo: 'Incorrect repository!'
52
- no_such_app: 'No such app in registry!'
54
+ no_such_dimg: 'No such dimg in registry!'
53
55
  authenticate_type_not_supported: 'Registry authenticate type not supported!'
54
56
  page_not_found: "Page '%{url}' not found!"
55
57
  user_not_authorized: 'User not authorized!'
@@ -24,7 +24,7 @@ require 'dapp/helper/sha256'
24
24
  require 'dapp/helper/net_status'
25
25
  require 'dapp/prctl'
26
26
  require 'dapp/error/base'
27
- require 'dapp/error/application'
27
+ require 'dapp/error/dimg'
28
28
  require 'dapp/error/dappfile'
29
29
  require 'dapp/error/build'
30
30
  require 'dapp/error/config'
@@ -42,7 +42,6 @@ require 'dapp/cli/base'
42
42
  require 'dapp/cli/build'
43
43
  require 'dapp/cli/push'
44
44
  require 'dapp/cli/spush'
45
- require 'dapp/cli/tag'
46
45
  require 'dapp/cli/list'
47
46
  require 'dapp/cli/stages'
48
47
  require 'dapp/cli/stages/flush_local'
@@ -57,24 +56,34 @@ require 'dapp/cli/bp'
57
56
  require 'dapp/cli/mrproper'
58
57
  require 'dapp/cli/stage_image'
59
58
  require 'dapp/filelock'
59
+ require 'dapp/config/base'
60
+ require 'dapp/config/dimg/instance_methods'
61
+ require 'dapp/config/dimg/validation'
62
+ require 'dapp/config/dimg'
63
+ require 'dapp/config/artifact_dimg'
64
+ require 'dapp/config/dimg_group_base'
65
+ require 'dapp/config/dimg_group_main'
66
+ require 'dapp/config/dimg_group'
67
+ require 'dapp/config/artifact_group'
68
+ require 'dapp/config/directive/base'
69
+ require 'dapp/config/directive/artifact_base'
70
+ require 'dapp/config/directive/git_artifact_local'
71
+ require 'dapp/config/directive/git_artifact_remote'
60
72
  require 'dapp/config/directive/artifact'
61
73
  require 'dapp/config/directive/chef'
62
- require 'dapp/config/directive/git_artifact'
63
- require 'dapp/config/directive/tmp_dir'
64
- require 'dapp/config/directive/build_dir'
74
+ require 'dapp/config/directive/shell/dimg'
75
+ require 'dapp/config/directive/shell/artifact'
65
76
  require 'dapp/config/directive/docker/base'
77
+ require 'dapp/config/directive/docker/dimg'
66
78
  require 'dapp/config/directive/docker/artifact'
67
- require 'dapp/config/directive/shell/base'
68
- require 'dapp/config/directive/shell/artifact'
69
- require 'dapp/config/application'
70
- require 'dapp/config/main'
71
- require 'dapp/config/artifact'
79
+ require 'dapp/config/directive/mount'
72
80
  require 'dapp/builder/base'
73
81
  require 'dapp/builder/chef'
74
82
  require 'dapp/builder/chef/error'
75
83
  require 'dapp/builder/chef/cookbook_metadata'
76
84
  require 'dapp/builder/chef/berksfile'
77
85
  require 'dapp/builder/shell'
86
+ require 'dapp/builder/none'
78
87
  require 'dapp/build/stage/mod/logging'
79
88
  require 'dapp/build/stage/mod/group'
80
89
  require 'dapp/build/stage/base'
@@ -120,7 +129,6 @@ require 'dapp/project/command/list'
120
129
  require 'dapp/project/command/push'
121
130
  require 'dapp/project/command/run'
122
131
  require 'dapp/project/command/spush'
123
- require 'dapp/project/command/tag'
124
132
  require 'dapp/project/command/stages/common'
125
133
  require 'dapp/project/command/stages/cleanup_local'
126
134
  require 'dapp/project/command/stages/cleanup_repo'
@@ -143,11 +151,11 @@ require 'dapp/docker_registry/mod/request'
143
151
  require 'dapp/docker_registry/mod/authorization'
144
152
  require 'dapp/docker_registry/base'
145
153
  require 'dapp/docker_registry/default'
146
- require 'dapp/application/git_artifact'
147
- require 'dapp/application/path'
148
- require 'dapp/application/tags'
149
- require 'dapp/application/stages'
150
- require 'dapp/application'
154
+ require 'dapp/dimg/git_artifact'
155
+ require 'dapp/dimg/path'
156
+ require 'dapp/dimg/tags'
157
+ require 'dapp/dimg/stages'
158
+ require 'dapp/dimg'
151
159
  require 'dapp/artifact'
152
160
  require 'dapp/image/argument'
153
161
  require 'dapp/image/docker'
@@ -1,6 +1,6 @@
1
1
  module Dapp
2
2
  # Artifact
3
- class Artifact < Application
3
+ class Artifact < Dimg
4
4
  def artifact?
5
5
  true
6
6
  end
@@ -3,8 +3,8 @@ module Dapp
3
3
  module Stage
4
4
  # AfterInstallArtifact
5
5
  class AfterInstallArtifact < ArtifactDefault
6
- def initialize(application, next_stage)
7
- @prev_stage = InstallGroup::GAPostInstallPatch.new(application, self)
6
+ def initialize(dimg, next_stage)
7
+ @prev_stage = InstallGroup::GAPostInstallPatch.new(dimg, self)
8
8
  super
9
9
  end
10
10
  end # AfterInstallArtifact
@@ -3,11 +3,11 @@ module Dapp
3
3
  module Stage
4
4
  # AfterSetupArtifact
5
5
  class AfterSetupArtifact < ArtifactDefault
6
- def initialize(application, next_stage)
7
- @prev_stage = if application.artifact?
8
- SetupGroup::ChefCookbooks.new(application, self)
6
+ def initialize(dimg, next_stage)
7
+ @prev_stage = if dimg.artifact?
8
+ SetupGroup::ChefCookbooks.new(dimg, self)
9
9
  else
10
- SetupGroup::GAPostSetupPatch.new(application, self)
10
+ SetupGroup::GAPostSetupPatch.new(dimg, self)
11
11
  end
12
12
  super
13
13
  end
@@ -9,17 +9,17 @@ module Dapp
9
9
 
10
10
  def prepare_image
11
11
  super
12
- artifacts_applications_build!
12
+ artifacts_dimgs_build!
13
13
  artifacts_labels = {}
14
14
  artifacts.each do |artifact|
15
15
  apply_artifact(artifact, image)
16
- artifacts_labels["dapp-artifact-#{artifact[:name]}".to_sym] = artifact[:app].send(:last_stage).image.built_id
16
+ artifacts_labels["dapp-artifact-#{artifact[:name]}".to_sym] = artifact[:dimg].send(:last_stage).image.built_id
17
17
  end
18
18
  image.add_service_change_label artifacts_labels
19
19
  end
20
20
 
21
21
  def images
22
- [image].concat(artifacts.map { |artifact| artifact[:app].images }.flatten)
22
+ [image].concat(artifacts.map { |artifact| artifact[:dimg].images }.flatten)
23
23
  end
24
24
 
25
25
  protected
@@ -34,43 +34,43 @@ module Dapp
34
34
 
35
35
  def artifacts
36
36
  @artifacts ||= begin
37
- application.config.public_send("_#{name}").map do |artifact|
38
- app = Dapp::Artifact.new(config: artifact._config,
39
- project: application.project,
40
- ignore_git_fetch: application.ignore_git_fetch)
41
- { name: artifact._config._name, options: artifact._artifact_options, app: app }
37
+ dimg.config.public_send("_#{name}").map do |artifact|
38
+ artifact_dimg = Dapp::Artifact.new(config: artifact._config,
39
+ project: dimg.project,
40
+ ignore_git_fetch: dimg.ignore_git_fetch)
41
+ { name: artifact._config._name, options: artifact._artifact_options, dimg: artifact_dimg }
42
42
  end
43
43
  end
44
44
  end
45
45
 
46
46
  def artifacts_signatures
47
- artifacts.map { |artifact| hashsum [artifact[:app].signature, artifact[:options]] }
47
+ artifacts.map { |artifact| hashsum [artifact[:dimg].signature, artifact[:options]] }
48
48
  end
49
49
 
50
- def artifacts_applications_build!
50
+ def artifacts_dimgs_build!
51
51
  artifacts.each do |artifact|
52
- process = application.project.t(code: 'process.artifact_building', data: { name: artifact[:name] })
53
- application.project.log_secondary_process(process,
54
- short: !application.project.log_verbose?,
55
- quiet: application.artifact? && !application.project.log_verbose?) do
56
- application.project.with_log_indent do
57
- artifact[:app].build!
52
+ process = dimg.project.t(code: 'process.artifact_building', data: { name: artifact[:name] })
53
+ dimg.project.log_secondary_process(process,
54
+ short: !dimg.project.log_verbose?,
55
+ quiet: dimg.artifact? && !dimg.project.log_verbose?) do
56
+ dimg.project.with_log_indent do
57
+ artifact[:dimg].build!
58
58
  end
59
59
  end
60
60
  end
61
61
  end
62
62
 
63
63
  # rubocop:disable Metrics/AbcSize
64
- def run_artifact_app(app, artifact_name, commands)
64
+ def run_artifact_dimg(artifact_dimg, artifact_name, commands)
65
65
  docker_options = ['--rm',
66
- "--volume #{application.tmp_path('artifact', artifact_name)}:#{app.container_tmp_path(artifact_name)}",
67
- "--volumes-from #{application.project.base_container}",
68
- "--entrypoint #{application.project.bash_path}"]
69
- application.project.log_secondary_process(application.project.t(code: 'process.artifact_copy',
70
- data: { name: artifact_name }),
71
- short: true,
72
- quiet: application.artifact? && !application.project.log_verbose?) do
73
- app.run(docker_options, [%(-ec '#{application.project.shellout_pack(commands)}')])
66
+ "--volume #{dimg.tmp_path('artifact', artifact_name)}:#{artifact_dimg.container_tmp_path(artifact_name)}",
67
+ "--volumes-from #{dimg.project.base_container}",
68
+ "--entrypoint #{dimg.project.bash_path}"]
69
+ dimg.project.log_secondary_process(dimg.project.t(code: 'process.artifact_copy',
70
+ data: { name: artifact_name }),
71
+ short: true,
72
+ quiet: dimg.artifact? && !dimg.project.log_verbose?) do
73
+ artifact_dimg.run(docker_options, [%(-ec '#{dimg.project.shellout_pack(commands)}')])
74
74
  end
75
75
  end
76
76
  # rubocop:enable Metrics/AbcSize
@@ -7,30 +7,30 @@ module Dapp
7
7
 
8
8
  # rubocop:disable Metrics/AbcSize
9
9
  def apply_artifact(artifact, image)
10
- return if application.project.dry_run?
10
+ return if dimg.project.dry_run?
11
11
 
12
12
  artifact_name = artifact[:name]
13
- app = artifact[:app]
13
+ artifact_dimg = artifact[:dimg]
14
14
  cwd = artifact[:options][:cwd]
15
- paths = artifact[:options][:paths]
15
+ include_paths = artifact[:options][:include_paths]
16
16
  exclude_paths = artifact[:options][:exclude_paths]
17
17
  owner = artifact[:options][:owner]
18
18
  group = artifact[:options][:group]
19
- where_to_add = artifact[:options][:where_to_add]
19
+ to = artifact[:options][:to]
20
20
 
21
- command = safe_cp(where_to_add, app.container_tmp_path(artifact_name), Process.uid, Process.gid, cwd, paths, exclude_paths)
22
- run_artifact_app(app, artifact_name, command)
21
+ command = safe_cp(to, artifact_dimg.container_tmp_path(artifact_name), Process.uid, Process.gid, cwd, include_paths, exclude_paths)
22
+ run_artifact_dimg(artifact_dimg, artifact_name, command)
23
23
 
24
- command = safe_cp(application.container_tmp_path('artifact', artifact_name), where_to_add, owner, group, '', paths, exclude_paths)
24
+ command = safe_cp(dimg.container_tmp_path('artifact', artifact_name), to, owner, group, '', include_paths, exclude_paths)
25
25
  image.add_command command
26
- image.add_volume "#{application.tmp_path('artifact', artifact_name)}:#{application.container_tmp_path('artifact', artifact_name)}:ro"
26
+ image.add_volume "#{dimg.tmp_path('artifact', artifact_name)}:#{dimg.container_tmp_path('artifact', artifact_name)}:ro"
27
27
  end
28
28
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
29
29
 
30
30
  private
31
31
 
32
32
  # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/MethodLength
33
- def safe_cp(from, to, owner, group, cwd = '', paths = [], exclude_paths = [])
33
+ def safe_cp(from, to, owner, group, cwd = '', include_paths = [], exclude_paths = [])
34
34
  credentials = ''
35
35
  credentials += "-o #{owner} " if owner
36
36
  credentials += "-g #{group} " if group
@@ -39,18 +39,18 @@ module Dapp
39
39
  copy_files = proc do |from_, cwd_, path_ = ''|
40
40
  cwd_ = File.expand_path(File.join('/', cwd_))
41
41
  "if [[ -d #{File.join(from_, cwd_, path_)} ]]; then " \
42
- "#{application.project.find_path} #{File.join(from_, cwd_, path_)} #{excludes} -type f -exec " \
43
- "#{application.project.bash_path} -ec '#{application.project.install_path} -D #{credentials} {} " \
42
+ "#{dimg.project.find_path} #{File.join(from_, cwd_, path_)} #{excludes} -type f -exec " \
43
+ "#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -D #{credentials} {} " \
44
44
  "#{File.join(to, '$(echo {} | ' \
45
- "#{application.project.sed_path} -e \"s/#{File.join(from_, cwd_).gsub('/', '\\/')}//g\")")}' \\; ;" \
45
+ "#{dimg.project.sed_path} -e \"s/#{File.join(from_, cwd_).gsub('/', '\\/')}//g\")")}' \\; ;" \
46
46
  'fi'
47
47
  end
48
48
 
49
49
  commands = []
50
- commands << [application.project.install_path, credentials, '-d', to].join(' ')
51
- commands.concat(paths.empty? ? Array(copy_files.call(from, cwd)) : paths.map { |path| copy_files.call(from, cwd, path) })
52
- commands << "#{application.project.find_path} #{to} -type d -exec " \
53
- "#{application.project.bash_path} -ec '#{application.project.install_path} -d #{credentials} {}' \\;"
50
+ commands << [dimg.project.install_path, credentials, '-d', to].join(' ')
51
+ commands.concat(include_paths.empty? ? Array(copy_files.call(from, cwd)) : include_paths.map { |path| copy_files.call(from, cwd, path) })
52
+ commands << "#{dimg.project.find_path} #{to} -type d -exec " \
53
+ "#{dimg.project.bash_path} -ec '#{dimg.project.install_path} -d #{credentials} {}' \\;"
54
54
  commands.join(' && ')
55
55
  end
56
56
  # rubocop:enable Metrics/ParameterLists, Metrics/AbcSize, Metrics/MethodLength
@@ -8,10 +8,10 @@ module Dapp
8
8
  include Mod::Logging
9
9
 
10
10
  attr_accessor :prev_stage, :next_stage
11
- attr_reader :application
11
+ attr_reader :dimg
12
12
 
13
- def initialize(application, next_stage)
14
- @application = application
13
+ def initialize(dimg, next_stage)
14
+ @dimg = dimg
15
15
 
16
16
  @next_stage = next_stage
17
17
  @next_stage.prev_stage = self
@@ -19,14 +19,14 @@ module Dapp
19
19
 
20
20
  # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity
21
21
  def build_lock!
22
- return yield if application.project.dry_run?
22
+ return yield if dimg.project.dry_run?
23
23
 
24
24
  try_lock = proc do
25
25
  next yield unless should_be_tagged?
26
26
 
27
27
  no_lock = false
28
28
 
29
- application.project.lock("#{application.config._basename}.image.#{image.name}") do
29
+ dimg.project.lock("#{dimg.project.name}.image.#{image.name}") do
30
30
  image.cache_reset
31
31
 
32
32
  if should_be_tagged?
@@ -60,7 +60,7 @@ module Dapp
60
60
  def save_in_cache!
61
61
  prev_stage.save_in_cache! if prev_stage
62
62
  return unless should_be_tagged?
63
- image.save_in_cache! unless application.project.dry_run?
63
+ image.tag! unless dimg.project.dry_run?
64
64
  end
65
65
 
66
66
  def image
@@ -68,37 +68,48 @@ module Dapp
68
68
  if empty?
69
69
  prev_stage.image
70
70
  else
71
- Image::Stage.new(name: image_name, from: from_image, project: application.project)
71
+ Image::Stage.new(name: image_name, from: from_image, project: dimg.project)
72
72
  end
73
73
  end
74
74
  end
75
75
 
76
76
  def prepare_image
77
- return if application.project.dry_run?
78
- image.add_volumes_from application.project.base_container
79
- image_add_tmp_volumes(:tmp)
80
- image_add_tmp_volumes(:build)
81
- image.add_service_change_label dapp: application.stage_dapp_label
77
+ return if dimg.project.dry_run?
78
+ image.add_volumes_from dimg.project.base_container
79
+ image_add_volumes
80
+ image.add_service_change_label dapp: dimg.stage_dapp_label
82
81
  image.add_service_change_label 'dapp-cache-version'.to_sym => Dapp::BUILD_CACHE_VERSION
83
- image.add_service_change_label 'dapp-dev-mode'.to_sym => true if application.dev_mode?
84
82
 
85
- if application.project.ssh_auth_sock
86
- image.add_volume "#{application.project.ssh_auth_sock}:/tmp/dapp-ssh-agent"
83
+ if dimg.project.ssh_auth_sock
84
+ image.add_volume "#{dimg.project.ssh_auth_sock}:/tmp/dapp-ssh-agent"
87
85
  image.add_env 'SSH_AUTH_SOCK', '/tmp/dapp-ssh-agent'
88
86
  end
89
87
  end
90
88
 
91
- def image_add_tmp_volumes(type)
92
- (application.config.public_send("_#{type}_dir")._store +
89
+ def image_add_volumes
90
+ image_add_tmp_volumes
91
+ image_add_build_volumes
92
+ end
93
+
94
+ def image_add_tmp_volumes
95
+ image_add_default_volumes(:tmp_dir)
96
+ end
97
+
98
+ def image_add_build_volumes
99
+ image_add_default_volumes(:build_dir)
100
+ end
101
+
102
+ def image_add_default_volumes(type)
103
+ (dimg.config.public_send("_#{type}_mount").map(&:to) +
93
104
  from_image.labels.select { |l, _| l == "dapp-#{type}-dir" }.map { |_, value| value.split(';') }.flatten).each do |path|
94
105
  absolute_path = File.expand_path(File.join('/', path))
95
- tmp_path = application.send("#{type}_path", 'mount', absolute_path[1..-1]).tap(&:mkpath)
106
+ tmp_path = dimg.send("#{type}_path", 'mount', absolute_path[1..-1]).tap(&:mkpath)
96
107
  image.add_volume "#{tmp_path}:#{absolute_path}"
97
108
  end
98
109
  end
99
110
 
100
111
  def image_should_be_build?
101
- !empty? || application.project.log_verbose?
112
+ !empty? || dimg.project.log_verbose?
102
113
  end
103
114
 
104
115
  def empty?
@@ -113,13 +124,7 @@ module Dapp
113
124
  if empty?
114
125
  prev_stage.signature
115
126
  else
116
- args = []
117
- args << prev_stage.signature unless prev_stage.nil?
118
- args << application.build_cache_version
119
- args << builder_checksum
120
- args.concat(dependencies.flatten)
121
-
122
- hashsum args
127
+ hashsum [prev_stage.signature, builder_checksum, *dependencies.flatten]
123
128
  end
124
129
  end
125
130
 
@@ -137,7 +142,7 @@ module Dapp
137
142
  end
138
143
 
139
144
  def should_be_skipped?
140
- image.tagged? && !application.project.log_verbose? && !should_be_introspected?
145
+ image.tagged? && !dimg.project.log_verbose? && !should_be_introspected?
141
146
  end
142
147
 
143
148
  def should_be_tagged?
@@ -150,7 +155,7 @@ module Dapp
150
155
  end
151
156
 
152
157
  def image_name
153
- application.stage_cache_format % { signature: signature }
158
+ dimg.stage_cache_format % { signature: signature }
154
159
  end
155
160
 
156
161
  def from_image
@@ -164,15 +169,15 @@ module Dapp
164
169
  end
165
170
 
166
171
  def dependencies_files_checksum(regs)
167
- regs.map! { |reg| File.directory?(File.join(application.project.path, reg)) ? File.join(reg, '**', '*') : reg }
168
- unless (files = regs.map { |reg| Dir[File.join(application.project.path, reg)].map { |f| File.read(f) if File.file?(f) } }).empty?
172
+ regs.map! { |reg| File.directory?(File.join(dimg.project.path, reg)) ? File.join(reg, '**', '*') : reg }
173
+ unless (files = regs.map { |reg| Dir[File.join(dimg.project.path, reg)].map { |f| File.read(f) if File.file?(f) } }).empty?
169
174
  hashsum files
170
175
  end
171
176
  end
172
177
 
173
178
  def change_options
174
179
  @change_options ||= begin
175
- application.config._docker._change_options.to_h.delete_if do |_, val|
180
+ dimg.config._docker._change_options.to_h.delete_if do |_, val|
176
181
  val.nil? || (val.respond_to?(:empty?) && val.empty?)
177
182
  end
178
183
  end