dapp 0.21.16 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/bin/dapp +0 -4
  3. data/config/en/net_status.yml +3 -2
  4. data/lib/dapp.rb +1 -4
  5. data/lib/dapp/cli.rb +0 -4
  6. data/lib/dapp/cli/command/base.rb +1 -7
  7. data/lib/dapp/cli/command/update.rb +1 -1
  8. data/lib/dapp/dapp.rb +19 -40
  9. data/lib/dapp/dapp/command/common.rb +19 -0
  10. data/lib/dapp/dapp/option_tags.rb +4 -6
  11. data/lib/dapp/dimg/build/stage/artifact_default.rb +1 -1
  12. data/lib/dapp/dimg/builder/chef/cookbook.rb +1 -1
  13. data/lib/dapp/dimg/cli/command/base.rb +4 -0
  14. data/lib/dapp/dimg/config/directive/artifact_dimg.rb +7 -0
  15. data/lib/dapp/dimg/config/directive/dimg/instance_methods.rb +0 -1
  16. data/lib/dapp/dimg/config/directive/dimg/validation.rb +16 -39
  17. data/lib/dapp/dimg/config/directive/git_artifact_remote.rb +7 -6
  18. data/lib/dapp/dimg/dapp/command/cleanup_repo.rb +98 -24
  19. data/lib/dapp/dimg/dapp/command/common.rb +4 -13
  20. data/lib/dapp/dimg/dapp/command/stages/cleanup_local.rb +9 -7
  21. data/lib/dapp/dimg/dapp/command/stages/cleanup_repo.rb +1 -1
  22. data/lib/dapp/dimg/dapp/command/stages/common.rb +1 -6
  23. data/lib/dapp/dimg/dapp/command/stages/flush_local.rb +5 -3
  24. data/lib/dapp/dimg/dapp/command/stages/flush_repo.rb +1 -1
  25. data/lib/dapp/dimg/docker_registry/dimg.rb +0 -9
  26. data/lib/dapp/dimg/git_repo/base.rb +30 -4
  27. data/lib/dapp/dimg/image/argument.rb +1 -3
  28. data/lib/dapp/helper/trivia.rb +0 -35
  29. data/lib/dapp/kube/cli/command/kube/deploy.rb +6 -0
  30. data/lib/dapp/kube/dapp/command/common.rb +129 -13
  31. data/lib/dapp/kube/dapp/command/deploy.rb +2 -9
  32. data/lib/dapp/kube/dapp/command/render.rb +2 -2
  33. data/lib/dapp/kube/error/base.rb +5 -1
  34. data/lib/dapp/kube/helm/release.rb +39 -3
  35. data/lib/dapp/kube/kubernetes/client.rb +2 -0
  36. data/lib/dapp/version.rb +2 -2
  37. metadata +4 -33
  38. data/lib/dapp/dapp/sentry.rb +0 -112
  39. data/lib/dapp/helper/url.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 50ec328ea740514c549d2366d96d8889f3e29940
4
- data.tar.gz: 3f1af717f6dbb3813cf8d0be4bdcc2940027859c
2
+ SHA256:
3
+ metadata.gz: 77598b3aaf53c25bda513349cdd1d04f7bbb3b0381553c674753926cd9422ecc
4
+ data.tar.gz: c921eb3a8041c2c4bdb86b28ba6179b6cdefb17095558d44ebc87f79518a726c
5
5
  SHA512:
6
- metadata.gz: 9eaa078ee0428cf2463326539e06038ac9defcac0e688e700167257b6c9d3e1db1b75a08ca6f7bdffbc4dd5fd92e77b9e66838347cc92940ae625fe21a91b958
7
- data.tar.gz: 2a9fd62aeafd9d26218dd5013f45d9fc6f46d100cf3dd53e22140be42275761468061e5cc5c5ae19139761a95a63fc77dd446c5db47e4c1083f4c3127117092e
6
+ metadata.gz: 27a73294f4dc0bc778bad4f766f30ae6bd717258b920bf55a0c85a52274c8b7042f02c3c5b55fff308e870026b698cac55e69fe428802db9971972b475299a55
7
+ data.tar.gz: 27e40f37ffd4d68f06f573840b2c5d72bd5405dca1f8a0de691fd71abcc080db432cb5259c69884eaecca6abb26b43a351b545eff10060bc4c5556907a377728
data/bin/dapp CHANGED
@@ -26,10 +26,6 @@ begin
26
26
  $stderr.puts "\033[1m\033[90mStacktrace dumped to #{filename}\033[0m"
27
27
  end
28
28
 
29
- if Dapp::CLI.dapp_object
30
- Dapp::CLI.dapp_object.sentry_exception(e)
31
- end
32
-
33
29
  raise
34
30
  end
35
31
  rescue Dapp::Error::Shellout => e
@@ -8,6 +8,7 @@ en:
8
8
  dimg_not_run: "Dimg run failed!"
9
9
  kube:
10
10
  deploy_timeout: "Deploy timeout!"
11
+ connect_timeout: "Connect timeout when connecting to kube API."
11
12
  dappfile:
12
13
  incorrect: "Dappfile with `%{error}`:\n%{message}"
13
14
  build:
@@ -51,7 +52,7 @@ en:
51
52
  cannot_run_ssh_agent: "Can't run ssh-agent!"
52
53
  ssh_key_not_found: "Ssh key `%{path}` doesn't exist!"
53
54
  docker_not_found: "Docker not found!"
54
- docker_version: "Required docker version (`%{version}`): VERSION must be newer than `%{min_version}`!"
55
+ docker_version: "Required docker version (`%{version}`): `%{min_version}` <= VERSION <= `%{max_version}`!"
55
56
  dapp_config_file_incorrect: "%{message}"
56
57
  yaml_file_incorrect: "Yaml file `%{file}`: `%{message}`"
57
58
  yaml_incorrect: "`%{message}`"
@@ -80,7 +81,7 @@ en:
80
81
  stage_artifact_double_associate: "Can't use `%{stage}` stage for artifact; already used in `%{conflict_stage}` stage!"
81
82
  stage_artifact_not_supported_associated_stage: "Bad artifact stage `%{stage}`!"
82
83
  git_artifact_remote_branch_with_commit: "Remote git repo: use `commit` or `branch` directive!"
83
- artifact_conflict: "Conflict between artifacts!\n\n%{dappfile_context}"
84
+ artifact_conflict: "Conflict between artifacts paths!"
84
85
  scratch_unsupported_directive: "Scratch dimg has unsupported directive `%{directive}`!"
85
86
  scratch_artifact_required: "Scratch dimg without artifacts!"
86
87
  scratch_artifact_associated: "Scratch artifact can't be associated: not expected `before`/`after` attribute!"
data/lib/dapp.rb CHANGED
@@ -24,8 +24,6 @@ require 'openssl'
24
24
  require 'etc'
25
25
  require 'zlib'
26
26
  require 'slugify'
27
- require 'sentry-raven'
28
- require 'toml-rb'
29
27
 
30
28
  require 'dapp/version'
31
29
  require 'dapp/core_ext/hash'
@@ -36,7 +34,6 @@ require 'dapp/helper/sha256'
36
34
  require 'dapp/helper/net_status'
37
35
  require 'dapp/helper/tar'
38
36
  require 'dapp/helper/yaml'
39
- require 'dapp/helper/url'
40
37
  require 'dapp/prctl'
41
38
  require 'dapp/error/base'
42
39
  require 'dapp/error/dapp'
@@ -52,7 +49,6 @@ require 'dapp/config/config'
52
49
  require 'dapp/config/error/config'
53
50
  require 'dapp/dapp/lock'
54
51
  require 'dapp/dapp/ssh_agent'
55
- require 'dapp/dapp/sentry'
56
52
  require 'dapp/dapp/git_artifact'
57
53
  require 'dapp/dapp/dappfile'
58
54
  require 'dapp/dapp/chef'
@@ -67,6 +63,7 @@ require 'dapp/dapp/deps/base'
67
63
  require 'dapp/dapp/deps/gitartifact'
68
64
  require 'dapp/dapp/shellout/streaming'
69
65
  require 'dapp/dapp/shellout/base'
66
+ require 'dapp/dapp/command/common'
70
67
  require 'dapp/dapp'
71
68
  require 'dapp/deployment'
72
69
  require 'dapp/deployment/config/directive/mod/group'
data/lib/dapp/cli.rb CHANGED
@@ -37,10 +37,6 @@ BANNER
37
37
  show_options: true,
38
38
  exit: 0
39
39
 
40
- class << self
41
- attr_accessor :dapp_object
42
- end
43
-
44
40
  def initialize(*args)
45
41
  super(*args)
46
42
 
@@ -62,8 +62,6 @@ module Dapp
62
62
 
63
63
  def run_dapp_command(run_method, options: {}, log_running_time: true)
64
64
  dapp = ::Dapp::Dapp.new(options: options)
65
- ::Dapp::CLI.dapp_object = dapp
66
- dapp.sentry_message("Manual usage: `#{options[:dapp_command]}` command") unless ENV['CI']
67
65
 
68
66
  log_dapp_running_time(dapp, ignore: !log_running_time) do
69
67
  if block_given?
@@ -74,10 +72,6 @@ module Dapp
74
72
  end
75
73
  end
76
74
 
77
- def run_method
78
- class_to_lowercase
79
- end
80
-
81
75
  def log_dapp_running_time(dapp, ignore: false)
82
76
  return yield if ignore
83
77
 
@@ -94,7 +88,7 @@ module Dapp
94
88
  end
95
89
 
96
90
  def cli_options(**kwargs)
97
- config.merge(dapp_command: run_method, **kwargs)
91
+ config.merge(**kwargs)
98
92
  end
99
93
  end
100
94
  end
@@ -4,7 +4,7 @@ module Dapp
4
4
  class Update < ::Dapp::CLI
5
5
  def run(_argv)
6
6
  spec = Gem::Specification.find do |s|
7
- File.fnmatch?(File.join(s.full_gem_path, '**', '*'), __FILE__, File::FNM_PATHNAME)
7
+ File.fnmatch(File.join(s.full_gem_path, '*'), __FILE__)
8
8
  end
9
9
  unless (latest_version = latest_beta_version(spec)).nil?
10
10
  try_lock do
data/lib/dapp/dapp.rb CHANGED
@@ -7,19 +7,18 @@ module Dapp
7
7
  include DappConfig
8
8
  include OptionTags
9
9
 
10
+ include Command::Common
11
+
10
12
  include Logging::Base
11
13
  include Logging::Process
12
14
  include Logging::I18n
13
15
  include Logging::Paint
14
16
 
15
17
  include SshAgent
16
- include Sentry
17
-
18
18
  include Helper::Sha256
19
- extend Helper::Trivia
19
+ extend Helper::Trivia
20
20
  include Helper::Trivia
21
21
  include Helper::Tar
22
- include Helper::Url
23
22
 
24
23
  include Deps::Toolchain
25
24
  include Deps::Gitartifact
@@ -40,18 +39,6 @@ module Dapp
40
39
  self.class.options
41
40
  end
42
41
 
43
- def settings
44
- @settings ||= begin
45
- settings_path = File.join(self.class.home_dir, "settings.toml")
46
-
47
- if File.exists? settings_path
48
- TomlRB.load_file(settings_path)
49
- else
50
- {}
51
- end
52
- end
53
- end
54
-
55
42
  def name
56
43
  @name ||= begin
57
44
  if name = options[:name]
@@ -94,18 +81,15 @@ module Dapp
94
81
  self.class.tmp_base_dir
95
82
  end
96
83
 
97
- def build_dir
98
- @build_dir ||= begin
84
+ def build_path(*path)
85
+ @build_path ||= begin
99
86
  if option_build_dir
100
87
  Pathname.new(option_build_dir)
101
88
  else
102
89
  path('.dapp_build')
103
90
  end.expand_path.tap(&:mkpath)
104
91
  end
105
- end
106
-
107
- def build_path(*path)
108
- make_path(build_dir, *path)
92
+ make_path(@build_path, *path)
109
93
  end
110
94
 
111
95
  def local_git_artifact_exclude_paths(&blk)
@@ -151,38 +135,33 @@ module Dapp
151
135
  end
152
136
 
153
137
  class << self
154
- def home_dir
155
- File.join(Dir.home, ".dapp")
156
- end
157
-
158
138
  def options
159
139
  @options ||= {}
160
140
  end
161
141
 
162
142
  def host_docker
163
143
  @host_docker ||= begin
164
- min_docker_minor_version = Gem::Version.new('1.10')
165
- unless host_docker_minor_version > min_docker_minor_version
166
- raise Error::Dapp, code: :docker_version, data: { min_version: min_docker_minor_version.to_s,
167
- version: host_docker_minor_version.to_s }
144
+ raise Error::Dapp, code: :docker_not_found if (res = shellout('which docker')).exitstatus.nonzero?
145
+ docker_bin = res.stdout.strip
146
+
147
+ current_docker_version = shellout!("#{docker_bin} --version").stdout.strip
148
+ required_min_docker_version = '1.10.0'
149
+ required_max_docker_version = '17.09.0'
150
+
151
+ if Gem::Version.new(required_min_docker_version) > Gem::Version.new(current_docker_version[/(\d+\.)+\d+/]) ||
152
+ Gem::Version.new(required_max_docker_version) < Gem::Version.new(current_docker_version[/(\d+\.)+\d+/])
153
+ raise Error::Dapp, code: :docker_version, data: { min_version: required_min_docker_version,
154
+ max_version: required_max_docker_version,
155
+ version: current_docker_version[/(\d+\.)+\d+/] }
168
156
  end
169
157
 
170
158
  [].tap do |cmd|
171
- cmd << host_docker_bin
159
+ cmd << docker_bin
172
160
  cmd << "--config #{host_docker_config_dir}"
173
161
  end.join(' ')
174
162
  end
175
163
  end
176
164
 
177
- def host_docker_bin
178
- raise Error::Dapp, code: :docker_not_found if (res = shellout('which docker')).exitstatus.nonzero?
179
- res.stdout.strip
180
- end
181
-
182
- def host_docker_minor_version
183
- Gem::Version.new(shellout!("#{host_docker_bin} --version").stdout.strip[/\d+\.\d+/])
184
- end
185
-
186
165
  def host_docker_config_dir
187
166
  if options_with_docker_credentials? && !options[:repo].nil?
188
167
  host_docker_tmp_config_dir
@@ -0,0 +1,19 @@
1
+ module Dapp
2
+ class Dapp
3
+ module Command
4
+ module Common
5
+ def option_repo
6
+ unless options[:repo].nil?
7
+ return "localhost:5000/#{name}" if options[:repo] == ':minikube'
8
+ options[:repo]
9
+ end
10
+ end
11
+
12
+ def dimg_registry(repo)
13
+ validate_repo_name!(repo)
14
+ ::Dapp::Dimg::DockerRegistry.new(repo)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -5,14 +5,12 @@ module Dapp
5
5
  @git_repo ||= ::Dapp::Dimg::GitRepo::Own.new(self)
6
6
  end
7
7
 
8
+ def tagging_schemes
9
+ %w(git_tag git_branch git_commit custom ci)
10
+ end
11
+
8
12
  def tags_by_scheme
9
13
  @tags_by_scheme_name ||= begin
10
- if simple_tags[:custom].any?
11
- if settings.fetch("sentry", {}).fetch("detect-push-tag-usage", false)
12
- sentry_message("--tag or --tag-slug usage detected", extra: {"slug_tags" => simple_tags})
13
- end
14
- end
15
-
16
14
  [simple_tags, branch_tags, commit_tags, build_tags, ci_tags].reduce({}) do |some_tags_by_scheme, tags_by_scheme|
17
15
  tags_by_scheme.in_depth_merge(some_tags_by_scheme)
18
16
  end.tap do |tags_by_scheme|
@@ -32,7 +32,7 @@ module Dapp
32
32
  def safe_cp(from, to, owner, group, include_paths = [], exclude_paths = [])
33
33
  ''.tap do |cmd|
34
34
  cmd << dimg.dapp.rsync_bin
35
- cmd << ' --archive --links --inplace'
35
+ cmd << ' --archive --links'
36
36
  cmd << " --chown=#{owner}:#{group}" if owner or group
37
37
 
38
38
  if include_paths.any?
@@ -87,7 +87,7 @@ module Dapp
87
87
  "#{builder.dimg.dapp.mkdir_bin} -p ~/.ssh",
88
88
  'echo "Host *" >> ~/.ssh/config',
89
89
  'echo " StrictHostKeyChecking no" >> ~/.ssh/config',
90
- *local_paths.map {|path| "#{builder.dimg.dapp.rsync_bin} --inplace --archive --relative #{path} /tmp/local_cookbooks"},
90
+ *local_paths.map {|path| "#{builder.dimg.dapp.rsync_bin} --archive --relative #{path} /tmp/local_cookbooks"},
91
91
  "cd /tmp/local_cookbooks/#{path}",
92
92
  "cp #{tmp_berksfile_path} Berksfile",
93
93
  "cp #{tmp_metadata_path} metadata.rb",
@@ -20,6 +20,10 @@ module Dapp::Dimg::CLI
20
20
  end
21
21
  end
22
22
  end
23
+
24
+ def run_method
25
+ class_to_lowercase
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -5,6 +5,13 @@ module Dapp
5
5
  class ArtifactDimg < Dimg
6
6
  def validate_scratch!
7
7
  end
8
+
9
+ def validate_artifacts_artifacts!
10
+ end
11
+
12
+ def validated_artifacts
13
+ _git_artifact._local + _git_artifact._remote
14
+ end
8
15
  end
9
16
  end
10
17
  end
@@ -132,7 +132,6 @@ module Dapp
132
132
 
133
133
  def artifacts_after_parsing!
134
134
  _artifacts_auto_excluding!
135
- _artifact.map(&:_config).each(&:artifacts_after_parsing!)
136
135
  end
137
136
 
138
137
  protected
@@ -4,8 +4,6 @@ module Dapp
4
4
  module Directive
5
5
  class Dimg < Base
6
6
  module Validation
7
- include Helper::Trivia
8
-
9
7
  def validate!
10
8
  directives_validate!
11
9
  validate_scratch!
@@ -75,39 +73,12 @@ module Dapp
75
73
  verifiable_artifact = artifacts.shift
76
74
  artifacts.select { |a| a[:to] == verifiable_artifact[:to] }.each do |artifact|
77
75
  next if verifiable_artifact[:index] == artifact[:index]
78
- begin
79
- validate_artifact!(verifiable_artifact, artifact)
80
- validate_artifact!(artifact, verifiable_artifact)
81
- rescue Error::Config => e
82
- conflict_between_artifacts!(artifact, verifiable_artifact) if e.net_status[:code] == :artifact_conflict
83
- raise
84
- end
76
+ validate_artifact!(verifiable_artifact, artifact)
77
+ validate_artifact!(artifact, verifiable_artifact)
85
78
  end
86
79
  end
87
80
  end
88
81
 
89
- def conflict_between_artifacts!(*formatted_artifacts)
90
- artifacts = formatted_artifacts.flatten.map { |formatted_artifact| formatted_artifact[:related_artifact] }
91
- dappfile_context = artifacts.map do |artifact|
92
- artifact_directive = []
93
- artifact_directive << begin
94
- if artifact.is_a? Artifact::Export
95
- "artifact.export('#{artifact._cwd}') do"
96
- else
97
- "git#{"('#{artifact._url}')" if artifact.respond_to?(:_url)}.add('#{artifact._cwd}') do"
98
- end
99
- end
100
- [:include_paths, :exclude_paths].each do |directive|
101
- next if (paths = artifact.send("_#{directive}")).empty?
102
- artifact_directive << " #{directive} '#{paths.join("', '")}'"
103
- end
104
- artifact_directive << " to '#{artifact._to}'"
105
- artifact_directive << 'end'
106
- artifact_directive.join("\n")
107
- end.join("\n\n")
108
- raise Error::Config, code: :artifact_conflict, data: { dappfile_context: dappfile_context }
109
- end
110
-
111
82
  def validate_artifact_format(artifacts)
112
83
  artifacts.map do |a|
113
84
  path_format = proc { |path| File.expand_path(File.join('/', path, '/'))[1..-1] }
@@ -135,20 +106,26 @@ module Dapp
135
106
  index: artifacts.index(a),
136
107
  to: to,
137
108
  include_paths: include_paths,
138
- exclude_paths: exclude_paths,
139
- related_artifact: a
109
+ exclude_paths: exclude_paths
140
110
  }
141
111
  end
142
112
  end
143
113
 
144
114
  def validate_artifact!(verifiable_artifact, artifact)
145
- cases = []
146
- cases << verifiable_artifact[:include_paths].any? do |verifiable_path|
147
- !ignore_path?(verifiable_path, paths: artifact[:include_paths], exclude_paths: artifact[:exclude_paths])
148
- end
149
- cases << (verifiable_artifact[:include_paths].empty? && artifact[:include_paths].empty?)
115
+ verifiable_artifact[:include_paths].each do |verifiable_path|
116
+ potential_conflicts = artifact[:include_paths].select { |path| path.start_with?(verifiable_path) }
117
+ validate_artifact_path!(verifiable_artifact, potential_conflicts)
118
+ end.empty? && verifiable_artifact[:exclude_paths].empty? && raise(Error::Config, code: :artifact_conflict)
119
+ validate_artifact_path!(verifiable_artifact, artifact[:include_paths]) if verifiable_artifact[:include_paths].empty?
120
+ end
150
121
 
151
- raise Error::Config, code: :artifact_conflict if cases.any?
122
+ def validate_artifact_path!(verifiable_artifact, potential_conflicts)
123
+ potential_conflicts.all? do |path|
124
+ loop do
125
+ break if verifiable_artifact[:exclude_paths].include?(path) || ((path = File.dirname(path)) == '.')
126
+ end
127
+ verifiable_artifact[:exclude_paths].include?(path)
128
+ end.tap { |res| res || raise(Error::Config, code: :artifact_conflict) }
152
129
  end
153
130
 
154
131
  def _associated_artifacts
@@ -3,13 +3,14 @@ module Dapp
3
3
  module Config
4
4
  module Directive
5
5
  class GitArtifactRemote < GitArtifactLocal
6
- include ::Dapp::Helper::Url
7
-
8
6
  attr_reader :_url, :_name, :_branch, :_commit
9
7
 
10
8
  def initialize(url, **kwargs, &blk)
11
9
  @_url = url
12
- @_name = git_url_to_name(url)
10
+
11
+ url_without_scheme = url.split("://", 2).last
12
+ url_without_creds = url_without_scheme.split(":", 2).last
13
+ @_name = url_without_creds.gsub(%r{.*?([^\/ ]+\/[^\/ ]+)\.git}, '\\1')
13
14
 
14
15
  super(**kwargs, &blk)
15
16
  end
@@ -19,7 +20,7 @@ module Dapp
19
20
  end
20
21
 
21
22
  def commit(value)
22
- sub_directive_eval { @_commit = value.to_s }
23
+ sub_directive_eval { @_commit = value }
23
24
  end
24
25
 
25
26
  def _export
@@ -39,11 +40,11 @@ module Dapp
39
40
  end
40
41
 
41
42
  def branch(value)
42
- sub_directive_eval { @_branch = value.to_s }
43
+ sub_directive_eval { @_branch = value }
43
44
  end
44
45
 
45
46
  def commit(value)
46
- sub_directive_eval { @_commit = value.to_s }
47
+ sub_directive_eval { @_commit = value }
47
48
  end
48
49
 
49
50
  def validate!