azdeploy 1.0.23 → 1.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/azdeploy.gemspec +1 -1
- data/lib/transform.rb +45 -50
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1d3c94443746e97569ab92d434a0d096b57f812
|
4
|
+
data.tar.gz: aa32f296e32aab7255870c88d937a7a2a8fe016d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01d3c8acb8b9eb34f76a9d152ced9bec42ca7997f835a99058efdb20baa8ada1386365fd8f83dea8e246aec792e0587b0a2a167d93bad90f5cd0ac2f5696ed76
|
7
|
+
data.tar.gz: 72422a1db7de52191fd89a705ea213371f0bf0d06dbc0ece486c2a055e40819976f7ce570f14d453780b0efe8f61d3150987020af5fc2e855d4803beb8e9a020
|
data/azdeploy.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'azdeploy'
|
3
|
-
s.version = '1.0.
|
3
|
+
s.version = '1.0.24'
|
4
4
|
s.date = '2015-08-07'
|
5
5
|
s.summary = 'Setup and scripting support for .Net project builds'
|
6
6
|
s.description = 'Azure Deployment Gem. Provides easy setup and deployment scripting support for .Net project builds'
|
data/lib/transform.rb
CHANGED
@@ -6,11 +6,15 @@ class Transform
|
|
6
6
|
attr_accessor :settings
|
7
7
|
attr_accessor :config_files
|
8
8
|
|
9
|
-
|
9
|
+
NO_VALUE = 'no'
|
10
10
|
ROWKEY = 'RowKey'
|
11
11
|
SETTING = 'setting'
|
12
12
|
VALUE = 'value'
|
13
13
|
APPID = 'AppId'
|
14
|
+
EMPTY_STR = ''
|
15
|
+
STORAGEACCOUNT = 'StorageAccount'
|
16
|
+
STORAGEACCOUNTKEY = "#{STORAGEACCOUNT}Key"
|
17
|
+
CONNECTIONSTRING = 'connectionString'
|
14
18
|
|
15
19
|
def get(key)
|
16
20
|
begin
|
@@ -41,7 +45,7 @@ class Transform
|
|
41
45
|
if (@settings.nil?)
|
42
46
|
return
|
43
47
|
end
|
44
|
-
value =
|
48
|
+
value = EMPTY_STR
|
45
49
|
@settings.each { |i|
|
46
50
|
if i.properties[ROWKEY] == key
|
47
51
|
value = i.properties[SETTING]
|
@@ -52,27 +56,19 @@ class Transform
|
|
52
56
|
value
|
53
57
|
end
|
54
58
|
|
55
|
-
def transform_appsettings(key =
|
59
|
+
def transform_appsettings(key = EMPTY_STR, value = EMPTY_STR)
|
56
60
|
# go to each file and replace value of matching appSettings key
|
57
61
|
@config_files.each{|file|
|
58
62
|
doc = Nokogiri::XML(File.read(file))
|
59
63
|
puts "Processing file: #{file}"
|
60
|
-
if (
|
61
|
-
|
62
|
-
|
63
|
-
else
|
64
|
-
k = key
|
65
|
-
end
|
66
|
-
if (value.to_s == '')
|
67
|
-
v = NO
|
68
|
-
else
|
69
|
-
v = value
|
70
|
-
end
|
64
|
+
if (key.to_s != EMPTY_STR && value.to_s != EMPTY_STR)
|
65
|
+
k = key
|
66
|
+
v = value
|
71
67
|
update_appsetting(k, v, doc, file)
|
72
68
|
else
|
73
69
|
@settings.each { |i|
|
74
|
-
k = i.properties[ROWKEY] ||
|
75
|
-
v = i.properties[SETTING] ||
|
70
|
+
k = i.properties[ROWKEY] || NO_VALUE
|
71
|
+
v = i.properties[SETTING] || NO_VALUE
|
76
72
|
update_appsetting(k, v, doc, file)
|
77
73
|
}
|
78
74
|
end
|
@@ -80,7 +76,7 @@ class Transform
|
|
80
76
|
end
|
81
77
|
|
82
78
|
def update_appsetting(k, v, doc, file)
|
83
|
-
if (k !=
|
79
|
+
if (k != NO_VALUE && v != NO_VALUE)
|
84
80
|
node = doc.at_css "appSettings/add[@key='#{k}']"
|
85
81
|
if !node.nil?
|
86
82
|
#puts "Old value: #{node[VALUE]}"
|
@@ -187,12 +183,12 @@ class Transform
|
|
187
183
|
node = doc.at_css 'InstrumentationKey'
|
188
184
|
if (!node.nil?)
|
189
185
|
val_from_settings = get_value('AI_InstrumentationKey')
|
190
|
-
if (val_from_settings.to_s ==
|
191
|
-
aikey = ENV['AI_InstrumentationKey'] ||
|
186
|
+
if (val_from_settings.to_s == EMPTY_STR)
|
187
|
+
aikey = ENV['AI_InstrumentationKey'] || NO_VALUE
|
192
188
|
else
|
193
189
|
aikey = val_from_settings
|
194
190
|
end
|
195
|
-
if (aikey !=
|
191
|
+
if (aikey != NO_VALUE)
|
196
192
|
node.content = aikey
|
197
193
|
end
|
198
194
|
end
|
@@ -206,11 +202,11 @@ class Transform
|
|
206
202
|
csdef.each{ |file|
|
207
203
|
doc = Nokogiri::XML(File.read(file))
|
208
204
|
|
209
|
-
node = doc.at_css "PrivateConfig
|
210
|
-
node['name'] = get_value(
|
211
|
-
node['key'] = get_value(
|
212
|
-
node = doc.at_css
|
213
|
-
node.content = get_value(
|
205
|
+
node = doc.at_css "PrivateConfig/#{STORAGEACCOUNT}"
|
206
|
+
node['name'] = get_value(STORAGEACCOUNT)
|
207
|
+
node['key'] = get_value(STORAGEACCOUNTKEY)
|
208
|
+
node = doc.at_css STORAGEACCOUNT
|
209
|
+
node.content = get_value(STORAGEACCOUNT)
|
214
210
|
|
215
211
|
File.write(file, doc.to_xml)
|
216
212
|
}
|
@@ -233,8 +229,8 @@ class Transform
|
|
233
229
|
def transform
|
234
230
|
|
235
231
|
# --- Get environment invoked
|
236
|
-
@env = ENV['env'] ||
|
237
|
-
if @env ==
|
232
|
+
@env = ENV['env'] || NO_VALUE
|
233
|
+
if @env == NO_VALUE
|
238
234
|
puts 'Environment name required to transform. No configuration changes will be done...'
|
239
235
|
return false
|
240
236
|
else
|
@@ -242,18 +238,18 @@ class Transform
|
|
242
238
|
end
|
243
239
|
|
244
240
|
# --- Get Settings Account Name, Key and Table from Environment variables
|
245
|
-
settings_account_name = ENV['SettingsAccount'] || ENV[
|
246
|
-
if (settings_account_name ==
|
241
|
+
settings_account_name = ENV['SettingsAccount'] || ENV[STORAGEACCOUNT] || NO_VALUE
|
242
|
+
if (settings_account_name == NO_VALUE)
|
247
243
|
puts "No settings storage account name found"
|
248
244
|
return false
|
249
245
|
end
|
250
|
-
settings_access_key = ENV['SettingsAccountKey'] || ENV[
|
251
|
-
if (settings_access_key ==
|
246
|
+
settings_access_key = ENV['SettingsAccountKey'] || ENV[STORAGEACCOUNTKEY] || NO_VALUE
|
247
|
+
if (settings_access_key == NO_VALUE)
|
252
248
|
puts "No settings storage account key found"
|
253
249
|
return false
|
254
250
|
end
|
255
|
-
config_table = ENV['ConfigSettingsTable'] ||
|
256
|
-
if (config_table ==
|
251
|
+
config_table = ENV['ConfigSettingsTable'] || NO_VALUE
|
252
|
+
if (config_table == NO_VALUE)
|
257
253
|
puts "No configuration table found"
|
258
254
|
end
|
259
255
|
|
@@ -262,6 +258,8 @@ class Transform
|
|
262
258
|
@config_files = Dir.glob('**/app.config')
|
263
259
|
@config_files.concat(Dir.glob('**/appSettings.config'))
|
264
260
|
@config_files.concat(Dir.glob('**/web.config'))
|
261
|
+
@config_files.concat(Dir.glob('**/RuntimeWeb/*Web.dll.config'))
|
262
|
+
@config_files.concat(Dir.glob('**/RuntimeService/*.exe.config'))
|
265
263
|
|
266
264
|
# --- Load Settings from storage
|
267
265
|
# azure table storage account where settings reside
|
@@ -276,34 +274,34 @@ class Transform
|
|
276
274
|
@settings = get_all
|
277
275
|
|
278
276
|
# --- Start Transformations ---
|
279
|
-
puts
|
277
|
+
puts "updating settings #{CONNECTIONSTRING}..."
|
280
278
|
settings_connstr = "DefaultEndpointsProtocol=https;AccountName=#{settings_account_name};AccountKey=#{settings_access_key}"
|
281
|
-
should_update_settings_connstr = ENV['should_update_settings_connstr'] ||
|
282
|
-
if should_update_settings_connstr ==
|
283
|
-
puts
|
279
|
+
should_update_settings_connstr = ENV['should_update_settings_connstr'] || NO_VALUE
|
280
|
+
if should_update_settings_connstr == NO_VALUE
|
281
|
+
puts "Flag for Setttings #{CONNECTIONSTRING} Update not set."
|
284
282
|
else
|
285
|
-
transform_appsettings(
|
283
|
+
transform_appsettings(CONNECTIONSTRING, settings_connstr)
|
286
284
|
end
|
287
285
|
|
288
|
-
puts
|
289
|
-
unitest_connstr = ENV[
|
290
|
-
if unitest_connstr ==
|
291
|
-
puts
|
286
|
+
puts "updating unit test #{CONNECTIONSTRING}..."
|
287
|
+
unitest_connstr = ENV["unitest#{CONNECTIONSTRING}"] || NO_VALUE
|
288
|
+
if unitest_connstr == NO_VALUE
|
289
|
+
puts "No unit test #{CONNECTIONSTRING} found."
|
292
290
|
else
|
293
|
-
transform_appsettings(
|
291
|
+
transform_appsettings("unitest#{CONNECTIONSTRING}", unitest_connstr)
|
294
292
|
end
|
295
293
|
|
296
294
|
puts "updating #{APPID}..."
|
297
|
-
appId = ENV[APPID] ||
|
298
|
-
if appId ==
|
295
|
+
appId = ENV[APPID] || NO_VALUE
|
296
|
+
if appId == NO_VALUE
|
299
297
|
puts "No #{APPID} found."
|
300
298
|
else
|
301
299
|
transform_appsettings(APPID, appId)
|
302
300
|
end
|
303
301
|
|
304
302
|
@service_name = ENV['ServiceName']
|
305
|
-
is_service = @service_name ||
|
306
|
-
if is_service !=
|
303
|
+
is_service = @service_name || NO_VALUE
|
304
|
+
if is_service != NO_VALUE
|
307
305
|
puts "Transforming config for service: #{@service_name}"
|
308
306
|
|
309
307
|
puts 'Obtaining cloud configuration templates...'
|
@@ -312,9 +310,6 @@ class Transform
|
|
312
310
|
cscfgTemplate = get_value('ServiceConfigurationTemplate')
|
313
311
|
File.write('ServiceConfiguration.cscfg', cscfgTemplate)
|
314
312
|
|
315
|
-
@config_files.concat(Dir.glob('**/RuntimeWeb/*Web.dll.config'))
|
316
|
-
@config_files.concat(Dir.glob('**/RuntimeService/*.exe.config'))
|
317
|
-
|
318
313
|
puts 'Transforming csdef...'
|
319
314
|
transform_csdef
|
320
315
|
|