docman 0.0.83 → 0.0.84
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/config/config.yaml +21 -0
- data/lib/application.rb +11 -5
- data/lib/docman/commands/yaml_execute_cmd.rb +14 -2
- data/lib/docman/config.rb +51 -16
- data/lib/docman/docroot_config.rb +3 -1
- data/lib/docman/git_util.rb +3 -1
- data/lib/docman/info.rb +2 -2
- data/lib/docman/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 80578901d1ae0de8b772d64bc2fc60377efd4c79
|
|
4
|
+
data.tar.gz: b3a0a76aaea7b08d1b65d176ee592a2e5d9890df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f31180892abc6e90eb00e16647fc2ea7b927aba9c68d3836aded44e9dffd8c1d5f62edff882d7510a1e6978089f0c70fa88fca9212fd881f3d1e9987452d3fc0
|
|
7
|
+
data.tar.gz: '0380ad7bc61bf16e81b4a1b4127d0790e9b1bab8c23d17dbf534fe59f53adaa5f91c6311e4741b5d6f0047b9370890b163733492205e51d6e2823e8f9da74b51'
|
data/config/config.yaml
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
---
|
|
2
|
+
uniconf:
|
|
3
|
+
1:
|
|
4
|
+
keys:
|
|
5
|
+
include: scenarios
|
|
6
|
+
sources: scenarioSources
|
|
7
|
+
params: params
|
|
8
|
+
jobs: jobs
|
|
9
|
+
dirs:
|
|
10
|
+
sources: scenarios
|
|
11
|
+
include:
|
|
12
|
+
prefix: .params.
|
|
13
|
+
2:
|
|
14
|
+
keys:
|
|
15
|
+
include: from
|
|
16
|
+
sources: sources
|
|
17
|
+
params: params
|
|
18
|
+
jobs: jobs
|
|
19
|
+
dirs:
|
|
20
|
+
sources: scenarios
|
|
21
|
+
include:
|
|
22
|
+
prefix: .params.
|
|
2
23
|
# common hooks used in deploy targets below
|
|
3
24
|
common_hooks:
|
|
4
25
|
- &execute_yaml_file
|
data/lib/application.rb
CHANGED
|
@@ -226,12 +226,18 @@ module Docman
|
|
|
226
226
|
|
|
227
227
|
def config_dirs(options)
|
|
228
228
|
config_dirs = []
|
|
229
|
-
if options
|
|
230
|
-
|
|
229
|
+
if options.key? :config_dir
|
|
230
|
+
config_dirs_cli = options[:config_dir].split(',')
|
|
231
|
+
config_dirs_cli.each { |dir|
|
|
232
|
+
config_dirs.push(File.join(dir, '.unipipe'))
|
|
233
|
+
config_dirs.push(File.join(dir, '.drupipe'))
|
|
234
|
+
config_dirs.push('')
|
|
235
|
+
}
|
|
236
|
+
else
|
|
237
|
+
config_dirs.push('.unipipe')
|
|
238
|
+
config_dirs.push('.drupipe')
|
|
239
|
+
config_dirs.push('')
|
|
231
240
|
end
|
|
232
|
-
config_dirs.push('.unipipe')
|
|
233
|
-
config_dirs.push('.drupipe')
|
|
234
|
-
config_dirs.push('')
|
|
235
241
|
config_dirs
|
|
236
242
|
end
|
|
237
243
|
|
|
@@ -21,26 +21,38 @@ module Docman
|
|
|
21
21
|
commands = nil
|
|
22
22
|
if self['source_type'] == 'file'
|
|
23
23
|
yaml_file_name = self['yaml_file_name'].nil? ? '{unipipe,.unipipe,drupipe,.drupipe,build,.build}.{yaml,yml}' : self['yaml_file_name']
|
|
24
|
-
|
|
24
|
+
search_pathes = []
|
|
25
|
+
if @context['name'] == 'master'
|
|
26
|
+
search_pathes.push File.join(@context['docroot_config'].config_dir, yaml_file_name)
|
|
27
|
+
end
|
|
28
|
+
search_pathes.push File.join(@context['full_build_path'], yaml_file_name)
|
|
29
|
+
build_file = Dir.glob(search_pathes).first
|
|
25
30
|
if not build_file.nil?
|
|
26
31
|
build_file_yaml = YAML::load_file(build_file)
|
|
27
32
|
commands = build_file_yaml[self['stage']]
|
|
28
33
|
source = yaml_file_name
|
|
29
34
|
end
|
|
30
35
|
end
|
|
36
|
+
chdir = ''
|
|
31
37
|
if self['source_type'] == 'inline'
|
|
32
38
|
commands = self['commands']
|
|
33
39
|
source = 'inline'
|
|
40
|
+
if self.has_key?('exec_dir')
|
|
41
|
+
chdir = self['exec_dir']
|
|
42
|
+
end
|
|
34
43
|
end
|
|
44
|
+
chdir_full = File.join(@context['full_build_path'], chdir)
|
|
45
|
+
Dir.chdir chdir_full
|
|
35
46
|
unless commands.nil?
|
|
36
47
|
commands.each do |cmd|
|
|
37
|
-
logger.info "Execute from #{source}: #{cmd}"
|
|
48
|
+
logger.info "Execute in #{chdir_full} from #{source}: #{cmd}"
|
|
38
49
|
logger.info `#{cmd}`
|
|
39
50
|
if $?.exitstatus > 0
|
|
40
51
|
raise "Command #{cmd} was failed"
|
|
41
52
|
end
|
|
42
53
|
end
|
|
43
54
|
end
|
|
55
|
+
Dir.chdir @context['full_build_path']
|
|
44
56
|
end
|
|
45
57
|
end
|
|
46
58
|
end
|
data/lib/docman/config.rb
CHANGED
|
@@ -24,20 +24,51 @@ module Docman
|
|
|
24
24
|
@unmutable_config = Marshal::load(Marshal.dump(@config))
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
def normalize_config(config)
|
|
28
|
+
temp_config = {}
|
|
29
|
+
@config['uniconf'][@config_version]['keys'].each{|key,value|
|
|
30
|
+
temp_config[value]
|
|
31
|
+
(1..@config_version).each {|version|
|
|
32
|
+
if config.has_key?(@config['uniconf'][version]['keys'][key])
|
|
33
|
+
tc = {}
|
|
34
|
+
tc[value] = config[@config['uniconf'][version]['keys'][key]]
|
|
35
|
+
config.delete(@config['uniconf'][version]['keys'][key])
|
|
36
|
+
temp_config.deep_merge!(tc)
|
|
37
|
+
end
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return temp_config.deep_merge!(config)
|
|
41
|
+
end
|
|
42
|
+
|
|
27
43
|
def merge_config_from_file(docroot_dir, docroot_config_dir, config_file, options = nil)
|
|
28
44
|
file = File.join(docroot_config_dir, config_file)
|
|
29
45
|
if File.file?(file)
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
yaml = YAML::load_file(file)
|
|
47
|
+
@config_version = 1
|
|
48
|
+
if yaml.has_key?('config_version')
|
|
49
|
+
@config_version = yaml['config_version']
|
|
50
|
+
end
|
|
51
|
+
config = normalize_config(yaml)
|
|
52
|
+
if config.has_key?(@config['uniconf'][@config_version]['keys']['include'])
|
|
32
53
|
scenarios_path = File.join(docroot_dir, '.docman/scenarios')
|
|
33
54
|
`rm -fR #{scenarios_path}` if File.directory? scenarios_path
|
|
34
55
|
`mkdir -p #{scenarios_path}`
|
|
35
|
-
unless config['
|
|
36
|
-
config['
|
|
56
|
+
unless config.has_key?(@config['uniconf'][@config_version]['keys']['sources'])
|
|
57
|
+
config[@config['uniconf'][@config_version]['keys']['sources']] = {}
|
|
58
|
+
end
|
|
59
|
+
if ENV.has_key?('UNIPIPE_SOURCES')
|
|
60
|
+
unipipe_sources = ENV['UNIPIPE_SOURCES']
|
|
61
|
+
puts "UNIPIPE_SOURCES: #{unipipe_sources}"
|
|
62
|
+
sources = {}
|
|
63
|
+
sources[@config['uniconf'][@config_version]['keys']['sources']] = JSON.parse(unipipe_sources)
|
|
64
|
+
puts "UNIPIPE_SOURCES PARSED: #{sources}"
|
|
65
|
+
config.deep_merge(sources)
|
|
66
|
+
else
|
|
67
|
+
puts "UNIPIPE_SOURCES not defined in environment. Additional sources may be not available."
|
|
37
68
|
end
|
|
38
|
-
config['
|
|
39
|
-
config['
|
|
40
|
-
@loaded_scenario_sources['root_config'] = config['
|
|
69
|
+
config[@config['uniconf'][@config_version]['keys']['sources']]['root_config'] = {}
|
|
70
|
+
config[@config['uniconf'][@config_version]['keys']['sources']]['root_config']['dir'] = docroot_config_dir
|
|
71
|
+
@loaded_scenario_sources['root_config'] = config[@config['uniconf'][@config_version]['keys']['sources']]['root_config']
|
|
41
72
|
config = merge_scenarios_configs(config, {}, scenarios_path, 'root_config')
|
|
42
73
|
end
|
|
43
74
|
end
|
|
@@ -54,11 +85,11 @@ module Docman
|
|
|
54
85
|
assign_to_self
|
|
55
86
|
end
|
|
56
87
|
|
|
57
|
-
def merge_scenarios_configs(config, temp_config = {}, scenarios_path, current_scenario_source_name)
|
|
88
|
+
def merge_scenarios_configs(config, temp_config = {}, scenarios_path = '', current_scenario_source_name = '')
|
|
58
89
|
temp_config.deep_merge!(config)
|
|
59
90
|
scenarios_config = {}
|
|
60
|
-
|
|
61
|
-
config['
|
|
91
|
+
if config.has_key?(@config['uniconf'][@config_version]['keys']['include'])
|
|
92
|
+
config[@config['uniconf'][@config_version]['keys']['include']].each do |s|
|
|
62
93
|
scenario = {}
|
|
63
94
|
if s.is_a? String
|
|
64
95
|
values = s.split(':')
|
|
@@ -70,21 +101,25 @@ module Docman
|
|
|
70
101
|
scenario_name = values[0]
|
|
71
102
|
end
|
|
72
103
|
scenario['name'] = scenario_name
|
|
73
|
-
if temp_config['
|
|
74
|
-
|
|
75
|
-
|
|
104
|
+
if temp_config[@config['uniconf'][@config_version]['keys']['sources']].has_key?(scenario_source_name)
|
|
105
|
+
scenario_source_path = File.join(scenarios_path, scenario_source_name)
|
|
106
|
+
if temp_config[@config['uniconf'][@config_version]['keys']['sources']][scenario_source_name].has_key?('dir') and not temp_config[@config['uniconf'][@config_version]['keys']['sources']][scenario_source_name]['dir'].nil?
|
|
107
|
+
scenario_source_path = temp_config[@config['uniconf'][@config_version]['keys']['sources']][scenario_source_name]['dir']
|
|
108
|
+
end
|
|
76
109
|
if @loaded_scenario_sources.key? scenario_source_name
|
|
77
110
|
scenario['source'] = @loaded_scenario_sources[scenario_source_name]
|
|
78
111
|
else
|
|
79
112
|
`rm -fR #{scenario_source_path}` if File.directory? scenario_source_path
|
|
80
|
-
scenario['source'] = temp_config['
|
|
113
|
+
scenario['source'] = temp_config[@config['uniconf'][@config_version]['keys']['sources']][scenario_source_name]
|
|
81
114
|
scenario['source']['ref'] = scenario['source']['ref'] ? scenario['source']['ref'] : 'master'
|
|
82
115
|
GitUtil.clone_repo(scenario['source']['repo'], scenario_source_path, 'branch', scenario['source']['ref'], true, 1)
|
|
83
116
|
@loaded_scenario_sources[scenario_source_name] = scenario['source']
|
|
84
117
|
end
|
|
85
|
-
scenario_config_file = File.join(scenario_source_path, '
|
|
118
|
+
scenario_config_file = File.join(scenario_source_path, @config['uniconf'][@config_version]['dirs']['sources'], scenario['name'], 'config.yaml')
|
|
86
119
|
if File.file? scenario_config_file
|
|
87
|
-
|
|
120
|
+
lyaml = YAML::load_file(scenario_config_file)
|
|
121
|
+
nyaml = normalize_config(lyaml)
|
|
122
|
+
scenario_config = merge_scenarios_configs(nyaml, temp_config, scenarios_path, scenario_source_name)
|
|
88
123
|
scenarios_config.deep_merge!(scenario_config)
|
|
89
124
|
puts "Loaded scenario #{scenario['name']} from source #{scenario_source_name}"
|
|
90
125
|
end
|
|
@@ -18,7 +18,9 @@ module Docman
|
|
|
18
18
|
@docroot_config_dir = File.join(docroot_dir, 'config')
|
|
19
19
|
|
|
20
20
|
Dir.chdir @docroot_config_dir
|
|
21
|
-
|
|
21
|
+
unless options.key? :config_dir
|
|
22
|
+
update('origin')
|
|
23
|
+
end
|
|
22
24
|
config_files = Docman::Application.instance.config_dirs(options).collect{|item|
|
|
23
25
|
File.join(@docroot_config_dir, item, 'config.{yaml,yml}')
|
|
24
26
|
}
|
data/lib/docman/git_util.rb
CHANGED
|
@@ -25,7 +25,9 @@ module Docman
|
|
|
25
25
|
def self.reset_repo(path)
|
|
26
26
|
Dir.chdir path
|
|
27
27
|
exec 'reset --hard'
|
|
28
|
-
exec 'clean -f -d'
|
|
28
|
+
exec 'clean -f -d -x --dry-run'
|
|
29
|
+
exec 'status'
|
|
30
|
+
exec 'clean -f -d -x'
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
def self.get(repo, path, type, version, single_branch = nil, depth = nil, reset = false)
|
data/lib/docman/info.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Docman
|
|
|
19
19
|
unless self['docroot_config'].deploy_target.nil?
|
|
20
20
|
if self.has_key? 'states'
|
|
21
21
|
self['states'].each_pair do |name, state|
|
|
22
|
-
if state.has_key?('source') and (not state.has_key?('type') or state.has_key['type'] == 'external_source')
|
|
22
|
+
if state.has_key?('source') and (not state.has_key?('type') or (state.has_key?('type') and state['type'] == 'external_source'))
|
|
23
23
|
if state['source']['type'] == :retrieve_from_repo
|
|
24
24
|
@state_name = name
|
|
25
25
|
repo = state['source']['repo'] == :project_repo ? self['repo'] : state['source']['repo']
|
|
@@ -146,7 +146,7 @@ module Docman
|
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
def states(options = {})
|
|
149
|
-
if options[:type] == 'root' and self['type'] == 'root_chain'
|
|
149
|
+
if options[:type] == 'root' and (self['type'] == 'root_chain' or self['type'] == 'single')
|
|
150
150
|
self['root_repo_states']
|
|
151
151
|
else
|
|
152
152
|
self['states']
|
data/lib/docman/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: docman
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.84
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Tolstikov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-12-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|