dapp 0.13.3 → 0.13.4

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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dapp +0 -13
  3. data/config/en/common.yml +4 -2
  4. data/config/en/net_status.yml +15 -3
  5. data/lib/dapp.rb +11 -6
  6. data/lib/dapp/cli.rb +1 -1
  7. data/lib/dapp/cli/command/base.rb +4 -4
  8. data/lib/dapp/config/directive/base.rb +4 -2
  9. data/lib/dapp/core_ext/hash.rb +14 -0
  10. data/lib/dapp/dapp.rb +32 -6
  11. data/lib/dapp/dapp/dapp_config.rb +85 -0
  12. data/lib/dapp/dapp/dappfile.rb +4 -0
  13. data/lib/dapp/dapp/deps/base.rb +2 -2
  14. data/lib/dapp/dapp/deps/gitartifact.rb +2 -2
  15. data/lib/dapp/dapp/logging/base.rb +5 -5
  16. data/lib/dapp/dapp/logging/process.rb +5 -7
  17. data/lib/dapp/dapp/shellout/base.rb +16 -17
  18. data/lib/dapp/deployment/cli/command/deployment.rb +2 -3
  19. data/lib/dapp/deployment/dapp/command/apply.rb +6 -6
  20. data/lib/dapp/deployment/dapp/dapp.rb +0 -1
  21. data/lib/dapp/deployment/kube_app.rb +1 -1
  22. data/lib/dapp/deployment/kube_base.rb +1 -1
  23. data/lib/dapp/dimg/build/stage/artifact_base.rb +3 -8
  24. data/lib/dapp/dimg/build/stage/base.rb +57 -38
  25. data/lib/dapp/dimg/build/stage/docker_instructions.rb +1 -1
  26. data/lib/dapp/dimg/build/stage/from.rb +6 -2
  27. data/lib/dapp/dimg/build/stage/ga_archive_dependencies.rb +2 -2
  28. data/lib/dapp/dimg/build/stage/ga_artifact_patch.rb +1 -5
  29. data/lib/dapp/dimg/build/stage/ga_base.rb +1 -14
  30. data/lib/dapp/dimg/build/stage/ga_latest_patch.rb +7 -31
  31. data/lib/dapp/dimg/build/stage/ga_related_dependencies_base.rb +21 -0
  32. data/lib/dapp/dimg/build/stage/import_artifact.rb +10 -3
  33. data/lib/dapp/dimg/build/stage/install/ga_post_install_patch_dependencies.rb +3 -3
  34. data/lib/dapp/dimg/build/stage/install/ga_pre_install_patch_dependencies.rb +3 -3
  35. data/lib/dapp/dimg/build/stage/mod/group.rb +19 -7
  36. data/lib/dapp/dimg/build/stage/mod/logging.rb +7 -20
  37. data/lib/dapp/dimg/build/stage/setup/ga_post_setup_patch_dependencies.rb +1 -1
  38. data/lib/dapp/dimg/build/stage/setup/ga_pre_setup_patch_dependencies.rb +3 -3
  39. data/lib/dapp/dimg/builder/chef.rb +2 -2
  40. data/lib/dapp/dimg/builder/chef/cookbook.rb +2 -2
  41. data/lib/dapp/dimg/cli/command/dimg.rb +1 -1
  42. data/lib/dapp/dimg/cli/command/dimg/build.rb +15 -8
  43. data/lib/dapp/dimg/config/directive/artifact_base.rb +13 -4
  44. data/lib/dapp/dimg/config/directive/dimg/instance_methods.rb +1 -1
  45. data/lib/dapp/dimg/config/directive/dimg/validation.rb +6 -1
  46. data/lib/dapp/dimg/config/directive/docker/base.rb +1 -2
  47. data/lib/dapp/dimg/config/directive/git_artifact_local.rb +3 -0
  48. data/lib/dapp/dimg/config/directive/git_artifact_remote.rb +1 -1
  49. data/lib/dapp/dimg/config/directive/mount.rb +9 -1
  50. data/lib/dapp/dimg/dapp/command/build_context/export.rb +13 -15
  51. data/lib/dapp/dimg/dapp/command/build_context/import.rb +3 -3
  52. data/lib/dapp/dimg/dapp/command/cleanup.rb +1 -1
  53. data/lib/dapp/dimg/dapp/command/common.rb +17 -6
  54. data/lib/dapp/dimg/dapp/command/mrproper.rb +9 -4
  55. data/lib/dapp/dimg/dapp/command/stages/cleanup_local.rb +19 -17
  56. data/lib/dapp/dimg/dapp/command/stages/cleanup_repo.rb +1 -1
  57. data/lib/dapp/dimg/dimg.rb +5 -5
  58. data/lib/dapp/dimg/dimg/git_artifact.rb +11 -6
  59. data/lib/dapp/dimg/dimg/path.rb +2 -6
  60. data/lib/dapp/dimg/git_artifact.rb +118 -66
  61. data/lib/dapp/dimg/git_repo/base.rb +1 -1
  62. data/lib/dapp/dimg/git_repo/own.rb +1 -1
  63. data/lib/dapp/dimg/git_repo/remote.rb +23 -14
  64. data/lib/dapp/dimg/image/docker.rb +11 -11
  65. data/lib/dapp/dimg/image/scratch.rb +33 -9
  66. data/lib/dapp/dimg/image/stage.rb +3 -3
  67. data/lib/dapp/helper/cli.rb +8 -0
  68. data/lib/dapp/helper/tar.rb +31 -0
  69. data/lib/dapp/kube/cli/command/kube.rb +5 -4
  70. data/lib/dapp/kube/cli/command/kube/deploy.rb +5 -0
  71. data/lib/dapp/kube/cli/command/kube/minikube_setup.rb +13 -0
  72. data/lib/dapp/kube/cli/command/kube/{secret_file_encrypt.rb → secret_extract.rb} +3 -3
  73. data/lib/dapp/kube/cli/command/kube/secret_generate.rb +11 -1
  74. data/lib/dapp/kube/client.rb +1 -1
  75. data/lib/dapp/kube/client/error.rb +1 -1
  76. data/lib/dapp/kube/dapp/command/common.rb +29 -4
  77. data/lib/dapp/kube/dapp/command/deploy.rb +43 -21
  78. data/lib/dapp/kube/dapp/command/dismiss.rb +1 -1
  79. data/lib/dapp/{deployment → kube}/dapp/command/minikube_setup.rb +12 -12
  80. data/lib/dapp/kube/dapp/command/secret_extract.rb +46 -0
  81. data/lib/dapp/kube/dapp/command/secret_generate.rb +33 -4
  82. data/lib/dapp/kube/dapp/dapp.rb +3 -2
  83. data/lib/dapp/kube/error/kubernetes.rb +7 -0
  84. data/lib/dapp/kube/secret.rb +1 -1
  85. data/lib/dapp/version.rb +2 -2
  86. metadata +11 -7
  87. data/lib/dapp/deployment/cli/command/deployment/minikube_setup.rb +0 -13
  88. data/lib/dapp/kube/dapp/command/secret_file_encrypt.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4e5c7613863b4e3513c88cb084d0b323c9edc54
4
- data.tar.gz: 8f9c887894a7af4f10b903a4b384bc0476eef466
3
+ metadata.gz: 6570b7b1469e193e6f8ff6f6af3aa14b209859e7
4
+ data.tar.gz: d3c5e800a04f70a35ca60a5a91dd83c026c5862a
5
5
  SHA512:
6
- metadata.gz: aaedc840723eade1037daa909219ad3b009ea44f19405f20dcc42f80afa9058d4d084eaed63738a6c98d60ac36da914fc0a9df6e8dd0de46eb9f6d06bfa52108
7
- data.tar.gz: 553efb13630ccb41e2ba2c22d81b3af28b746651b13bd012aff21ff082cdf941d3082372d89a3eaa0335ae61ac5dd9660a0c4afc28e19cf4b3cf49aad50cf7c5
6
+ metadata.gz: b9ce968a3bb3bcb5ae8e41a1baa09a6f60b62600aca223887aa007a90ca3fbdf90ba2990c2b3e24c87a2ff0c77491d7a2a0d6e1e5ccb3e01eb88e352550be68f
7
+ data.tar.gz: 4fd1fae4d99bec6b86f818c0e43991d4d14354db0fa30a1e177820cbbba43e12f430128aa06594a4ec2ce5713eed695d97beea4d5407bead8923b678b790dd06
data/bin/dapp CHANGED
@@ -5,20 +5,7 @@
5
5
  require 'rubygems'
6
6
  require 'dapp'
7
7
 
8
- def check_docker_version
9
- required_docker_version = '1.10.0'
10
- if Gem::Version.new(required_docker_version) >= Gem::Version.new(`docker --version`[/(\d+\.)+\d+/])
11
- $stderr.puts(Dapp::Dapp.paint_string("Required docker version: >= #{required_docker_version}!", :warning))
12
- exit 1
13
- end
14
- rescue Errno::ENOENT => e
15
- $stderr.puts(Dapp::Dapp.paint_string(e.message, :warning))
16
- exit 1
17
- end
18
-
19
8
  begin
20
- check_docker_version
21
-
22
9
  begin
23
10
  begin
24
11
  Dapp::CLI.new.run
data/config/en/common.yml CHANGED
@@ -39,7 +39,6 @@ en:
39
39
  using_cache: '[USING CACHE]'
40
40
  not_present: '[NOT PRESENT]'
41
41
  build: '[BUILD]'
42
- empty: '[EMPTY]'
43
42
  push: '[PUSH]'
44
43
  pull: '[PULL]'
45
44
  tag: '[TAG]'
@@ -54,7 +53,10 @@ en:
54
53
  stage_artifact_rewritten: "WARNING: Artifact stage rewritten from %{conflict_stage} to %{stage}."
55
54
  recipe_does_not_used: "WARNING: Recipe `%{recipe}` doesn't used in any stage."
56
55
  context_archive_not_found: "WARNING: context archive `%{path}` not found!"
57
- dapp_secret_key_not_found: "Secrets haven't decoded: set `DAPP_SECRET_KEY`!"
56
+ dapp_secret_key_not_found: "WARNING: Secrets haven't decoded: secret key not found in %{not_found_in}!"
57
+ introspect_image_impossible: "WARNING: You can't introspect stage `%{name}`!"
58
+ stage_dependencies_not_found: "WARNING: Stage dependencies `%{dependencies}` haven't been found in repo `%{repo}`!"
59
+ unsupported_dapp_config_options: "WARNING: .dapp_config includes unsupported options [%{options}]: use only following options [%{supported_options}]"
58
60
  group:
59
61
  install: 'Install group'
60
62
  setup: 'Setup group'
@@ -27,7 +27,7 @@ en:
27
27
  tag_name_incorrect: "Incorrect tag name `%{name}` given!"
28
28
  context_directory_not_found: "Context directory `%{path}` not found!"
29
29
  stored_build_dir_already_exist: "Cannot store current build_dir `%{path}`: restore or delete old build_dir!"
30
- secret_key_not_found: "Secret key `DAPP_SECRET_KEY` not found!"
30
+ secret_key_not_found: "Secret key not found in %{not_found_in}!"
31
31
  minikube_not_found: "Minikube not found: install minikube (https://github.com/kubernetes/minikube/releases)!"
32
32
  minikube_not_started: "Minikube not started!"
33
33
  project_helm_chart_not_found: "Project helm chart `%{path}` not found!"
@@ -35,16 +35,25 @@ en:
35
35
  helm_release_not_exist: "Helm release `%{name}` not exist!"
36
36
  file_not_exist: "File `%{path}` doesn't exist!"
37
37
  helm_directory_not_exist: "Helm directory doesn't exist in project!"
38
+ values_file_not_found: "Values file `%{path}` not found!"
39
+ secret_values_file_not_found: "Secret values file `%{path}` not found!"
40
+ user_containers_detected: "User containers have been using images!\n%{ids}"
38
41
  dapp:
39
42
  no_such_dimg: "No such dimg: `%{dimgs_patterns}`!"
40
43
  no_such_app: "No such app: `%{apps_patterns}`!"
41
44
  dappfile_not_found: "Dappfile not found!"
42
45
  cannot_run_ssh_agent: "Cannot run ssh-agent"
43
46
  ssh_key_not_found: "Ssh key `%{path}` not exist!"
47
+ docker_not_found: "Docker not found!"
48
+ docker_version: "Required docker version: >= %{version}!"
49
+ dapp_config_file_incorrect: "%{message}"
50
+ incorrect_dapp_config_option: ".dapp_config includes option `%{option}` with incorrect value `%{value}`: expected one of the following types [%{expected}]"
51
+ incorrect_dapp_config_option_color: ".dapp_config includes option `color` with incorrect value `%{value}`: expected one of the following values [%{expected}]"
44
52
  config:
45
53
  dimg_name_required: 'Dimg name required!'
46
54
  dimg_name_incorrect: "Dimg has incorrect name `%{value}`: doesn't match regex `%{pattern}`!"
47
- mount_from_required: "Mount: `from` directive required!"
55
+ mount_from_or_from_path_required: "Mount: `from` or `from_path` directive required!"
56
+ mount_duplicate_to: "Duplicate mount point `%{path}`!"
48
57
  export_to_required: "Export: `to` directive required!"
49
58
  add_to_required: "Add: `to` directive required!"
50
59
  export_cwd_absolute_path_required: "Export: given cwd path must be absolute!"
@@ -56,7 +65,6 @@ en:
56
65
  mount_from_type_required: "Mount: `from` directive expect `build_dir` or `tmp_dir` type!"
57
66
  builder_type_conflict: 'Conflict between builder types!'
58
67
  docker_from_incorrect: "`docker.from` has incorrect value `%{name}`!"
59
- docker_from_without_tag: "`docker.from`: image `%{name}` without tag!"
60
68
  stage_artifact_not_associated: "Artifact not associated with any stage: expected `before` or `after` attribute!"
61
69
  stage_artifact_double_associate: "Cannot use `%{stage}` stage for artifact, already used in `%{conflict_stage}` stage!"
62
70
  stage_artifact_not_supported_associated_stage: "Bad artifact stage `%{stage}`!"
@@ -99,6 +107,7 @@ en:
99
107
  commit_not_found_in_local_git_repository: "Local git repo: commit `%{commit}` not found!\nIf commit has been rebased: run command `dapp dimg stages cleanup local --improper-git-commit`!"
100
108
  commit_not_found_in_remote_git_repository: "Remote git repo `%{url}`: commit `%{commit}` not found!\nIf commit has been rebased: run command `dapp dimg stages cleanup local --improper-git-commit`!"
101
109
  branch_not_exist_in_remote_git_repository: "Remote git repo `%{url}`: branch `%{branch}` not exist!"
110
+ rugged_protocol_not_supported: "Rugged has been compiled without support for `%{protocol}`.\nGit repositories will not be reachable via `%{protocol}` (`%{url}`).\nRugged.features should include `%{protocol}`."
102
111
  lock:
103
112
  timeout: "Could not obtain lock for `%{name}` within %{timeout} seconds"
104
113
  app:
@@ -113,3 +122,6 @@ en:
113
122
  kubernetes:
114
123
  kube_config_not_found: "Kube config `%{path}` not found!"
115
124
  kube_server_connection_refused: "Kube server `%{url}` connection refused: %{error}"
125
+ secret:
126
+ bad_data: "Data `%{data}` can't be decrypted: check encryption key and data."
127
+ key_length_too_short: "Encryption key isn't valid (required size %{required_size} bytes)!"
data/lib/dapp.rb CHANGED
@@ -22,6 +22,7 @@ require 'net_status'
22
22
  require 'yaml'
23
23
  require 'openssl'
24
24
  require 'etc'
25
+ require 'zlib'
25
26
 
26
27
  require 'dapp/version'
27
28
  require 'dapp/core_ext/hash'
@@ -30,6 +31,7 @@ require 'dapp/helper/cli'
30
31
  require 'dapp/helper/trivia'
31
32
  require 'dapp/helper/sha256'
32
33
  require 'dapp/helper/net_status'
34
+ require 'dapp/helper/tar'
33
35
  require 'dapp/prctl'
34
36
  require 'dapp/error/base'
35
37
  require 'dapp/error/dapp'
@@ -46,6 +48,7 @@ require 'dapp/dapp/ssh_agent'
46
48
  require 'dapp/dapp/git_artifact'
47
49
  require 'dapp/dapp/dappfile'
48
50
  require 'dapp/dapp/chef'
51
+ require 'dapp/dapp/dapp_config'
49
52
  require 'dapp/dapp/logging/base'
50
53
  require 'dapp/dapp/logging/process'
51
54
  require 'dapp/dapp/logging/paint'
@@ -89,16 +92,17 @@ require 'dapp/deployment/cli/command/base'
89
92
  require 'dapp/deployment/cli/command/deployment'
90
93
  require 'dapp/deployment/cli/command/deployment/apply'
91
94
  require 'dapp/deployment/cli/command/deployment/mrproper'
92
- require 'dapp/deployment/cli/command/deployment/minikube_setup'
93
95
  require 'dapp/deployment/cli/cli'
94
96
  require 'dapp/deployment/dapp/command/mrproper'
95
97
  require 'dapp/deployment/dapp/command/apply'
96
- require 'dapp/deployment/dapp/command/minikube_setup'
97
98
  require 'dapp/deployment/dapp/command/common'
98
99
  require 'dapp/deployment/dapp/dappfile'
99
100
  require 'dapp/deployment/dapp/dapp'
100
101
  require 'dapp/deployment/secret'
101
102
  require 'dapp/kube'
103
+ require 'dapp/kube/error/base'
104
+ require 'dapp/kube/error/command'
105
+ require 'dapp/kube/error/kubernetes'
102
106
  require 'dapp/kube/client'
103
107
  require 'dapp/kube/client/error'
104
108
  require 'dapp/kube/cli/command/base'
@@ -107,17 +111,17 @@ require 'dapp/kube/cli/command/kube/deploy'
107
111
  require 'dapp/kube/cli/command/kube/dismiss'
108
112
  require 'dapp/kube/cli/command/kube/secret_key_generate'
109
113
  require 'dapp/kube/cli/command/kube/secret_generate'
110
- require 'dapp/kube/cli/command/kube/secret_file_encrypt'
114
+ require 'dapp/kube/cli/command/kube/secret_extract'
115
+ require 'dapp/kube/cli/command/kube/minikube_setup'
111
116
  require 'dapp/kube/cli/cli'
112
117
  require 'dapp/kube/dapp/command/common'
113
118
  require 'dapp/kube/dapp/command/deploy'
114
119
  require 'dapp/kube/dapp/command/dismiss'
115
120
  require 'dapp/kube/dapp/command/secret_key_generate'
116
121
  require 'dapp/kube/dapp/command/secret_generate'
117
- require 'dapp/kube/dapp/command/secret_file_encrypt'
122
+ require 'dapp/kube/dapp/command/secret_extract'
123
+ require 'dapp/kube/dapp/command/minikube_setup'
118
124
  require 'dapp/kube/dapp/dapp'
119
- require 'dapp/kube/error/base'
120
- require 'dapp/kube/error/command'
121
125
  require 'dapp/kube/secret'
122
126
  require 'dapp/dimg'
123
127
  require 'dapp/dimg/builder'
@@ -133,6 +137,7 @@ require 'dapp/dimg/build/stage/mod/group'
133
137
  require 'dapp/dimg/build/stage/base'
134
138
  require 'dapp/dimg/build/stage/ga_base'
135
139
  require 'dapp/dimg/build/stage/ga_dependencies_base'
140
+ require 'dapp/dimg/build/stage/ga_related_dependencies_base'
136
141
  require 'dapp/dimg/build/stage/artifact_base'
137
142
  require 'dapp/dimg/build/stage/artifact_default'
138
143
  require 'dapp/dimg/build/stage/from'
data/lib/dapp/cli.rb CHANGED
@@ -8,7 +8,7 @@ module Dapp
8
8
  SUBCOMMANDS = ['dimg', 'deployment', 'kube'].freeze
9
9
 
10
10
  banner <<BANNER.freeze
11
- Usage: dapp sub-command [sub-command options]
11
+ Usage: dapp subcommand [subcommand options]
12
12
 
13
13
  Available subcommands: (for details, dapp SUB-COMMAND --help)
14
14
 
@@ -11,20 +11,20 @@ module Dapp
11
11
  long: '--build-dir PATH',
12
12
  description: 'Directory where build cache stored (DIR/.dapp_build by default)'
13
13
 
14
- option :log_quiet,
14
+ option :quiet,
15
15
  short: '-q',
16
16
  long: '--quiet',
17
17
  description: 'Suppress logging',
18
18
  default: false,
19
19
  boolean: true
20
20
 
21
- option :log_verbose,
21
+ option :verbose,
22
22
  long: '--verbose',
23
23
  description: 'Enable verbose output',
24
24
  default: false,
25
25
  boolean: true
26
26
 
27
- option :log_time,
27
+ option :time,
28
28
  long: '--time',
29
29
  description: 'Enable output with time',
30
30
  default: false,
@@ -35,7 +35,7 @@ module Dapp
35
35
  default: false,
36
36
  boolean: true
37
37
 
38
- option :log_color,
38
+ option :color,
39
39
  long: '--color MODE',
40
40
  description: 'Display output in color on the terminal',
41
41
  in: %w(auto on off),
@@ -92,8 +92,10 @@ module Dapp
92
92
  end
93
93
 
94
94
  def _clone_to(obj)
95
- obj.marshal_load(marshal_dump)
96
- _set_ref_variables_to(obj)
95
+ obj.tap do
96
+ obj.marshal_load(marshal_dump)
97
+ _set_ref_variables_to(obj)
98
+ end
97
99
  end
98
100
 
99
101
  def _set_ref_variables_to(obj)
@@ -12,6 +12,20 @@ module Dapp
12
12
  end
13
13
  end
14
14
  end
15
+
16
+ def symbolize_keys
17
+ transform_keys { |key| key.to_sym rescue key }
18
+ end
19
+
20
+ private
21
+
22
+ def transform_keys
23
+ result = {}
24
+ each_key do |key|
25
+ result[yield(key)] = self[key]
26
+ end
27
+ result
28
+ end
15
29
  end
16
30
  end
17
31
  end
data/lib/dapp/dapp.rb CHANGED
@@ -4,6 +4,7 @@ module Dapp
4
4
  include GitArtifact
5
5
  include Dappfile
6
6
  include Chef
7
+ include DappConfig
7
8
 
8
9
  include Logging::Base
9
10
  include Logging::Process
@@ -13,6 +14,7 @@ module Dapp
13
14
  include SshAgent
14
15
  include Helper::Sha256
15
16
  include Helper::Trivia
17
+ include Helper::Tar
16
18
 
17
19
  include Deps::Gitartifact
18
20
  include Deps::Base
@@ -23,8 +25,9 @@ module Dapp
23
25
 
24
26
  def initialize(options: {})
25
27
  @options = options
26
- Logging::Paint.initialize(options[:log_color])
27
28
  Logging::I18n.initialize
29
+ validate_config_options!
30
+ Logging::Paint.initialize(option_color)
28
31
  end
29
32
 
30
33
  def name
@@ -34,9 +37,9 @@ module Dapp
34
37
  repo_name = repo_name[/.*(?=\.git)/] if repo_name.end_with? '.git'
35
38
  repo_name
36
39
  elsif git_path
37
- File.basename(File.dirname(git_path))
40
+ File.basename(File.dirname(git_path)).to_s
38
41
  else
39
- path.basename
42
+ path.basename.to_s
40
43
  end
41
44
  end
42
45
  end
@@ -63,14 +66,19 @@ module Dapp
63
66
  make_path(@path, *path)
64
67
  end
65
68
 
66
- def build_path
69
+ def tmp_base_dir
70
+ File.expand_path(options[:tmp_dir_prefix] || '/tmp')
71
+ end
72
+
73
+ def build_path(*path)
67
74
  @build_path ||= begin
68
- if options[:build_dir]
69
- Pathname.new(options[:build_dir])
75
+ if option_build_dir
76
+ Pathname.new(option_build_dir)
70
77
  else
71
78
  path('.dapp_build')
72
79
  end.expand_path.tap(&:mkpath)
73
80
  end
81
+ make_path(@build_path, *path)
74
82
  end
75
83
 
76
84
  def local_git_artifact_exclude_paths(&blk)
@@ -89,5 +97,23 @@ module Dapp
89
97
  def stage_dapp_label
90
98
  name
91
99
  end
100
+
101
+ def host_docker_bin
102
+ self.class.host_docker_bin
103
+ end
104
+
105
+ def self.host_docker_bin
106
+ @host_docker_bin ||= begin
107
+ raise Error::Dapp, code: :docker_not_found if (res = shellout('which docker')).exitstatus.nonzero?
108
+ res.stdout.strip.tap do |docker_bin|
109
+ current_docker_version = shellout!("#{docker_bin} --version").stdout.strip
110
+ required_docker_version = '1.10.0'
111
+
112
+ if Gem::Version.new(required_docker_version) >= Gem::Version.new(current_docker_version[/(\d+\.)+\d+/])
113
+ raise Error::Dapp, code: :docker_version, data: { version: required_docker_version }
114
+ end
115
+ end
116
+ end
117
+ end
92
118
  end # Dapp
93
119
  end # Dapp
@@ -0,0 +1,85 @@
1
+ module Dapp
2
+ class Dapp
3
+ module DappConfig
4
+ SUPPORTED_CONFIG_OPTIONS = {
5
+ verbose: [FalseClass, TrueClass],
6
+ quiet: [FalseClass, TrueClass],
7
+ dev: [FalseClass, TrueClass],
8
+ time: [FalseClass, TrueClass],
9
+ dry_run: [FalseClass, TrueClass],
10
+ build_dir: [String],
11
+ color: [String]
12
+ }
13
+
14
+ SUPPORTED_CONFIG_OPTIONS.keys.each do |opt|
15
+ define_method "option_#{opt}" do
16
+ options[opt] || config_options[opt]
17
+ end
18
+ end
19
+
20
+ def option_color
21
+ if options[:color] == 'auto'
22
+ config_options[:color] || 'auto'
23
+ else
24
+ options[:color]
25
+ end
26
+ end
27
+
28
+ def option_dev
29
+ if options[:dev].nil?
30
+ config._dev_mode || config_options[:dev]
31
+ else
32
+ options[:dev]
33
+ end
34
+ end
35
+
36
+ def config_options
37
+ @config_options ||= begin
38
+ config_search_paths = []
39
+ config_search_paths << File.join(Dir.home)
40
+ config_search_paths << path if dappfile_exists?
41
+
42
+ config_search_paths.reduce({}) do |options, dir|
43
+ if (config_options_path = make_path(dir, '.dapp_config')).file?
44
+ config_options = begin
45
+ YAML.load_file(config_options_path).tap do |c_options|
46
+ c_options.merge!(c_options.in_depth_merge(c_options['ci'] || {})) if ENV['GITLAB_CI'] || ENV['TRAVIS']
47
+ c_options.delete('ci')
48
+ end
49
+ rescue Psych::SyntaxError => e
50
+ raise Error::Dapp, code: :dapp_config_file_incorrect, data: { message: e.message }
51
+ end
52
+ options.in_depth_merge(config_options)
53
+ else
54
+ options
55
+ end
56
+ end.symbolize_keys
57
+ end
58
+ end
59
+
60
+ def validate_config_options!
61
+ data_list_format = proc { |list| list.map { |e| "'#{e}'" }.join(', ') }
62
+
63
+ unless (unsupported_keys = config_options.select { |k, _| !SUPPORTED_CONFIG_OPTIONS.keys.include?(k) }.keys).empty?
64
+ log_warning(desc: { code: :unsupported_dapp_config_options,
65
+ data: { options: data_list_format.call(unsupported_keys),
66
+ supported_options: data_list_format.call(SUPPORTED_CONFIG_OPTIONS.keys) } })
67
+ end
68
+
69
+ config_options.each do |k, v|
70
+ next unless SUPPORTED_CONFIG_OPTIONS.keys.include?(k)
71
+
72
+ if k == :color
73
+ raise Error::Dapp,
74
+ code: :incorrect_dapp_config_option_color,
75
+ data: { value: v, expected: data_list_format.call(%w(auto on off)) } unless %w(auto on off).member?(v)
76
+ elsif !SUPPORTED_CONFIG_OPTIONS[k].member? v.class
77
+ raise Error::Dapp,
78
+ code: :incorrect_dapp_config_option,
79
+ data: { option: k, value: v, expected: data_list_format.call(SUPPORTED_CONFIG_OPTIONS[k]) }
80
+ end
81
+ end
82
+ end
83
+ end # DappConfig
84
+ end # Dapp
85
+ end # Dapp
@@ -9,6 +9,10 @@ module Dapp
9
9
  end
10
10
  end
11
11
 
12
+ def dappfile_exists?
13
+ !!search_file_upward('Dappfile')
14
+ end
15
+
12
16
  def dappfile_path
13
17
  raise Error::Dapp, code: :dappfile_not_found unless (dappfile_path = search_file_upward('Dappfile'))
14
18
  dappfile_path