dapp 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dapp +3 -3
  3. data/config/en/common.yml +19 -4
  4. data/config/en/net_status.yml +13 -4
  5. data/lib/dapp.rb +48 -16
  6. data/lib/dapp/application.rb +75 -40
  7. data/lib/dapp/application/path.rb +3 -2
  8. data/lib/dapp/application/stages.rb +59 -0
  9. data/lib/dapp/artifact.rb +22 -0
  10. data/lib/dapp/build/stage/after_install_artifact.rb +13 -0
  11. data/lib/dapp/build/stage/after_setup_artifact.rb +17 -0
  12. data/lib/dapp/build/stage/artifact_base.rb +80 -0
  13. data/lib/dapp/build/stage/artifact_default.rb +62 -0
  14. data/lib/dapp/build/stage/base.rb +47 -12
  15. data/lib/dapp/build/stage/before_install.rb +6 -5
  16. data/lib/dapp/build/stage/before_install_artifact.rb +13 -0
  17. data/lib/dapp/build/stage/before_setup.rb +7 -8
  18. data/lib/dapp/build/stage/before_setup_artifact.rb +13 -0
  19. data/lib/dapp/build/stage/build_artifact.rb +32 -0
  20. data/lib/dapp/build/stage/docker_instructions.rb +4 -22
  21. data/lib/dapp/build/stage/from.rb +7 -8
  22. data/lib/dapp/build/stage/ga_archive.rb +1 -1
  23. data/lib/dapp/build/stage/ga_archive_dependencies.rb +1 -1
  24. data/lib/dapp/build/stage/ga_artifact_patch.rb +21 -0
  25. data/lib/dapp/build/stage/ga_base.rb +6 -29
  26. data/lib/dapp/build/stage/ga_dependencies_base.rb +4 -13
  27. data/lib/dapp/build/stage/ga_latest_patch.rb +2 -2
  28. data/lib/dapp/build/stage/import_artifact.rb +69 -0
  29. data/lib/dapp/build/stage/install/ga_post_install_patch.rb +1 -1
  30. data/lib/dapp/build/stage/install/ga_post_install_patch_dependencies.rb +1 -1
  31. data/lib/dapp/build/stage/install/ga_pre_install_patch_dependencies.rb +1 -7
  32. data/lib/dapp/build/stage/install/install.rb +12 -7
  33. data/lib/dapp/build/stage/mod/logging.rb +10 -7
  34. data/lib/dapp/build/stage/setup/chef_cookbooks.rb +3 -4
  35. data/lib/dapp/build/stage/setup/ga_post_setup_patch.rb +1 -1
  36. data/lib/dapp/build/stage/setup/ga_pre_setup_patch.rb +2 -2
  37. data/lib/dapp/build/stage/setup/ga_pre_setup_patch_dependencies.rb +2 -8
  38. data/lib/dapp/build/stage/setup/setup.rb +12 -7
  39. data/lib/dapp/builder/base.rb +13 -1
  40. data/lib/dapp/builder/chef.rb +125 -79
  41. data/lib/dapp/builder/chef/cookbook_metadata.rb +1 -1
  42. data/lib/dapp/builder/shell.rb +2 -3
  43. data/lib/dapp/cli.rb +3 -3
  44. data/lib/dapp/cli/base.rb +0 -2
  45. data/lib/dapp/cli/bp.rb +0 -4
  46. data/lib/dapp/cli/build.rb +3 -7
  47. data/lib/dapp/cli/cleanup.rb +0 -2
  48. data/lib/dapp/cli/list.rb +0 -2
  49. data/lib/dapp/cli/mrproper.rb +22 -0
  50. data/lib/dapp/cli/push.rb +4 -3
  51. data/lib/dapp/cli/run.rb +0 -2
  52. data/lib/dapp/cli/spush.rb +0 -2
  53. data/lib/dapp/cli/stage_image.rb +24 -0
  54. data/lib/dapp/cli/stages.rb +7 -5
  55. data/lib/dapp/cli/stages/cleanup_local.rb +28 -0
  56. data/lib/dapp/cli/stages/cleanup_repo.rb +24 -0
  57. data/lib/dapp/cli/stages/{flush.rb → flush_local.rb} +4 -6
  58. data/lib/dapp/cli/stages/{cleanup.rb → flush_repo.rb} +4 -6
  59. data/lib/dapp/cli/stages/pull.rb +28 -0
  60. data/lib/dapp/cli/stages/push.rb +24 -0
  61. data/lib/dapp/config/application.rb +185 -44
  62. data/lib/dapp/config/artifact.rb +10 -50
  63. data/lib/dapp/config/directive/artifact.rb +77 -0
  64. data/lib/dapp/config/directive/build_dir.rb +9 -0
  65. data/lib/dapp/config/directive/chef.rb +95 -0
  66. data/lib/dapp/config/directive/docker/artifact.rb +26 -0
  67. data/lib/dapp/config/directive/docker/base.rb +91 -0
  68. data/lib/dapp/config/directive/git_artifact.rb +59 -0
  69. data/lib/dapp/config/directive/shell/artifact.rb +38 -0
  70. data/lib/dapp/config/directive/shell/base.rb +85 -0
  71. data/lib/dapp/config/directive/tmp_dir.rb +36 -0
  72. data/lib/dapp/config/main.rb +1 -7
  73. data/lib/dapp/core_ext/hash.rb +21 -0
  74. data/lib/dapp/docker_registry/base.rb +60 -5
  75. data/lib/dapp/docker_registry/mod/request.rb +2 -14
  76. data/lib/dapp/git_artifact.rb +32 -23
  77. data/lib/dapp/git_repo/base.rb +1 -1
  78. data/lib/dapp/image/argument.rb +3 -3
  79. data/lib/dapp/image/docker.rb +13 -16
  80. data/lib/dapp/image/scratch.rb +29 -0
  81. data/lib/dapp/image/stage.rb +33 -23
  82. data/lib/dapp/lock/base.rb +18 -11
  83. data/lib/dapp/lock/file.rb +18 -16
  84. data/lib/dapp/prctl.rb +1 -0
  85. data/lib/dapp/project.rb +22 -9
  86. data/lib/dapp/project/command/bp.rb +2 -5
  87. data/lib/dapp/project/command/build.rb +1 -2
  88. data/lib/dapp/project/command/cleanup.rb +9 -7
  89. data/lib/dapp/project/command/common.rb +37 -12
  90. data/lib/dapp/project/command/mrproper.rb +57 -0
  91. data/lib/dapp/project/command/push.rb +8 -2
  92. data/lib/dapp/project/command/run.rb +1 -1
  93. data/lib/dapp/project/command/stage_image.rb +15 -0
  94. data/lib/dapp/project/command/stages/cleanup_local.rb +100 -0
  95. data/lib/dapp/project/command/stages/cleanup_repo.rb +65 -0
  96. data/lib/dapp/project/command/stages/common.rb +48 -0
  97. data/lib/dapp/project/command/stages/flush_local.rb +24 -0
  98. data/lib/dapp/project/command/stages/flush_repo.rb +22 -0
  99. data/lib/dapp/project/command/stages/pull.rb +26 -0
  100. data/lib/dapp/project/command/stages/push.rb +22 -0
  101. data/lib/dapp/project/dappfile.rb +3 -1
  102. data/lib/dapp/project/deps/base.rb +52 -0
  103. data/lib/dapp/project/deps/gitartifact.rb +36 -0
  104. data/lib/dapp/project/lock.rb +20 -13
  105. data/lib/dapp/project/logging/base.rb +20 -3
  106. data/lib/dapp/project/logging/i18n.rb +25 -0
  107. data/lib/dapp/project/logging/paint.rb +47 -0
  108. data/lib/dapp/project/logging/process.rb +17 -10
  109. data/lib/dapp/project/shellout/base.rb +74 -0
  110. data/lib/dapp/project/shellout/streaming.rb +49 -0
  111. data/lib/dapp/project/shellout/system.rb +72 -0
  112. data/lib/dapp/project/ssh_agent.rb +8 -9
  113. data/lib/dapp/version.rb +1 -1
  114. metadata +48 -17
  115. data/lib/dapp/build/stage/artifact.rb +0 -40
  116. data/lib/dapp/build/stage/mod/artifact.rb +0 -79
  117. data/lib/dapp/config/chef.rb +0 -51
  118. data/lib/dapp/config/docker.rb +0 -82
  119. data/lib/dapp/config/git_artifact.rb +0 -51
  120. data/lib/dapp/config/shell.rb +0 -64
  121. data/lib/dapp/helper/i18n.rb +0 -20
  122. data/lib/dapp/helper/paint.rb +0 -27
  123. data/lib/dapp/helper/shellout.rb +0 -63
  124. data/lib/dapp/helper/streaming.rb +0 -47
  125. data/lib/dapp/project/command/stages_cleanup.rb +0 -72
  126. data/lib/dapp/project/command/stages_flush.rb +0 -20
  127. data/lib/dapp/project/paint.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b6165113f304afaf820870c5c598fee4e1479bd
4
- data.tar.gz: 88972466d5e6c65afe11935e7f942bb9277053da
3
+ metadata.gz: 3f7c169bd67fd20777df9d919789eb8a05849e0b
4
+ data.tar.gz: 6cb60dfa39665c8551ba425cae42a7a3f9513403
5
5
  SHA512:
6
- metadata.gz: a3f72d1c7e43506f02d5df57543652f1b1d6e33d04552c340cf67b28ae35a2bd5b3e244ae8985ac176d03fdec08c1fb509edf40f1f77880af2ce0e176ef5725b
7
- data.tar.gz: 7b51f113c56a01579955a6fb554baa10c69f5a22f8267f0998cc0117a0d2aaff01036971777a2ae849a0b245894df485cf9f4279100c7f90e58e8d1fbec4368a
6
+ metadata.gz: 380deffddc3206ee8c200015bd71e367f7c9b1b3e04a684acbc2cd539ee75bf9398a09b341ec5ac7f776a34396ccc1f89c203e6bc2c86f8ff370f874b07bf4de
7
+ data.tar.gz: dcfb3adef54dc705d13a13e1d24c3256d6b1a1d87675a0f3d2fd48db5cb6052fe4da8e5fe184fc58ad399be84087e63f43e6fbe93bdc6fe9e8a818d510f928f6
data/bin/dapp CHANGED
@@ -11,12 +11,12 @@ rescue Dapp::Error::Shellout => e
11
11
  $stderr.puts(Dapp::Helper::NetStatus.message(e))
12
12
  exit 1
13
13
  rescue Dapp::Error::Base, NetStatus::Exception => e
14
- $stderr.puts(Dapp::Helper::Paint.paint_string(Dapp::Helper::NetStatus.message(e), :warning))
14
+ $stderr.puts(Dapp::Project.paint_string(Dapp::Helper::NetStatus.message(e), :warning))
15
15
  exit 1
16
16
  rescue Interrupt => _e
17
- $stderr.puts(Dapp::Helper::Paint.paint_string('Interrupted', :warning))
17
+ $stderr.puts(Dapp::Project.paint_string('Interrupted', :warning))
18
18
  exit 1
19
19
  rescue Errno::EACCES => _e
20
- $stderr.puts(Dapp::Helper::Paint.paint_string('Permission denied!', :warning))
20
+ $stderr.puts(Dapp::Project.paint_string('Permission denied!', :warning))
21
21
  exit 1
22
22
  end
@@ -11,20 +11,27 @@ en:
11
11
  process:
12
12
  artifact_copy: "copying artifact '%{name}'"
13
13
  artifact_building: "building artifact '%{name}'"
14
- git_artifact_loading: 'loading git_artifact'
15
14
  git_artifact_clone: "cloning remote git_artifact '%{name}'"
16
15
  git_artifact_fetch: "fetching remote git_artifact '%{name}'"
17
- chefdk_loading: 'loading chefdk'
18
- berks_vendor: 'berks vendor'
16
+ berks_vendor: 'vendoring cookbooks'
17
+ chef_cookbooks_stage_berks_vendor: 'vendoring cookbooks for chef cookbooks stage'
19
18
  waiting_resouce_lock: "waiting for locked resource '%{name}'"
19
+ gitartifact_container_loading: 'loading dappdeps/gitartifact container'
20
+ base_container_loading: 'loading dappdeps/base container'
21
+ chefdk_container_loading: 'loading dappdeps/chefdk container'
22
+ system_shellout_container_loading: 'loading system shellout container'
23
+ image_pull: "pulling image '%{name}'"
24
+ image_push: "pushing image '%{name}'"
20
25
  status:
21
26
  process:
22
27
  pushing: '[PUSHING]'
28
+ pulling: '[PULLING]'
23
29
  building: '[BUILDING]'
24
30
  default: '[RUNNING]'
25
31
  success:
26
32
  default: '[OK]'
27
33
  failed:
34
+ not_pulled: '[NOT PULLED]'
28
35
  default: '[FAILED]'
29
36
  state:
30
37
  using_cache: '[USING CACHE]'
@@ -32,16 +39,20 @@ en:
32
39
  build: '[BUILD]'
33
40
  empty: '[EMPTY]'
34
41
  push: '[PUSH]'
42
+ pull: '[PULL]'
35
43
  warning:
36
44
  excess_builder_instruction: "WARNING: Excessive use of the 'builder' instruction. Builder type will be automatically determined by the first use of any builder."
37
45
  excess_name_instruction: "WARNING: Excessive use of the 'name' instruction. Given name corresponds to default name."
38
46
  another_image_already_tagged: 'WARNING: image with other id already exist.'
47
+ tag_ignored: "WARNING: tag '%{tag}' ignored."
39
48
  group:
40
49
  install_group: 'Install group'
41
50
  setup_group: 'Setup group'
42
51
  stage:
43
52
  from: 'From'
53
+ import_artifact: 'Import Artifact'
44
54
  before_install: 'Before install'
55
+ before_install_artifact: 'Before install artifact'
45
56
  g_a_archive_dependencies: 'Git artifacts dependencies'
46
57
  g_a_archive: 'Git artifacts: create archive'
47
58
  install_group:
@@ -50,8 +61,9 @@ en:
50
61
  install: 'Install'
51
62
  g_a_post_install_patch_dependencies: 'Git artifacts dependencies'
52
63
  g_a_post_install_patch: 'Git artifacts: apply patches (after install)'
53
- artifact: 'Artifact'
64
+ after_install_artifact: 'After install artifact'
54
65
  before_setup: 'Before setup'
66
+ before_setup_artifact: 'Before setup artifact'
55
67
  setup_group:
56
68
  g_a_pre_setup_patch_dependencies: 'Git artifacts dependencies'
57
69
  g_a_pre_setup_patch: 'Git artifacts: apply patches (before setup)'
@@ -59,5 +71,8 @@ en:
59
71
  chef_cookbooks: 'Сhef сookbooks'
60
72
  g_a_post_setup_patch_dependencies: 'Git artifacts dependencies'
61
73
  g_a_post_setup_patch: 'Git artifacts: apply patches (after setup)'
74
+ after_setup_artifact: 'After setup artifact'
62
75
  g_a_latest_patch: 'Git artifacts: latest patch'
63
76
  docker_instructions: 'Docker instructions'
77
+ g_a_artifact_patch: 'Git artifacts: artifact patch'
78
+ build_artifact: 'Build artifact'
@@ -8,7 +8,7 @@ en:
8
8
  application_not_run: "Application run failed!"
9
9
  git_branch_without_name: "Application has specific revision that isn't associated with a branch name!"
10
10
  ci_environment_required: 'CI environment required (Travis or GitLab CI)!'
11
- cookbooks_stage_checksum_not_caclculated: "Cookbooks checksum not calculated for stage '%{stage}', run build first"
11
+ cookbooks_stage_checksum_not_calculated: "Cookbooks checksum not calculated for stage '%{stage}', run build first"
12
12
  dappfile:
13
13
  incorrect: "Dappfile with '%{error}':\n%{message}"
14
14
  build:
@@ -19,26 +19,35 @@ en:
19
19
  from_image_not_found: 'Image `%{name}` not found!'
20
20
  project:
21
21
  spush_command_unexpected_apps_number: "Command 'spush' can process only one application!"
22
- run_command_unexpected_apps_number: "Command 'run' can process only one application!"
22
+ command_unexpected_apps_number: "Command can process only one application!"
23
23
  no_such_app: "No such app: '%{apps_patterns}'!"
24
24
  dappfile_not_found: "Dappfile not found!"
25
25
  cannot_run_ssh_agent: "Cannot run ssh-agent"
26
26
  ssh_key_not_found: "Ssh key '%{path}' not exist!"
27
+ mrproper_required_option: "Expected command option '--all' or '--improper-cache-version-stages'!"
27
28
  config:
28
29
  builder_type_conflict: 'Conflict between builder types!'
29
30
  builder_type_unsupported: "Defined unsupported builder type `%{type}`!"
30
- docker_from_not_defined: "`docker.from` not defined!"
31
31
  artifact_unexpected_attribute: "Artifact doesn't has attribute '%{attr}'!"
32
+ artifact_conflict: "Conflict between artifacts paths!"
33
+ scratch_unsupported_directive: "Scratch application has unsupported directive '%{directive}'!"
34
+ scratch_artifact_required: "Scratch application without artifacts!"
35
+ scratch_artifact_associated: "Scratch artifact cannot be associated: not expected 'before'/'after' option!"
36
+ scratch_artifact_docker_from: "Scratch artifact must have directive 'docker.from'!"
37
+ stage_artifact_not_associated: "Artifact not associated with any stage: expected 'before' or 'after' option!"
38
+ stage_artifact_double_associate: "Artifact cannot use with both associated options 'before' and 'after'!"
39
+ stage_artifact_not_supported_associated_stage: "Artifact not supported associated stage '%{stage}'!"
32
40
  git_artifact_unexpected_attribute: "'%{type}' git artifact doesn't has attribute '%{attr}'!"
33
41
  docker_from_incorrect: "`docker.from` has incorrect value `%{name}`: expected format `image_name:tag`!"
34
42
  app_name_incorrect: "Application has incorrect name '%{name}': doesn't match regex '%{reg}'!"
35
43
  chef:
36
44
  stage_path_overlap: "Cannot install '%{cookbook}' cookbook's path %{from} into %{to}: already exists"
45
+ mdapp_dependency_in_metadata_forbidden: "Using mdapp as dependency in metadata.rb forbidden: detected '%{dependency}'"
37
46
  registry:
38
47
  incorrect_repo: 'Incorrect repository!'
39
48
  no_such_app: 'No such app in registry!'
40
49
  authenticate_type_not_supported: 'Registry authenticate type not supported!'
41
- not_found: 'Registry not found!'
50
+ page_not_found: "Page '%{url}' not found!"
42
51
  user_not_authorized: 'User not authorized!'
43
52
  response_with_error_status: 'Response with error status!'
44
53
  berksfile_absolute_path_forbidden: "Absolute paths in Berksfile are not allowed (cookbook '%{cookbook}', path: '%{path}')"
@@ -4,6 +4,7 @@ require 'tmpdir'
4
4
  require 'digest'
5
5
  require 'timeout'
6
6
  require 'base64'
7
+ require 'mixlib/cli'
7
8
  require 'mixlib/shellout'
8
9
  require 'securerandom'
9
10
  require 'excon'
@@ -16,13 +17,10 @@ require 'paint'
16
17
  require 'net_status'
17
18
 
18
19
  require 'dapp/version'
20
+ require 'dapp/core_ext/hash'
19
21
  require 'dapp/helper/cli'
20
22
  require 'dapp/helper/trivia'
21
23
  require 'dapp/helper/sha256'
22
- require 'dapp/helper/i18n'
23
- require 'dapp/helper/paint'
24
- require 'dapp/helper/streaming'
25
- require 'dapp/helper/shellout'
26
24
  require 'dapp/helper/net_status'
27
25
  require 'dapp/prctl'
28
26
  require 'dapp/error/base'
@@ -46,33 +44,47 @@ require 'dapp/cli/push'
46
44
  require 'dapp/cli/spush'
47
45
  require 'dapp/cli/list'
48
46
  require 'dapp/cli/stages'
49
- require 'dapp/cli/stages/flush'
50
- require 'dapp/cli/stages/cleanup'
47
+ require 'dapp/cli/stages/flush_local'
48
+ require 'dapp/cli/stages/flush_repo'
49
+ require 'dapp/cli/stages/cleanup_local'
50
+ require 'dapp/cli/stages/cleanup_repo'
51
+ require 'dapp/cli/stages/push'
52
+ require 'dapp/cli/stages/pull'
51
53
  require 'dapp/cli/run'
52
54
  require 'dapp/cli/cleanup'
53
55
  require 'dapp/cli/bp'
56
+ require 'dapp/cli/mrproper'
57
+ require 'dapp/cli/stage_image'
54
58
  require 'dapp/filelock'
59
+ require 'dapp/config/directive/artifact'
60
+ require 'dapp/config/directive/chef'
61
+ require 'dapp/config/directive/git_artifact'
62
+ require 'dapp/config/directive/tmp_dir'
63
+ require 'dapp/config/directive/build_dir'
64
+ require 'dapp/config/directive/docker/base'
65
+ require 'dapp/config/directive/docker/artifact'
66
+ require 'dapp/config/directive/shell/base'
67
+ require 'dapp/config/directive/shell/artifact'
55
68
  require 'dapp/config/application'
56
69
  require 'dapp/config/main'
57
- require 'dapp/config/chef'
58
- require 'dapp/config/shell'
59
70
  require 'dapp/config/artifact'
60
- require 'dapp/config/git_artifact'
61
- require 'dapp/config/docker'
62
71
  require 'dapp/builder/base'
63
72
  require 'dapp/builder/chef'
64
73
  require 'dapp/builder/chef/error'
65
74
  require 'dapp/builder/chef/cookbook_metadata'
66
75
  require 'dapp/builder/chef/berksfile'
67
76
  require 'dapp/builder/shell'
68
- require 'dapp/build/stage/mod/artifact'
69
77
  require 'dapp/build/stage/mod/logging'
70
78
  require 'dapp/build/stage/mod/group'
71
79
  require 'dapp/build/stage/base'
72
80
  require 'dapp/build/stage/ga_base'
73
81
  require 'dapp/build/stage/ga_dependencies_base'
82
+ require 'dapp/build/stage/artifact_base'
83
+ require 'dapp/build/stage/artifact_default'
74
84
  require 'dapp/build/stage/from'
85
+ require 'dapp/build/stage/import_artifact'
75
86
  require 'dapp/build/stage/before_install'
87
+ require 'dapp/build/stage/before_install_artifact'
76
88
  require 'dapp/build/stage/ga_archive_dependencies'
77
89
  require 'dapp/build/stage/ga_archive'
78
90
  require 'dapp/build/stage/install/ga_pre_install_patch_dependencies'
@@ -80,32 +92,49 @@ require 'dapp/build/stage/install/ga_pre_install_patch'
80
92
  require 'dapp/build/stage/install/install'
81
93
  require 'dapp/build/stage/install/ga_post_install_patch_dependencies'
82
94
  require 'dapp/build/stage/install/ga_post_install_patch'
83
- require 'dapp/build/stage/artifact'
95
+ require 'dapp/build/stage/after_install_artifact'
84
96
  require 'dapp/build/stage/before_setup'
97
+ require 'dapp/build/stage/before_setup_artifact'
85
98
  require 'dapp/build/stage/setup/ga_pre_setup_patch_dependencies'
86
99
  require 'dapp/build/stage/setup/ga_pre_setup_patch'
87
100
  require 'dapp/build/stage/setup/setup'
88
101
  require 'dapp/build/stage/setup/chef_cookbooks'
89
102
  require 'dapp/build/stage/setup/ga_post_setup_patch_dependencies'
90
103
  require 'dapp/build/stage/setup/ga_post_setup_patch'
104
+ require 'dapp/build/stage/after_setup_artifact'
91
105
  require 'dapp/build/stage/ga_latest_patch'
92
106
  require 'dapp/build/stage/docker_instructions'
107
+ require 'dapp/build/stage/ga_artifact_patch'
108
+ require 'dapp/build/stage/build_artifact'
93
109
  require 'dapp/project/lock'
94
110
  require 'dapp/project/ssh_agent'
95
111
  require 'dapp/project/dappfile'
96
- require 'dapp/project/paint'
112
+ require 'dapp/project/command/common'
97
113
  require 'dapp/project/command/build'
98
114
  require 'dapp/project/command/bp'
99
115
  require 'dapp/project/command/cleanup'
100
- require 'dapp/project/command/common'
116
+ require 'dapp/project/command/mrproper'
117
+ require 'dapp/project/command/stage_image'
101
118
  require 'dapp/project/command/list'
102
119
  require 'dapp/project/command/push'
103
120
  require 'dapp/project/command/run'
104
121
  require 'dapp/project/command/spush'
105
- require 'dapp/project/command/stages_flush'
106
- require 'dapp/project/command/stages_cleanup'
122
+ require 'dapp/project/command/stages/common'
123
+ require 'dapp/project/command/stages/cleanup_local'
124
+ require 'dapp/project/command/stages/cleanup_repo'
125
+ require 'dapp/project/command/stages/flush_local'
126
+ require 'dapp/project/command/stages/flush_repo'
127
+ require 'dapp/project/command/stages/push'
128
+ require 'dapp/project/command/stages/pull'
107
129
  require 'dapp/project/logging/base'
108
130
  require 'dapp/project/logging/process'
131
+ require 'dapp/project/logging/paint'
132
+ require 'dapp/project/logging/i18n'
133
+ require 'dapp/project/deps/base'
134
+ require 'dapp/project/deps/gitartifact'
135
+ require 'dapp/project/shellout/streaming'
136
+ require 'dapp/project/shellout/base'
137
+ require 'dapp/project/shellout/system'
109
138
  require 'dapp/project'
110
139
  require 'dapp/docker_registry'
111
140
  require 'dapp/docker_registry/mod/request'
@@ -115,10 +144,13 @@ require 'dapp/docker_registry/default'
115
144
  require 'dapp/application/git_artifact'
116
145
  require 'dapp/application/path'
117
146
  require 'dapp/application/tags'
147
+ require 'dapp/application/stages'
118
148
  require 'dapp/application'
149
+ require 'dapp/artifact'
119
150
  require 'dapp/image/argument'
120
151
  require 'dapp/image/docker'
121
152
  require 'dapp/image/stage'
153
+ require 'dapp/image/scratch'
122
154
  require 'dapp/git_repo/base'
123
155
  require 'dapp/git_repo/own'
124
156
  require 'dapp/git_repo/remote'
@@ -4,32 +4,28 @@ module Dapp
4
4
  include GitArtifact
5
5
  include Path
6
6
  include Tags
7
+ include Stages
7
8
 
8
9
  include Helper::Sha256
9
10
 
10
11
  attr_reader :config
11
12
  attr_reader :ignore_git_fetch
12
13
  attr_reader :should_be_built
13
- attr_reader :is_artifact
14
14
  attr_reader :project
15
15
 
16
- def initialize(config:, project:, should_be_built: false, ignore_git_fetch: false, is_artifact: false)
16
+ def initialize(config:, project:, should_be_built: false, ignore_git_fetch: false)
17
17
  @config = config
18
18
  @project = project
19
19
 
20
- @tmp_path = Dir.mktmpdir(project.cli_options[:tmp_dir_prefix] || 'dapp-')
21
-
22
- @last_stage = Build::Stage::DockerInstructions.new(self)
23
20
  @ignore_git_fetch = ignore_git_fetch
24
21
  @should_be_built = should_be_built
25
- @is_artifact = is_artifact
22
+
23
+ raise Error::Application, code: :application_not_built if should_be_built?
26
24
  end
27
25
 
28
26
  def build!
29
- raise Error::Application, code: :application_not_built if should_be_built && !last_stage.image.tagged?
30
-
31
27
  with_introspection do
32
- project.lock("#{config._basename}.images", shared: true) do
28
+ project.lock("#{config._basename}.images", readonly: true) do
33
29
  last_stage.build_lock! do
34
30
  last_stage.build!
35
31
  last_stage.save_in_cache!
@@ -41,72 +37,111 @@ module Dapp
41
37
  end
42
38
 
43
39
  def export!(repo, format:)
44
- builder.before_application_export
45
-
46
- raise Error::Application, code: :application_not_built unless last_stage.image.tagged? || project.dry_run?
47
-
48
- project.lock("#{config._basename}.images", shared: true) do
40
+ project.lock("#{config._basename}.images", readonly: true) do
49
41
  tags.each do |tag|
50
42
  image_name = format % { repo: repo, application_name: config._name, tag: tag }
51
- if project.dry_run?
52
- project.log_state(image_name, state: project.t(code: 'state.push'), styles: { status: :success })
53
- else
54
- project.lock("image.#{image_name.gsub('/', '__')}") do
55
- Dapp::Image::Stage.cache_reset(image_name)
56
- project.log_process(image_name, process: project.t(code: 'status.process.pushing')) do
57
- last_stage.image.export!(image_name, log_verbose: project.log_verbose?,
58
- log_time: project.log_time?)
59
- end
43
+ export_base!(last_stage.image, image_name)
44
+ end
45
+ end
46
+ end
47
+
48
+ def export_stages!(repo, format:)
49
+ project.lock("#{config._basename}.images", readonly: true) do
50
+ export_images.each do |image|
51
+ image_name = format % { repo: repo, signature: image.name.split(':').last }
52
+ export_base!(image, image_name)
53
+ end
54
+ end
55
+ end
56
+
57
+ def export_base!(image, image_name)
58
+ if project.dry_run?
59
+ project.log_state(image_name, state: project.t(code: 'state.push'), styles: { status: :success })
60
+ else
61
+ project.lock("image.#{hashsum image_name}") do
62
+ Dapp::Image::Stage.cache_reset(image_name)
63
+ project.log_process(image_name, process: project.t(code: 'status.process.pushing')) do
64
+ project.with_log_indent do
65
+ image.export!(image_name)
60
66
  end
61
67
  end
62
68
  end
63
69
  end
64
70
  end
65
71
 
72
+ def import_stages!(repo, format:)
73
+ project.lock("#{config._basename}.images", readonly: true) do
74
+ import_images.each do |image|
75
+ begin
76
+ image_name = format % { repo: repo, signature: image.name.split(':').last }
77
+ import_base!(image, image_name)
78
+ rescue Error::Shellout
79
+ next
80
+ end
81
+ break unless project.pull_all_stages?
82
+ end
83
+ end
84
+ end
85
+
86
+ def import_base!(image, image_name)
87
+ if project.dry_run?
88
+ project.log_state(image_name, state: project.t(code: 'state.pull'), styles: { status: :success })
89
+ else
90
+ project.lock("image.#{hashsum image_name}") do
91
+ project.log_process(image_name,
92
+ process: project.t(code: 'status.process.pulling'),
93
+ status: { failed: project.t(code: 'status.failed.not_pulled') },
94
+ style: { failed: :secondary }) do
95
+ image.import!(image_name)
96
+ end
97
+ end
98
+ end
99
+ end
100
+
66
101
  def run(docker_options, command)
67
- raise Error::Application, code: :application_not_built unless last_stage.image.tagged?
68
102
  cmd = "docker run #{[docker_options, last_stage.image.name, command].flatten.compact.join(' ')}"
69
103
  if project.dry_run?
70
- project.log_info(cmd)
104
+ project.log(cmd)
71
105
  else
72
106
  system(cmd) || raise(Error::Application, code: :application_not_run)
73
107
  end
74
108
  end
75
109
 
76
- def signature
77
- last_stage.send(:signature)
78
- end
79
-
80
- def stage_cache_format
81
- "#{project.cache_format % { application_name: config._basename }}:%{signature}"
110
+ def stage_image_name(stage_name)
111
+ stages.find { |stage| stage.send(:name) == stage_name }.image.name
82
112
  end
83
113
 
84
- def stage_dapp_label
85
- project.stage_dapp_label_format % { application_name: config._basename }
114
+ def builder
115
+ @builder ||= Builder.const_get(config._builder.capitalize).new(self)
86
116
  end
87
117
 
88
- def artifact(config)
89
- self.class.new(config: config, project: project, ignore_git_fetch: ignore_git_fetch, is_artifact: true, should_be_built: should_be_built)
118
+ def artifact?
119
+ false
90
120
  end
91
121
 
92
- def builder
93
- @builder ||= Builder.const_get(config._builder.capitalize).new(self)
122
+ def scratch?
123
+ config._docker._from.nil?
94
124
  end
95
125
 
96
126
  protected
97
127
 
128
+ def should_be_built?
129
+ should_be_built && begin
130
+ builder.before_application_should_be_built_check
131
+ !last_stage.image.tagged?
132
+ end
133
+ end
134
+
98
135
  def with_introspection
99
136
  yield
100
137
  rescue Exception::IntrospectImage => e
101
138
  data = e.net_status[:data]
102
- cmd = "docker run -ti --rm --entrypoint /bin/bash #{data[:options]} #{data[:built_id]}"
139
+ cmd = "docker run -ti --rm --entrypoint #{project.bash_path} #{data[:options]} #{data[:built_id]}"
103
140
  system(cmd).tap do |res|
104
141
  project.shellout!("docker rmi #{data[:built_id]}") if data[:rmi]
105
142
  res || raise(Error::Application, code: :application_not_run)
106
143
  end
107
144
  exit 0
108
145
  end
109
-
110
- attr_reader :last_stage
111
146
  end # Application
112
147
  end # Dapp