azdeploy 1.0.19 → 1.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/azdeploy.gemspec +2 -2
  3. data/lib/transform.rb +77 -51
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9bb7548db5cec9e11d4a65b1a6de69159b581a1
4
- data.tar.gz: 2cb3abd91e3710a067a27f407fe00ad16601632e
3
+ metadata.gz: f44fe4d7f6c34024cc9807e921bc5e3474bc7404
4
+ data.tar.gz: fa1d0b6b5f31843d4ae7a9ce625f73e283a7a3ff
5
5
  SHA512:
6
- metadata.gz: 6b1b760dba40834d8f1700b29fad30f194f232bfbf7806693db401cff10b66d69244c5c753ee656ac33feb9219ab9a007e776959303da9731b0f1e6de6675d66
7
- data.tar.gz: 61dadaefeb6b0e12263129910ebff9415ccea7d5a8c8e2f1926c8fbe770568092a38b8f7bf4cb9d15e62d72a2c8222137778ce5096fc986c6ad3a02c77a1df4c
6
+ metadata.gz: 5740cfe22441487a334a8cfcf1b0c36cf91454f4d27f2aa3b9730a0194ea35014430471496bccdd92f339b0775a419368707da8129d1fc63fdb019d0e494954c
7
+ data.tar.gz: 54d83b7dbcf8a783584c134c7e936f5201fa4ebb8ccd9b841ce565554831c060f522523b90086042bc33118caa7f03480e5b19c83c71ac84d43bd56d6ca708df
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'azdeploy'
3
- s.version = '1.0.19'
4
- s.date = '2015-08-05'
3
+ s.version = '1.0.20'
4
+ s.date = '2015-08-06'
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'
7
7
  s.authors = ['Suresh Batta']
@@ -37,6 +37,9 @@ class Transform
37
37
  end
38
38
 
39
39
  def get_value(key)
40
+ if (@settings.nil?)
41
+ return
42
+ end
40
43
  value = ''
41
44
  @settings.each { |i|
42
45
  if i.properties[ROWKEY] == key
@@ -47,36 +50,38 @@ class Transform
47
50
 
48
51
  value
49
52
  end
50
-
51
- def transform_connstring(connstr)
52
- @config_files.each{|file|
53
- doc = Nokogiri::XML(File.read(file))
54
- puts "Processing file: #{file}"
55
- node = doc.at_css "appSettings/add[@key='connectionString']"
56
- if !node.nil?
57
- node[VALUE] = connstr
58
- File.write(file, doc.to_xml)
59
- end
60
- }
61
- end
62
53
 
63
- def transform_appsettings
54
+ def transform_appsettings(key = '', value = '')
64
55
  # go to each file and replace value of matching appSettings key
65
56
  @config_files.each{|file|
66
57
  doc = Nokogiri::XML(File.read(file))
67
58
  puts "Processing file: #{file}"
68
- @settings.each { |i|
69
- key = i.properties[ROWKEY]
70
- node = doc.at_css "appSettings/add[@key='#{key}']"
59
+ if (@settings.nil?)
60
+ if (key.to_s == '')
61
+ k = NO
62
+ else
63
+ k = key
64
+ end
65
+ if (value.to_s == '')
66
+ v = NO
67
+ else
68
+ v = value
69
+ end
70
+ else
71
+ @settings.each { |i|
72
+ k = i.properties[ROWKEY] || NO
73
+ v = i.properties[SETTING] || NO
74
+ }
75
+ end
76
+ if (k != NO && v != NO)
77
+ node = doc.at_css "appSettings/add[@key='#{k}']"
71
78
  if !node.nil?
72
- oldVal = node[VALUE]
73
- #puts "Old value: #{oldVal}"
74
- node[VALUE] = i.properties[SETTING]
75
- newVal = node[VALUE]
76
- #puts "New value: #{newVal}"
79
+ #puts "Old value: #{node[VALUE]}"
80
+ node[VALUE] = v
81
+ #puts "New value: #{v}"
77
82
  File.write(file, doc.to_xml)
78
83
  end
79
- }
84
+ end
80
85
  }
81
86
  end
82
87
 
@@ -175,7 +180,13 @@ class Transform
175
180
 
176
181
  node = doc.at_css 'InstrumentationKey'
177
182
  if (!node.nil?)
178
- node.content = get_value('AI_InstrumentationKey') if !node.nil?
183
+ val_from_settings = get_value('AI_InstrumentationKey')
184
+ if (val_from_settings.to_s == '')
185
+ aikey = ENV['AI_InstrumentationKey'] || NO
186
+ end
187
+ if (aikey != NO)
188
+ node.content = aikey
189
+ end
179
190
  end
180
191
 
181
192
  File.write(file, doc.to_xml)
@@ -212,12 +223,17 @@ class Transform
212
223
  end
213
224
 
214
225
  def transform
215
-
216
- # find all App.config and web.config files
217
- @config_files = Dir.glob('**/app.config')
218
- @config_files.concat(Dir.glob('**/appSettings.config'))
219
- @config_files.concat(Dir.glob('**/web.config'))
220
-
226
+
227
+ # --- Get environment invoked
228
+ @env = ENV['env'] || NO
229
+ if @env == NO
230
+ puts 'Environment name required to transform. No configuration changes will be done...'
231
+ return false
232
+ else
233
+ puts "Transforming config for environment: #{@env} ..."
234
+ end
235
+
236
+ # --- Get Settings Account Name, Key and Table from Environment variables
221
237
  settings_account_name = ENV['SettingsAccount'] || ENV['StorageAccount'] || NO
222
238
  if (settings_account_name == NO)
223
239
  puts "No settings storage account name found"
@@ -233,28 +249,14 @@ class Transform
233
249
  puts "No configuration table found"
234
250
  return false
235
251
  end
236
-
237
- puts 'updating settings connection string...'
238
- settings_connstr = "DefaultEndpointsProtocol=https;AccountName=#{settings_account_name};AccountKey=#{settings_access_key}"
239
- should_update_settings_connstr = ENV['should_update_settings_connstr'] || NO
240
- if should_update_settings_connstr == NO
241
- puts 'Flag for Setttings Connection String Update not set.'
242
- else
243
- transform_connstring(settings_connstr)
244
- end
245
-
246
- # environment invoked
247
- @env = ENV['env'] || NO
248
- if @env == NO
249
- puts 'Environment name required to transform. No configuration changes will be done...'
250
- return false
251
- end
252
-
253
- is_service = ENV['ServiceName'] || NO
254
- puts 'Target to transform is not a service...' if is_service == NO
255
252
 
256
- puts "Transforming config for environment: #{@env} ..."
253
+ # --- Collect config files to transform
254
+ # find all App.config and web.config files
255
+ @config_files = Dir.glob('**/app.config')
256
+ @config_files.concat(Dir.glob('**/appSettings.config'))
257
+ @config_files.concat(Dir.glob('**/web.config'))
257
258
 
259
+ # --- Load Settings from storage
258
260
  # azure table storage account where settings reside
259
261
  Azure.config.storage_account_name = settings_account_name
260
262
  Azure.config.storage_access_key = settings_access_key
@@ -266,8 +268,31 @@ class Transform
266
268
  # get all settings for environment
267
269
  @settings = get_all
268
270
 
269
- if is_service
271
+ # --- Start Transformations ---
272
+ puts 'updating settings connection string...'
273
+ settings_connstr = "DefaultEndpointsProtocol=https;AccountName=#{settings_account_name};AccountKey=#{settings_access_key}"
274
+ should_update_settings_connstr = ENV['should_update_settings_connstr'] || NO
275
+ if should_update_settings_connstr == NO
276
+ puts 'Flag for Setttings Connection String Update not set.'
277
+ else
278
+ puts settings_connstr
279
+ transform_appsettings('connectionString', settings_connstr)
280
+ end
281
+
282
+ puts 'updating unit test connection string...'
283
+ unitest_connstr = "DefaultEndpointsProtocol=https;AccountName=#{settings_account_name};AccountKey=#{settings_access_key}"
284
+ unitest_connstr = ENV['unitestconnectionString'] || NO
285
+ if unitest_connstr == NO
286
+ puts 'No unit test connection string found.'
287
+ else
288
+ transform_appsettings('unitestconnectionString', unitest_connstr)
289
+ end
290
+
291
+ is_service = ENV['ServiceName'] || NO
270
292
 
293
+ if is_service != NO
294
+ puts "Transforming config for service: #{ENV['ServiceName']}"
295
+
271
296
  puts 'Obtaining cloud configuration templates...'
272
297
  csdefTemplate = get_value('ServiceDefinitionTemplate')
273
298
  File.write('ServiceDefinition.csdef', csdefTemplate)
@@ -288,7 +313,8 @@ class Transform
288
313
 
289
314
  puts 'Replacing service model settings...'
290
315
  transform_servicemodelconfig
291
-
316
+ else
317
+ puts 'Target to transform is not a service...'
292
318
  end
293
319
 
294
320
  puts 'Replacing app settings...'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.19
4
+ version: 1.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suresh Batta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-05 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Azure Deployment Gem. Provides easy setup and deployment scripting support
14
14
  for .Net project builds