dply 0.3.1 → 0.3.2
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.
- checksums.yaml +4 -4
- data/lib/dply/app_config.rb +3 -7
- data/lib/dply/build.rb +3 -11
- data/lib/dply/build_config.rb +11 -2
- data/lib/dply/deploy_config.rb +11 -2
- data/lib/dply/meta_config.rb +78 -0
- data/lib/dply/strategy/archive.rb +9 -14
- data/lib/dply/strategy/git.rb +9 -14
- data/lib/dply/task_dsl.rb +2 -2
- data/lib/dply/util.rb +2 -1
- data/lib/dply/version.rb +1 -1
- data/spec/integration/archive_flow_spec.rb +10 -0
- data/spec/integration/git_flow_spec.rb +8 -1
- data/spec/test_data/config_repo/app.yml +7 -0
- data/spec/test_data/config_repo/custom.yml +2 -0
- data/spec/test_data/config_repo/host.yml +2 -0
- data/spec/test_data/sample_repo/dply/app.rb +1 -1
- data/spec/webserver.rb +1 -1
- metadata +9 -3
- data/lib/dply/config_downloader.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a742b7e51a3fa6f6c3dde85c7e865ce808f06f4daadfdac8b9e484c0fa537dd
|
4
|
+
data.tar.gz: a10e414804b13354bd1e47a78edb498aa219e43bddfdc488f4a1efdbe12e47c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 630810896801f78190c74fa7988e13308c71d388870ffcb500a9adf9d197fd1f4fe377fa5aa6339ff76274b23a3121b039c877a1664eb7167c5be00b0d1196a6
|
7
|
+
data.tar.gz: 96a09128c85ba165e1f77077c402a1680a9d189116878bf7d5137500c4236d63602f633f973bf1357932bd0b3fc6ab396bd3d6d8040c9b4b49f4646f0e502035
|
data/lib/dply/app_config.rb
CHANGED
@@ -37,13 +37,9 @@ module Dply
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def render_config
|
41
|
-
|
42
|
-
|
43
|
-
data = load_yml override_file, optional: true
|
44
|
-
config_data.deep_merge! data
|
45
|
-
end
|
46
|
-
|
40
|
+
def render_config
|
41
|
+
load_config
|
42
|
+
config_data = load_yml "meta.yml", optional: true
|
47
43
|
tmp_file = "tmp/config_render.tmp"
|
48
44
|
@config_map.each do |dest, src|
|
49
45
|
raise Error, %(error dest "#{dest}" is a directory) if File.directory? dest
|
data/lib/dply/build.rb
CHANGED
@@ -12,8 +12,7 @@ module Dply
|
|
12
12
|
extend Forwardable
|
13
13
|
include Helper
|
14
14
|
|
15
|
-
def_delegators :config, :branch, :
|
16
|
-
:config_map, :dir_map, :config_skip_download
|
15
|
+
def_delegators :config, :branch, :config_map, :dir_map, :meta_conf
|
17
16
|
|
18
17
|
attr_reader :config
|
19
18
|
|
@@ -23,7 +22,7 @@ module Dply
|
|
23
22
|
|
24
23
|
def run
|
25
24
|
setup
|
26
|
-
|
25
|
+
meta_conf.generate if meta_conf
|
27
26
|
Dir.chdir repo_dir do
|
28
27
|
git_step
|
29
28
|
git.clean
|
@@ -33,7 +32,7 @@ module Dply
|
|
33
32
|
link_build_dir
|
34
33
|
bundle.install
|
35
34
|
bundle.clean
|
36
|
-
util.run config.task
|
35
|
+
util.run config.task, render_config: false
|
37
36
|
generate_checksum
|
38
37
|
end
|
39
38
|
end
|
@@ -45,13 +44,6 @@ module Dply
|
|
45
44
|
setup.build
|
46
45
|
end
|
47
46
|
|
48
|
-
def download_configs
|
49
|
-
files = config_map.values.uniq
|
50
|
-
downloader = ConfigDownloader.new(files, config_download_url)
|
51
|
-
downloader.skip_download = config_skip_download
|
52
|
-
downloader.download_all
|
53
|
-
end
|
54
|
-
|
55
47
|
def git_step
|
56
48
|
return unless config.git
|
57
49
|
if config.no_pull
|
data/lib/dply/build_config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'dply/base_config'
|
2
|
+
require_relative 'meta_config'
|
2
3
|
|
3
4
|
module Dply
|
4
5
|
class BuildConfig < BaseConfig
|
@@ -14,8 +15,16 @@ module Dply
|
|
14
15
|
opt :config_map, type: Hash
|
15
16
|
opt :dir_map, type: Hash
|
16
17
|
opt :shared_dirs, type: Array
|
17
|
-
opt :
|
18
|
-
|
18
|
+
opt :meta_conf, type: MetaConfig
|
19
|
+
end
|
20
|
+
|
21
|
+
def meta_conf(&block)
|
22
|
+
conf = MetaConfig.new("config")
|
23
|
+
conf.instance_eval &block
|
24
|
+
config_map({
|
25
|
+
"meta.yml" => "meta_generated.yml"
|
26
|
+
})
|
27
|
+
set(:meta_conf, conf)
|
19
28
|
end
|
20
29
|
|
21
30
|
def default_config
|
data/lib/dply/deploy_config.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'dply/base_config'
|
2
|
+
require_relative 'meta_config'
|
2
3
|
|
3
4
|
module Dply
|
4
5
|
class DeployConfig < BaseConfig
|
@@ -13,11 +14,19 @@ module Dply
|
|
13
14
|
opt :shared_dirs, type: Array
|
14
15
|
opt :config_map, type: Hash
|
15
16
|
opt :dir_map, type: Hash
|
16
|
-
opt :config_download_url
|
17
|
-
opt :config_skip_download, type: Array
|
18
17
|
opt :verify_checksum
|
19
18
|
opt :revision
|
20
19
|
opt :dir
|
20
|
+
opt :meta_conf, type: MetaConfig
|
21
|
+
end
|
22
|
+
|
23
|
+
def meta_conf(&block)
|
24
|
+
conf = MetaConfig.new("config")
|
25
|
+
conf.instance_eval &block
|
26
|
+
config_map({
|
27
|
+
"meta.yml" => "meta_generated.yml"
|
28
|
+
})
|
29
|
+
set(:meta_conf, conf)
|
21
30
|
end
|
22
31
|
|
23
32
|
def default_config
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require_relative 'ext/hash'
|
3
|
+
module Dply
|
4
|
+
class MetaConfig
|
5
|
+
|
6
|
+
using HashExt
|
7
|
+
|
8
|
+
include Helper
|
9
|
+
|
10
|
+
def initialize(dir)
|
11
|
+
@sources = []
|
12
|
+
@dir = dir
|
13
|
+
@output_path = "#{dir}/meta_generated.yml"
|
14
|
+
@tmpfile = "#{dir}/meta.tmp"
|
15
|
+
end
|
16
|
+
|
17
|
+
def define(&block)
|
18
|
+
instance_eval &block
|
19
|
+
end
|
20
|
+
|
21
|
+
def generate
|
22
|
+
config = {}
|
23
|
+
@sources.each do |i|
|
24
|
+
path = i.fetch(:path)
|
25
|
+
url = i.fetch(:url)
|
26
|
+
auth = i.fetch(:auth)
|
27
|
+
optional = i.fetch(:optional)
|
28
|
+
deep_merge = i.fetch(:deep_merge)
|
29
|
+
block = i.fetch(:block)
|
30
|
+
|
31
|
+
if url
|
32
|
+
download(url, path, optional: optional)
|
33
|
+
end
|
34
|
+
|
35
|
+
if block
|
36
|
+
instance_exec path, optional, &block
|
37
|
+
end
|
38
|
+
|
39
|
+
h = load_yml(path, optional: optional)
|
40
|
+
deep_merge ? config.deep_merge!(h) : config.merge!(h)
|
41
|
+
end
|
42
|
+
File.write @tmpfile, YAML.dump(config)
|
43
|
+
FileUtils.mv @tmpfile, @output_path
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def config(path, url = nil, auth: nil, deep_merge: true, optional: false, &block)
|
49
|
+
path = "#{@dir}/#{path}"
|
50
|
+
@sources << { path: path, url: url, auth: auth, deep_merge: deep_merge,
|
51
|
+
optional: optional, block: block }
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_yml(path, optional:)
|
55
|
+
if not File.readable? path
|
56
|
+
return {} if optional
|
57
|
+
raise Error, "error reading file #{path}"
|
58
|
+
end
|
59
|
+
YAML.safe_load(File.read(path)) || {}
|
60
|
+
end
|
61
|
+
|
62
|
+
def download(url, path, optional:)
|
63
|
+
logger.bullet "downloading #{url}"
|
64
|
+
http_status = IO.popen(["curl", "-w", '%{http_code}', "-f", "-s", "-o", @tmpfile, url]) { |f| f.read }
|
65
|
+
exit_status = $?.exitstatus
|
66
|
+
if (http_status != "200" || exit_status != 0)
|
67
|
+
message = "failed to download #{path}, http status #{http_status}, exit_status #{exit_status}"
|
68
|
+
if optional
|
69
|
+
logger.warn message
|
70
|
+
return
|
71
|
+
end
|
72
|
+
error(message)
|
73
|
+
end
|
74
|
+
FileUtils.mv @tmpfile, path
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'dply/helper'
|
2
2
|
require 'dply/util'
|
3
3
|
require 'dply/setup'
|
4
|
-
require 'dply/config_downloader'
|
5
4
|
require 'dply/yum'
|
6
5
|
require 'dply/release'
|
7
6
|
require 'dply/release_helper'
|
@@ -16,8 +15,7 @@ module Dply
|
|
16
15
|
|
17
16
|
attr_reader :config, :options
|
18
17
|
def_delegators :config, :target, :branch, :revision, :name,
|
19
|
-
:config_map, :dir_map, :
|
20
|
-
:config_download_url, :build_url
|
18
|
+
:config_map, :dir_map, :build_url, :meta_conf
|
21
19
|
|
22
20
|
def initialize(config, options)
|
23
21
|
@config = config
|
@@ -34,12 +32,12 @@ module Dply
|
|
34
32
|
util.report_changes(current_version, previous_version)
|
35
33
|
return
|
36
34
|
end
|
37
|
-
|
35
|
+
generate_meta_config
|
38
36
|
install_release
|
39
37
|
previous_version = get_release
|
40
38
|
release.make_current
|
41
39
|
Dir.chdir current_dir do
|
42
|
-
util.run "deploy:#{deploy_target}"
|
40
|
+
util.run "deploy:#{deploy_target}", render_config: true
|
43
41
|
end
|
44
42
|
release.record_deployment
|
45
43
|
current_version = get_release
|
@@ -48,15 +46,19 @@ module Dply
|
|
48
46
|
end
|
49
47
|
|
50
48
|
def reload
|
51
|
-
|
49
|
+
generate_meta_config
|
52
50
|
Dir.chdir current_dir do
|
53
51
|
link_all
|
54
|
-
util.run :reload
|
52
|
+
util.run :reload, render_config: true
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
58
56
|
private
|
59
57
|
|
58
|
+
def generate_meta_config
|
59
|
+
meta_conf.generate if meta_conf
|
60
|
+
end
|
61
|
+
|
60
62
|
def deploy_target
|
61
63
|
@deploy_target ||= (target || :archive)
|
62
64
|
end
|
@@ -70,13 +72,6 @@ module Dply
|
|
70
72
|
File.basename (File.readlink current_dir)
|
71
73
|
end
|
72
74
|
|
73
|
-
def download_configs
|
74
|
-
files = config_map.values.uniq
|
75
|
-
downloader = ConfigDownloader.new(files, config_download_url)
|
76
|
-
downloader.skip_download = config_skip_download if config_skip_download
|
77
|
-
downloader.download_all
|
78
|
-
end
|
79
|
-
|
80
75
|
def release
|
81
76
|
@release ||= Release.find_or_create(
|
82
77
|
revision: revision,
|
data/lib/dply/strategy/git.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'dply/helper'
|
2
2
|
require 'dply/setup'
|
3
|
-
require 'dply/config_downloader'
|
4
3
|
require 'dply/yum'
|
5
4
|
require 'dply/util'
|
6
5
|
require 'forwardable'
|
@@ -14,8 +13,7 @@ module Dply
|
|
14
13
|
|
15
14
|
attr_reader :config, :options
|
16
15
|
def_delegators :config, :target, :branch,
|
17
|
-
:config_map, :dir_map, :
|
18
|
-
:config_download_url
|
16
|
+
:config_map, :dir_map, :meta_conf
|
19
17
|
|
20
18
|
def initialize(config, options)
|
21
19
|
@config = config
|
@@ -25,7 +23,7 @@ module Dply
|
|
25
23
|
def deploy
|
26
24
|
deploy_target = (target || :git)
|
27
25
|
setup.git
|
28
|
-
|
26
|
+
generate_meta_config
|
29
27
|
Dir.chdir current_dir do
|
30
28
|
previous_version = git.commit_id
|
31
29
|
git_step
|
@@ -34,30 +32,27 @@ module Dply
|
|
34
32
|
install_pkgs
|
35
33
|
bundle.install
|
36
34
|
bundle.clean
|
37
|
-
util.run "deploy:#{deploy_target}"
|
35
|
+
util.run "deploy:#{deploy_target}", render_config: true
|
38
36
|
util.report_changes(previous_version, current_version)
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
40
|
def reload
|
43
|
-
|
41
|
+
generate_meta_config
|
44
42
|
Dir.chdir current_dir do
|
45
43
|
link_all
|
46
|
-
util.run :reload
|
44
|
+
util.run :reload, render_config: true
|
47
45
|
end
|
48
46
|
end
|
49
47
|
|
50
48
|
private
|
51
49
|
|
52
|
-
def
|
53
|
-
|
50
|
+
def generate_meta_config
|
51
|
+
meta_conf.generate if meta_conf
|
54
52
|
end
|
55
53
|
|
56
|
-
def
|
57
|
-
|
58
|
-
downloader = ConfigDownloader.new(files, config_download_url)
|
59
|
-
downloader.skip_download = config_skip_download if config_skip_download
|
60
|
-
downloader.download_all
|
54
|
+
def current_dir
|
55
|
+
@current_dir ||= "#{config.dir}/current"
|
61
56
|
end
|
62
57
|
|
63
58
|
def git_step
|
data/lib/dply/task_dsl.rb
CHANGED
@@ -18,8 +18,8 @@ module Dply
|
|
18
18
|
super(command, env: extra_env, bundled_env: bundled_env, display: :arrow)
|
19
19
|
end
|
20
20
|
|
21
|
-
def render_config
|
22
|
-
@app_config.render_config
|
21
|
+
def render_config
|
22
|
+
@app_config.render_config
|
23
23
|
end
|
24
24
|
|
25
25
|
def set_env(key, value)
|
data/lib/dply/util.rb
CHANGED
@@ -38,9 +38,10 @@ module Dply
|
|
38
38
|
linker.create_symlinks
|
39
39
|
end
|
40
40
|
|
41
|
-
def run(task, optional: false)
|
41
|
+
def run(task, render_config: false, optional: false)
|
42
42
|
app_config = AppConfig.new
|
43
43
|
logger.arrow task
|
44
|
+
app_config.render_config if render_config
|
44
45
|
app_config.run_task task, optional: optional
|
45
46
|
end
|
46
47
|
|
data/lib/dply/version.rb
CHANGED
@@ -29,6 +29,11 @@ describe "archive flow" do
|
|
29
29
|
"tmp" => "tmp",
|
30
30
|
"log" => "log"
|
31
31
|
})
|
32
|
+
|
33
|
+
meta_conf do
|
34
|
+
url = lambda { |name| "http://127.0.0.1:8000/config_repo/" + name }
|
35
|
+
config "app.yml", url["app.yml"]
|
36
|
+
end
|
32
37
|
CONFIG
|
33
38
|
end
|
34
39
|
|
@@ -43,6 +48,11 @@ describe "archive flow" do
|
|
43
48
|
"\#{repo}/\#{name}-\#{revision}-\#{branch}.tar.gz"
|
44
49
|
end
|
45
50
|
|
51
|
+
meta_conf do
|
52
|
+
url = lambda { |name| "http://127.0.0.1:8000/config_repo/" + name }
|
53
|
+
config "app.yml", url["app.yml"]
|
54
|
+
end
|
55
|
+
|
46
56
|
dir_map ({
|
47
57
|
"log" => "log",
|
48
58
|
"tmp" => "tmp",
|
@@ -31,6 +31,13 @@ describe "git flow" do
|
|
31
31
|
"log" => "log",
|
32
32
|
"tmp" => "tmp"
|
33
33
|
})
|
34
|
+
|
35
|
+
meta_conf do
|
36
|
+
url = lambda { |name| "http://127.0.0.1:8000/config_repo/" + name }
|
37
|
+
config "app.yml", url["app.yml"]
|
38
|
+
config "custom.yml", url["custom.yml"]
|
39
|
+
config "host.yml", url["host.yml"], deep_merge: false
|
40
|
+
end
|
34
41
|
CONFIG
|
35
42
|
end
|
36
43
|
|
@@ -65,7 +72,7 @@ describe "git flow" do
|
|
65
72
|
Dir.chdir @deploy_dir do
|
66
73
|
expect(File).to exist("current/test.txt")
|
67
74
|
data = File.read "current/test.txt"
|
68
|
-
expect(data).to eq("
|
75
|
+
expect(data).to eq("custom-host\napp-port\n")
|
69
76
|
end
|
70
77
|
end
|
71
78
|
end
|
@@ -8,6 +8,7 @@ test do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
build do
|
11
|
+
render_config
|
11
12
|
rake :a
|
12
13
|
sh "ls"
|
13
14
|
FileUtils.mkdir_p "vendor"
|
@@ -19,7 +20,6 @@ build do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
deploy :git do
|
22
|
-
render_config override_file: "application-override.yml"
|
23
23
|
set_env "MIX_ENV", "prod"
|
24
24
|
sh "ls"
|
25
25
|
puts " git deployed"
|
data/spec/webserver.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dply
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neeraj
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-elf
|
@@ -96,7 +96,6 @@ files:
|
|
96
96
|
- lib/dply/cli/task.rb
|
97
97
|
- lib/dply/code_archive.rb
|
98
98
|
- lib/dply/command.rb
|
99
|
-
- lib/dply/config_downloader.rb
|
100
99
|
- lib/dply/curl.rb
|
101
100
|
- lib/dply/custom_logger.rb
|
102
101
|
- lib/dply/deplist.rb
|
@@ -112,6 +111,7 @@ files:
|
|
112
111
|
- lib/dply/linker.rb
|
113
112
|
- lib/dply/lock.rb
|
114
113
|
- lib/dply/logger.rb
|
114
|
+
- lib/dply/meta_config.rb
|
115
115
|
- lib/dply/pkgs.rb
|
116
116
|
- lib/dply/release.rb
|
117
117
|
- lib/dply/release_helper.rb
|
@@ -167,6 +167,9 @@ files:
|
|
167
167
|
- spec/test_data/bundle/gems_not_installed/Gemfile
|
168
168
|
- spec/test_data/bundle/no_gemfile/.gitkeep
|
169
169
|
- spec/test_data/command/test.rb
|
170
|
+
- spec/test_data/config_repo/app.yml
|
171
|
+
- spec/test_data/config_repo/custom.yml
|
172
|
+
- spec/test_data/config_repo/host.yml
|
170
173
|
- spec/test_data/elf/elf
|
171
174
|
- spec/test_data/elf/libecpg.so
|
172
175
|
- spec/test_data/elf/libpgtypes.so.3
|
@@ -239,6 +242,9 @@ test_files:
|
|
239
242
|
- spec/test_data/bundle/gems_not_installed/Gemfile
|
240
243
|
- spec/test_data/bundle/no_gemfile/.gitkeep
|
241
244
|
- spec/test_data/command/test.rb
|
245
|
+
- spec/test_data/config_repo/app.yml
|
246
|
+
- spec/test_data/config_repo/custom.yml
|
247
|
+
- spec/test_data/config_repo/host.yml
|
242
248
|
- spec/test_data/elf/elf
|
243
249
|
- spec/test_data/elf/libecpg.so
|
244
250
|
- spec/test_data/elf/libpgtypes.so.3
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'dply/helper'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'dply/curl'
|
4
|
-
|
5
|
-
module Dply
|
6
|
-
class ConfigDownloader
|
7
|
-
|
8
|
-
include Helper
|
9
|
-
attr_writer :skip_download
|
10
|
-
|
11
|
-
def initialize(config_files , base_url, dir: "config")
|
12
|
-
@config_files = config_files
|
13
|
-
@base_url = base_url
|
14
|
-
@dir = dir
|
15
|
-
@skip_download = []
|
16
|
-
end
|
17
|
-
|
18
|
-
def download_all
|
19
|
-
@config_files.each do |f|
|
20
|
-
if @skip_download.include? f
|
21
|
-
logger.debug "skipping to download file #{f}"
|
22
|
-
next
|
23
|
-
end
|
24
|
-
curl.download "#{@base_url}/#{f}", "#{@dir}/#{f}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def curl
|
31
|
-
@curl ||= Curl.new
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|