docman 0.0.99 → 0.0.100

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c33f19d40ef65fbc0a67c8a5981cb6c1f5a2e755
4
- data.tar.gz: fa2a0ab1aa3bc357222ee20befe1a5fd92d36e40
3
+ metadata.gz: e231868676b2f087fe12b8734ae861b205b95ad0
4
+ data.tar.gz: a87e681d52375023f07f9ef0019fcca151f16664
5
5
  SHA512:
6
- metadata.gz: 85956602c75962475c80d14cd22dfb15c5d06e4fc5f8c4b9010188a430f5c2ac9435aeb0fa8d536ee59bbffa8a84542a937e179e0a04b988c09a90db34088943
7
- data.tar.gz: 714f172b03ead9e1c62717a56a123579b4ed8bdeffed1a3f24c54d58bd01ff51f81b64123054388d5c600680d72ce638c321dcbb89fbec014727bd13f111c127
6
+ metadata.gz: b58e55802f3d67a3cd04283688770969c0e68c3af2cdea8fe73e31e5c8e2365f93eecfe1de41d7e06bd280642b5d2f0158e90692683556a1a80694021c2a6e04
7
+ data.tar.gz: 749fed753ef3466accdddbcbf0d46de7efc59e3462357f31b45855eb1ed9ad6de4442579ae2fed1a84e4f50389498e9b122d2bf5575bed1120d8eb7a7ef2d9f3
@@ -84,7 +84,7 @@ module Docman
84
84
  def build(deploy_target_name, state, options = false)
85
85
  with_rescue do
86
86
  @options = options
87
- @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target_name, options)
87
+ @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target_name, options, state)
88
88
  @deploy_target = @docroot_config.deploy_target
89
89
  execute('build', state, nil, options['tag'])
90
90
  end
@@ -94,7 +94,7 @@ module Docman
94
94
  result = nil
95
95
  with_rescue do
96
96
  @options = options
97
- @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target_name, options)
97
+ @docroot_config = DocrootConfig.new(@workspace_dir, deploy_target_name, options, state)
98
98
  @deploy_target = @docroot_config.deploy_target
99
99
  @docroot_config.states_dependin_on(name, version).keys.each do |state|
100
100
  execute('deploy', state, name)
@@ -45,13 +45,21 @@ module Docman
45
45
  method_option :config, :desc => 'Configuration override JSON'
46
46
  method_option :config_dir, :desc => 'Config directories divided by coma where docman will search for config.yaml'
47
47
  option :tag
48
- def build(deploy_target, state)
49
- get_to_root_dir
50
- if options[:force]
51
- FileUtils.rm_rf('master') if File.directory? 'master'
48
+ def build(deploy_target="git_target", state="")
49
+ docman_state_var = "DOCMAN_STATE"
50
+ if ENV.has_key? docman_state_var and ENV[docman_state_var].length > 0
51
+ state = ENV[docman_state_var]
52
+ end
53
+ if state.length > 0
54
+ get_to_root_dir
55
+ if options[:force]
56
+ FileUtils.rm_rf('master') if File.directory? 'master'
57
+ end
58
+ Application.instance.build(deploy_target, state, options)
59
+ say('Complete!', :green)
60
+ else
61
+ say("Cant build without state parameter or #{docman_state_var} environment variable.")
52
62
  end
53
- Application.instance.build(deploy_target, state, options)
54
- say('Complete!', :green)
55
63
  end
56
64
 
57
65
  desc 'deploy', 'Deploy to target'
@@ -14,7 +14,15 @@ module Docman
14
14
  prev_version = File.file?(filepath) ? File.open(filepath) : nil
15
15
  params = self['environment']['tagger']
16
16
  params['prev_version'] = prev_version
17
- version = Docman::Taggers::Tagger.create(params, root, self).perform
17
+ version = ''
18
+ docman_tag_var = "DOCMAN_TAG"
19
+ if ENV.has_key? docman_tag_var and ENV[docman_tag_var].length > 0
20
+ puts "Variable #{docman_tag_var} => #{ENV[docman_tag_var]}"
21
+ version = ENV[docman_tag_var]
22
+ else
23
+ puts "Variable #{docman_tag_var} not found."
24
+ version = Docman::Taggers::Tagger.create(params, root, self).perform
25
+ end
18
26
  File.open(filepath, 'w') {|f| f.write(version) }
19
27
 
20
28
  filepath = File.join(root['full_build_path'], 'version.properties')
@@ -8,7 +8,9 @@ module Docman
8
8
 
9
9
  attr_reader :structure, :deploy_target, :docroot_dir, :docroot_config_dir, :config_dir, :root, :raw_infos
10
10
 
11
- def initialize(docroot_dir, deploy_target_name = nil, options = nil)
11
+ def initialize(docroot_dir, deploy_target_name = nil, options = nil, state = nil)
12
+ @state = state
13
+
12
14
  @override = {}
13
15
  if options && options['config']
14
16
  @override = JSON.parse(options['config'])
@@ -90,6 +92,8 @@ module Docman
90
92
  info.merge! @override['projects'][info['name']]
91
93
  end
92
94
 
95
+ info = override_from_environment(info)
96
+
93
97
  i = Docman::Info.new(info)
94
98
  @root = i if parent.nil?
95
99
  i['root'] = @root
@@ -130,6 +134,8 @@ module Docman
130
134
  info.merge! @override['projects'][info['name']]
131
135
  end
132
136
 
137
+ info = override_from_environment(info)
138
+
133
139
  i = Docman::Info.new(info)
134
140
  @root = i if parent.nil?
135
141
  i['root'] = @root
@@ -149,6 +155,54 @@ module Docman
149
155
  i
150
156
  end
151
157
 
158
+ def override_from_environment(info)
159
+
160
+ docman_config_var = "DOCMAN_CONFIG"
161
+ if ENV.has_key? docman_config_var and ENV[docman_config_var].length > 0
162
+ puts "Variable #{docman_config_var} => #{ENV[docman_config_var]}"
163
+ docman_config_overrides = JSON.parse(ENV[docman_config_var])
164
+ if docman_config_overrides['projects'] && docman_config_overrides['projects'].key?(info['name'])
165
+ info.merge! docman_config_overrides['projects'][info['name']]
166
+ end
167
+ else
168
+ puts "Variable #{docman_config_var} not found."
169
+ end
170
+
171
+ docman_repo_var = "DOCMAN_PROJECTS_#{info['name'].upcase}_REPO"
172
+ if ENV.has_key? docman_repo_var and ENV[docman_repo_var].length > 0
173
+ puts "Variable #{docman_repo_var} => #{ENV[docman_repo_var]}"
174
+ info['repo'] = ENV[docman_repo_var]
175
+ else
176
+ puts "Variable #{docman_repo_var} not found."
177
+ end
178
+
179
+ docman_order_var = "DOCMAN_PROJECTS_#{info['name'].upcase}_ORDER"
180
+ if ENV.has_key? docman_order_var and ENV[docman_tag_var].length > 0
181
+ puts "Variable #{docman_order_var} => #{ENV[docman_order_var]}"
182
+ info['order'] = ENV[docman_order_var]
183
+ else
184
+ puts "Variable #{docman_order_var} not found."
185
+ end
186
+
187
+ docman_version_var = "DOCMAN_PROJECTS_#{info['name'].upcase}_VERSION"
188
+ if ENV.has_key? docman_version_var and ENV[docman_version_var].length > 0
189
+ puts "Variable #{docman_version_var} => #{ENV[docman_version_var]}"
190
+ if @state.nil?
191
+ info['states'].each do |k,v|
192
+ info['states'][k]['type'] = "branch"
193
+ info['states'][k]['version'] = ENV[docman_version_var]
194
+ end
195
+ else
196
+ info['states'][@state]['type'] = "branch"
197
+ info['states'][@state]['version'] = ENV[docman_version_var]
198
+ end
199
+ else
200
+ puts "Variable #{docman_version_var} not found."
201
+ end
202
+
203
+ info
204
+ end
205
+
152
206
  def chain(info)
153
207
  chain = {}
154
208
  chain[info['name']] = info
@@ -1,3 +1,3 @@
1
1
  module Docman
2
- VERSION = "0.0.99"
2
+ VERSION = "0.0.100"
3
3
  end
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.99
4
+ version: 0.0.100
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Tolstikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-05 00:00:00.000000000 Z
11
+ date: 2019-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler