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
@@ -1,74 +1,49 @@
1
1
  module Dapp
2
2
  module Config
3
+ # Directive
3
4
  module Directive
4
5
  # Artifact
5
- module Artifact
6
- # Base
7
- class Base
8
- attr_accessor :_where_to_add, :_cwd, :_paths, :_exclude_paths, :_owner, :_group
6
+ class Artifact < ArtifactBase
7
+ attr_reader :_config
9
8
 
10
- def initialize(where_to_add, **options)
11
- @_cwd = ''
12
- @_where_to_add = where_to_add
13
-
14
- options.each do |k, v|
15
- respond_to?("_#{k}=") ? send(:"_#{k}=", v) : raise(Error::Config, code: code,
16
- data: { type: object_name, attr: k })
17
- end
18
- end
9
+ def initialize(config:)
10
+ @_config = config
11
+ super()
12
+ end
19
13
 
20
- def _paths
21
- base_paths(@_paths)
14
+ def _export
15
+ super do |export|
16
+ export._before ||= @_before
17
+ export._after ||= @_after
18
+ export._config = _config
22
19
  end
20
+ end
23
21
 
24
- def _exclude_paths
25
- base_paths(@_exclude_paths)
26
- end
22
+ # Export
23
+ class Export < ArtifactBase::Export
24
+ attr_accessor :_config
25
+ attr_accessor :_before, :_after
27
26
 
28
- def _artifact_options
29
- {
30
- where_to_add: _where_to_add,
31
- cwd: _cwd,
32
- paths: _paths,
33
- exclude_paths: _exclude_paths,
34
- owner: _owner,
35
- group: _group
36
- }
27
+ def not_associated?
28
+ (_before || _after).nil?
37
29
  end
38
30
 
39
31
  protected
40
32
 
41
- def clone
42
- Marshal.load(Marshal.dump(self))
43
- end
44
-
45
- def base_paths(paths)
46
- Array(paths)
33
+ def before(stage)
34
+ associate_validation!(:before, stage)
35
+ @_before = stage
47
36
  end
48
37
 
49
- def code
50
- raise
51
- end
52
-
53
- def object_name
54
- self.class.to_s.split('::').last
55
- end
56
- end
57
-
58
- # Stage
59
- class Stage < Base
60
- attr_accessor :_config
61
-
62
- protected
63
-
64
- def clone
65
- artifact_options = Marshal.load(Marshal.dump(_artifact_options))
66
- where_to_add = artifact_options.delete(:where_to_add)
67
- self.class.new(where_to_add, config: _config, **artifact_options)
38
+ def after(stage)
39
+ associate_validation!(:after, stage)
40
+ @_after = stage
68
41
  end
69
42
 
70
- def code
71
- :artifact_unexpected_attribute
43
+ def associate_validation!(type, stage)
44
+ another = [:before, :after].find { |t| t != type }
45
+ raise Error::Config, code: :stage_artifact_double_associate unless send("_#{another}").nil?
46
+ raise Error::Config, code: :stage_artifact_not_supported_associated_stage unless [:install, :setup].include? stage
72
47
  end
73
48
  end
74
49
  end
@@ -0,0 +1,92 @@
1
+ module Dapp
2
+ module Config
3
+ module Directive
4
+ # ArtifactBase
5
+ class ArtifactBase < Base
6
+ attr_reader :_owner, :_group
7
+
8
+ def initialize
9
+ @_export = []
10
+ super
11
+ end
12
+
13
+ def _export
14
+ @_export.each do |export|
15
+ export._owner ||= @_owner
16
+ export._group ||= @_group
17
+
18
+ yield(export) if block_given?
19
+ end
20
+ end
21
+
22
+ # Export
23
+ class Export < Directive::Base
24
+ attr_accessor :_cwd, :_to, :_include_paths, :_exclude_paths, :_owner, :_group
25
+
26
+ def initialize(cwd = '/')
27
+ raise Error::Config, code: :export_cwd_absolute_path_required unless Pathname(cwd).absolute?
28
+ @_cwd = cwd
29
+ @_include_paths ||= []
30
+ @_exclude_paths ||= []
31
+
32
+ super()
33
+ end
34
+
35
+ def _artifact_options
36
+ {
37
+ to: _to,
38
+ cwd: _cwd,
39
+ include_paths: _include_paths,
40
+ exclude_paths: _exclude_paths,
41
+ owner: _owner,
42
+ group: _group
43
+ }
44
+ end
45
+
46
+ protected
47
+
48
+ def to(absolute_path)
49
+ raise Error::Config, code: :export_to_absolute_path_required unless Pathname(absolute_path).absolute?
50
+ @_to = absolute_path
51
+ end
52
+
53
+ def include_paths(*relative_paths)
54
+ raise Error::Config, code: :export_include_paths_relative_path_required unless relative_paths.all? { |path| Pathname(path).relative? }
55
+ _include_paths.concat(relative_paths)
56
+ end
57
+
58
+ def exclude_paths(*relative_paths)
59
+ raise Error::Config, code: :export_exclude_paths_relative_path_required unless relative_paths.all? { |path| Pathname(path).relative? }
60
+ _exclude_paths.concat(relative_paths)
61
+ end
62
+
63
+ def owner(owner)
64
+ @_owner = owner
65
+ end
66
+
67
+ def group(group)
68
+ @_group = group
69
+ end
70
+
71
+ def validate!
72
+ raise Error::Config, code: :export_to_required if _to.nil?
73
+ end
74
+ end
75
+
76
+ protected
77
+
78
+ def owner(owner)
79
+ @_owner = owner
80
+ end
81
+
82
+ def group(group)
83
+ @_group = group
84
+ end
85
+
86
+ def export(absolute_dir_path = '/', &blk)
87
+ @_export << self.class.const_get('Export').new(absolute_dir_path, &blk)
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,22 @@
1
+ module Dapp
2
+ module Config
3
+ module Directive
4
+ # Base
5
+ class Base < Config::Base
6
+ def initialize(&blk)
7
+ instance_eval(&blk) unless blk.nil?
8
+ end
9
+
10
+ protected
11
+
12
+ def clone
13
+ marshal_dup(self)
14
+ end
15
+
16
+ def clone_to_artifact
17
+ clone
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -2,85 +2,35 @@ module Dapp
2
2
  module Config
3
3
  module Directive
4
4
  # Chef
5
- class Chef
6
- attr_reader :_modules
7
- attr_reader :_recipes
5
+ class Chef < Base
6
+ attr_accessor :_dimod, :_recipe, :_attributes
8
7
 
9
8
  def initialize
10
- @_modules = []
11
- @_recipes = []
12
- end
13
-
14
- def module(*args)
15
- @_modules.concat(args)
16
- end
9
+ @_dimod = []
10
+ @_recipe = []
17
11
 
18
- def reset_modules
19
- @_modules.clear
12
+ super
20
13
  end
21
14
 
22
- def skip_module(*args)
23
- @_modules.reject! { |mod| args.include? mod }
15
+ def dimod(*args)
16
+ @_dimod.concat(args)
24
17
  end
25
18
 
26
19
  def recipe(*args)
27
- @_recipes.concat(args)
28
- end
29
-
30
- def remove_recipe(*args)
31
- @_recipes.reject! { |recipe| args.include? recipe }
32
- end
33
-
34
- def reset_recipes
35
- @_recipes.clear
20
+ @_recipe.concat(args)
36
21
  end
37
22
 
38
23
  def attributes
39
- @attributes ||= Attributes.new
24
+ @_attributes ||= Attributes.new
40
25
  end
41
26
 
42
27
  %i(before_install install before_setup setup build_artifact).each do |stage|
43
- define_method("#{stage}_attributes") do
44
- var = "@#{stage}_attributes"
45
- instance_variable_get(var) || instance_variable_set(var, Attributes.new)
46
- end
47
-
48
28
  define_method("_#{stage}_attributes") do
49
- attributes.in_depth_merge send("#{stage}_attributes")
50
- end
51
-
52
- define_method("reset_#{stage}_attributes") do
53
- instance_variable_set("@#{stage}_attributes", nil)
54
- end
55
- end
56
-
57
- def reset_attributes
58
- @attributes = nil
59
- end
60
-
61
- def reset_all_attributes
62
- reset_attributes
63
- %i(before_install install before_setup setup build_artifact).each do |stage|
64
- send("reset_#{stage}_attributes")
29
+ var = "@__#{stage}_attributes"
30
+ instance_variable_get(var) || instance_variable_set(var, Attributes.new)
65
31
  end
66
32
  end
67
33
 
68
- def reset_all
69
- reset_modules
70
- reset_recipes
71
- reset_all_attributes
72
- end
73
-
74
- protected
75
-
76
- def clone
77
- Marshal.load(Marshal.dump(self))
78
- end
79
-
80
- def empty?
81
- @_modules.empty? && @_recipes.empty?
82
- end
83
-
84
34
  # Attributes
85
35
  class Attributes < Hash
86
36
  def [](key)
@@ -89,6 +39,18 @@ module Dapp
89
39
  end
90
40
  end
91
41
  end # Attributes
42
+
43
+ %i(before_install install before_setup setup build_artifact).each do |stage|
44
+ define_method("__#{stage}_attributes") do
45
+ attributes.in_depth_merge send("_#{stage}_attributes")
46
+ end
47
+ end
48
+
49
+ protected
50
+
51
+ def empty?
52
+ (@_dimod + @_recipe).empty? && attributes.empty?
53
+ end
92
54
  end
93
55
  end
94
56
  end
@@ -4,20 +4,9 @@ module Dapp
4
4
  # Docker
5
5
  module Docker
6
6
  # Artifact
7
- class Artifact
8
- attr_reader :_from
9
- attr_reader :_from_cache_version
10
-
11
- def from(image, cache_version: nil)
12
- raise(Error::Config, code: :docker_from_incorrect, data: { name: image }) unless image =~ /^[[^ ].]+:[[^ ].]+$/
13
- @_from = image
14
- @_from_cache_version = cache_version
15
- end
16
-
17
- protected
18
-
19
- def clone
20
- Marshal.load(Marshal.dump(self))
7
+ class Artifact < Base
8
+ def _change_options
9
+ {}
21
10
  end
22
11
  end
23
12
  end
@@ -1,91 +1,16 @@
1
1
  module Dapp
2
2
  module Config
3
3
  module Directive
4
- # Docker
5
4
  module Docker
6
5
  # Base
7
- class Base
8
- attr_reader :_from, :_volume, :_expose, :_env, :_label, :_cmd, :_onbuild, :_workdir, :_user, :_entrypoint
9
- attr_reader :_from_cache_version
10
-
11
- def initialize
12
- @_volume = []
13
- @_expose = []
14
- @_env = {}
15
- @_label = {}
16
- @_cmd = []
17
- @_onbuild = []
18
- end
6
+ class Base < Directive::Base
7
+ attr_reader :_from, :_from_cache_version
19
8
 
20
9
  def from(image, cache_version: nil)
21
- image = image.to_s
22
- raise(Error::Config, code: :docker_from_incorrect, data: { name: image }) unless Image::Docker.image_name?(image)
23
- raise(Error::Config, code: :docker_from_without_tag, data: { name: image }) unless image.include?(':')
10
+ raise(Error::Config, code: :docker_from_incorrect, data: { name: image }) unless image =~ /^[[^ ].]+:[[^ ].]+$/
24
11
  @_from = image
25
12
  @_from_cache_version = cache_version
26
13
  end
27
-
28
- def volume(*args)
29
- @_volume.concat(args)
30
- end
31
-
32
- def expose(*args)
33
- @_expose.concat(args)
34
- end
35
-
36
- def env(**options)
37
- @_env.merge!(options)
38
- end
39
-
40
- def label(**options)
41
- @_label.merge!(options)
42
- end
43
-
44
- def cmd(*args)
45
- @_cmd.concat(args)
46
- end
47
-
48
- def onbuild(*args)
49
- @_onbuild.concat(args)
50
- end
51
-
52
- def workdir(val)
53
- @_workdir = val
54
- end
55
-
56
- def user(val)
57
- @_user = val
58
- end
59
-
60
- def entrypoint(*cmd_with_args)
61
- @_entrypoint = cmd_with_args.flatten
62
- end
63
-
64
- def _change_options
65
- {
66
- volume: _volume,
67
- expose: _expose,
68
- env: _env,
69
- label: _label,
70
- cmd: _cmd,
71
- onbuild: _onbuild,
72
- workdir: _workdir,
73
- user: _user,
74
- entrypoint: _entrypoint
75
- }
76
- end
77
-
78
- protected
79
-
80
- def clone
81
- Marshal.load(Marshal.dump(self))
82
- end
83
-
84
- def clone_to_artifact
85
- Artifact.new.tap do |docker|
86
- docker.instance_variable_set('@_from', @_from)
87
- end
88
- end
89
14
  end
90
15
  end
91
16
  end