azdeploy 1.0.3 → 1.0.4

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: 9cf2c326811c55622109ab3769d6e3680426b7cd
4
- data.tar.gz: 7308f6e64f03c786355d9ecf49f2372e9525272e
3
+ metadata.gz: 568d52c0cf58f450921d0c2a230008cf3e9c07ae
4
+ data.tar.gz: 46f4a975b55a31ee59505564c20cee1d2e2806a7
5
5
  SHA512:
6
- metadata.gz: a52d51303c4d7d04a3217d4e2d4e89ee213dd8d46abcb82aa1db31b9f7936b7f3be4518edc38cff4e57a01718a668fcfc8800ddd7a35d6459a7073c07bfbfea6
7
- data.tar.gz: 8397068d136473385e2f6e93b6b50df86f7a552a34bbab6d4291e6044ce65f2a6f67421afe153cb0d19a27e83dea9481a6886414bd422e414cb0607139830427
6
+ metadata.gz: e0233f3afcd694be9d466e0576dc8582570fae1c262134dfc4df3e7f84aa2587fa24d127a8dca1ff014489c42bbd7f54d3c83f48b226d5a912bdaa4d5b51ff50
7
+ data.tar.gz: 7aaad78029ced4b08490dcfa539cde948a24614443559039331336cfef6abd30cefeae4a81b8622c9eaa19ac91b1f9a451cd1196459c0043aca9581d1e34701b
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'azdeploy'
3
- s.version = '1.0.3'
3
+ s.version = '1.0.4'
4
4
  s.date = '2015-02-04'
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'
@@ -16,7 +16,7 @@ require 'nokogiri'
16
16
  require 'azure'
17
17
 
18
18
  # config transform
19
- transform
19
+ Transform.new.transform
20
20
 
21
21
  # includes for rake build
22
22
  include FileTest
@@ -1,205 +1,214 @@
1
- def get(key)
2
- begin
3
- result = @svc.get_entity(@table, @env, key)
4
- rescue
5
- puts $!
6
- puts "key : #{@key}"
7
- puts
8
- end
1
+ class Transform
2
+
3
+ attr_accessor :env
4
+ attr_accessor :svc
5
+ attr_accessor :table
6
+ attr_accessor :settings
7
+ attr_accessor :config_files
8
+
9
+ def get(key)
10
+ begin
11
+ result = @svc.get_entity(@table, @env, key)
12
+ rescue
13
+ puts $!
14
+ puts "key : #{@key}"
15
+ puts
16
+ end
9
17
 
10
- result
11
- end
12
-
13
- def get_all
14
- begin
15
- query = { :filter => "PartitionKey eq '#{@env}'" }
16
- result = @svc.query_entities(@table, query)
17
- rescue
18
- puts $!
19
- puts "Env : #{@env}"
20
- puts
18
+ result
21
19
  end
22
-
23
- result
24
- end
25
-
26
- def get_value(key)
27
- value = ''
28
- @settings.each { |i|
29
- if i.properties['RowKey'] == key
30
- value = i.properties['setting']
31
- break
32
- end
33
- }
34
20
 
35
- value
36
- end
21
+ def get_all
22
+ begin
23
+ query = { :filter => "PartitionKey eq '#{@env}'" }
24
+ result = @svc.query_entities(@table, query)
25
+ rescue
26
+ puts $!
27
+ puts "Env : #{@env}"
28
+ puts
29
+ end
30
+
31
+ result
32
+ end
37
33
 
38
- def transform_appsettings
39
- # go to each file and replace value of matching appSettings key
40
- @configFiles.each{|file|
41
- doc = Nokogiri::XML(File.read(file))
42
- puts "Processing file: #{file}"
34
+ def get_value(key)
35
+ value = ''
43
36
  @settings.each { |i|
44
- key = i.properties['RowKey']
45
- node = doc.at_css "appSettings/add[@key='#{key}']"
46
- if !node.nil?
47
- oldVal = node['value']
48
- #puts "Old value: #{oldVal}"
49
- node['value'] = i.properties['setting']
50
- newVal = node['value']
51
- #puts "New value: #{newVal}"
37
+ if i.properties['RowKey'] == key
38
+ value = i.properties['setting']
39
+ break
52
40
  end
53
41
  }
54
- File.write(file, doc.to_xml)
55
- }
56
- end
57
-
58
- def transform_servicemodelconfig
59
- @configFiles.each{|file|
60
- doc = Nokogiri::XML(File.read(file))
61
- doc.xpath('//system.serviceModel').each do |node|
62
- #puts node
63
- if file.end_with?('app.config') || file.end_with?('App.config')
64
- node.replace(get_value('system.ServiceModel.Client')) if !node.nil?
65
- elsif file.end_with?('Web.config')
66
- node.replace(get_value('system.ServiceModel.Service')) if !node.nil?
42
+
43
+ value
44
+ end
45
+
46
+ def transform_appsettings
47
+ # go to each file and replace value of matching appSettings key
48
+ @config_files.each{|file|
49
+ doc = Nokogiri::XML(File.read(file))
50
+ puts "Processing file: #{file}"
51
+ @settings.each { |i|
52
+ key = i.properties['RowKey']
53
+ node = doc.at_css "appSettings/add[@key='#{key}']"
54
+ if !node.nil?
55
+ oldVal = node['value']
56
+ #puts "Old value: #{oldVal}"
57
+ node['value'] = i.properties['setting']
58
+ newVal = node['value']
59
+ #puts "New value: #{newVal}"
60
+ end
61
+ }
62
+ File.write(file, doc.to_xml)
63
+ }
64
+ end
65
+
66
+ def transform_servicemodelconfig
67
+ @config_files.each{|file|
68
+ doc = Nokogiri::XML(File.read(file))
69
+ doc.xpath('//system.serviceModel').each do |node|
70
+ #puts node
71
+ if file.end_with?('app.config') || file.end_with?('App.config')
72
+ node.replace(get_value('system.ServiceModel.Client')) if !node.nil?
73
+ elsif file.end_with?('Web.config')
74
+ node.replace(get_value('system.ServiceModel.Service')) if !node.nil?
75
+ end
67
76
  end
68
- end
69
- File.write(file, doc.to_xml)
70
- }
71
- end
72
-
73
- def transform_systemwebcompilationattribs
74
- @configFiles.each{|file|
75
- doc = Nokogiri::XML(File.read(file))
76
- node = doc.at_css "compilation"
77
- if !node.nil?
78
- #puts node
79
- node.xpath('//@debug').remove
80
- node.xpath('//@tempDirectory').remove
81
- #puts node
82
77
  File.write(file, doc.to_xml)
83
- end
84
- }
85
- end
78
+ }
79
+ end
80
+
81
+ def transform_systemwebcompilationattribs
82
+ @config_files.each{|file|
83
+ doc = Nokogiri::XML(File.read(file))
84
+ node = doc.at_css "compilation"
85
+ if !node.nil?
86
+ #puts node
87
+ node.xpath('//@debug').remove
88
+ node.xpath('//@tempDirectory').remove
89
+ #puts node
90
+ File.write(file, doc.to_xml)
91
+ end
92
+ }
93
+ end
86
94
 
87
- def transform_csdef
88
- csdef = Dir.glob("**/*.csdef")
89
- csdef.each{ |file|
90
- doc = Nokogiri::XML(File.read(file))
95
+ def transform_csdef
96
+ csdef = Dir.glob("**/*.csdef")
97
+ csdef.each{ |file|
98
+ doc = Nokogiri::XML(File.read(file))
91
99
 
92
- node = doc.at_css "ServiceDefinition"
93
- node['name'] = ENV['ServiceName'] if !node.nil?
100
+ node = doc.at_css "ServiceDefinition"
101
+ node['name'] = ENV['ServiceName'] if !node.nil?
94
102
 
95
- node = doc.at_css "WebRole"
96
- node['name'] = ENV['ServiceName'] if !node.nil?
103
+ node = doc.at_css "WebRole"
104
+ node['name'] = ENV['ServiceName'] if !node.nil?
97
105
 
98
- node = doc.at_css "Certificates"
99
- node.replace(get_value('Certificates_csdef')) if !node.nil?
100
-
101
- node = doc.at_css "Endpoints"
102
- node.replace(get_value('Endpoints')) if !node.nil?
103
-
104
- node = doc.at_css "Bindings"
105
- node.replace(get_value('Bindings')) if !node.nil?
106
+ node = doc.at_css "Certificates"
107
+ node.replace(get_value('Certificates_csdef')) if !node.nil?
108
+
109
+ node = doc.at_css "Endpoints"
110
+ node.replace(get_value('Endpoints')) if !node.nil?
111
+
112
+ node = doc.at_css "Bindings"
113
+ node.replace(get_value('Bindings')) if !node.nil?
106
114
 
107
- File.write(file, doc.to_xml)
108
- }
109
- end
115
+ File.write(file, doc.to_xml)
116
+ }
117
+ end
110
118
 
111
- def transform_cscfg
112
- csdef = Dir.glob("**/*.cscfg")
113
- csdef.each{ |file|
114
- doc = Nokogiri::XML(File.read(file))
119
+ def transform_cscfg
120
+ csdef = Dir.glob("**/*.cscfg")
121
+ csdef.each{ |file|
122
+ doc = Nokogiri::XML(File.read(file))
115
123
 
116
- node = doc.at_css "ServiceConfiguration"
117
- node['serviceName'] = ENV['ServiceName'] if !node.nil?
124
+ node = doc.at_css "ServiceConfiguration"
125
+ node['serviceName'] = ENV['ServiceName'] if !node.nil?
118
126
 
119
- node = doc.at_css "Role"
120
- node['name'] = ENV['ServiceName'] if !node.nil?
127
+ node = doc.at_css "Role"
128
+ node['name'] = ENV['ServiceName'] if !node.nil?
121
129
 
122
- node = doc.at_css "Certificates"
123
- node.replace(get_value('Certificates_cscfg')) if !node.nil?
130
+ node = doc.at_css "Certificates"
131
+ node.replace(get_value('Certificates_cscfg')) if !node.nil?
124
132
 
125
- File.write(file, doc.to_xml)
126
- }
127
- end
133
+ File.write(file, doc.to_xml)
134
+ }
135
+ end
128
136
 
129
- def transform_diagnosticscfg
130
- csdef = Dir.glob("**/*.wadcfgx")
131
- csdef.each{ |file|
132
- doc = Nokogiri::XML(File.read(file))
137
+ def transform_diagnosticscfg
138
+ csdef = Dir.glob("**/*.wadcfgx")
139
+ csdef.each{ |file|
140
+ doc = Nokogiri::XML(File.read(file))
141
+
142
+ node = doc.at_css "PrivateConfig/StorageAccount"
143
+ node['name'] = get_value('StorageAccount')
144
+ node['key'] = get_value('StorageAccountKey')
145
+ node = doc.at_css "StorageAccount"
146
+ node.content = get_value('StorageAccount')
147
+
148
+ File.write(file, doc.to_xml)
149
+ }
150
+ end
133
151
 
134
- node = doc.at_css "PrivateConfig/StorageAccount"
135
- node['name'] = get_value('StorageAccount')
136
- node['key'] = get_value('StorageAccountKey')
137
- node = doc.at_css "StorageAccount"
138
- node.content = get_value('StorageAccount')
139
-
140
- File.write(file, doc.to_xml)
141
- }
142
- end
152
+ def transform
143
153
 
144
- def transform
154
+ # environment invoked
155
+ @env = ENV['env'] || 'noenv'
156
+ if @env == 'noenv'
157
+ puts 'Environment name required to transform. No configuration changes will be done...'
158
+ return false
159
+ end
145
160
 
146
- # environment invoked
147
- @env = ENV['env'] || 'noenv'
148
- if @env == 'noenv'
149
- puts 'Environment name required to transform. No configuration changes will be done...'
150
- return false
151
- end
161
+ is_service = ENV['ServiceName'] || 'nosvc'
162
+ puts 'Target to transform is not a service...' if is_service == 'nosvc'
152
163
 
153
- @is_service = ENV['ServiceName'] || 'nosvc'
154
- puts 'Target to transform is not a service...' if @is_service == 'nosvc'
164
+ puts "Transforming config for environment: #{@env} ..."
155
165
 
156
- puts "Transforming config for environment: #{@env} ..."
166
+ # azure table storage account where settings reside
167
+ Azure.config.storage_account_name = ENV['StorageAccount']
168
+ Azure.config.storage_access_key = ENV['StorageAccountKey']
169
+ @table = ENV['ConfigSettingsTable']
157
170
 
158
- # azure table storage account where settings reside
159
- Azure.config.storage_account_name = ENV['StorageAccount']
160
- Azure.config.storage_access_key = ENV['StorageAccountKey']
161
- @table = ENV['ConfigSettingsTable']
171
+ # table service
172
+ @svc = Azure::TableService.new
162
173
 
163
- # table service
164
- @svc = Azure::TableService.new
174
+ # get all settings for environment
175
+ @settings = get_all
165
176
 
166
- # get all settings for environment
167
- @settings = get_all
177
+ # find all App.config and web.config files
178
+ @config_files = Dir.glob("**/app.config")
179
+ @config_files.concat(Dir.glob("**/web.config"))
168
180
 
169
- # find all App.config and web.config files
170
- @configFiles = Dir.glob("**/app.config")
171
- @configFiles.concat(Dir.glob("**/web.config"))
181
+ if is_service
172
182
 
173
- # get config templates
174
- if @is_service
183
+ puts "Obtaining cloud configuration templates..."
184
+ csdefTemplate = get_value('ServiceDefinitionTemplate')
185
+ File.write('ServiceDefinition.csdef', csdefTemplate)
186
+ cscfgTemplate = get_value('ServiceConfigurationTemplate')
187
+ File.write('ServiceConfiguration.cscfg', cscfgTemplate)
175
188
 
176
- puts "Obtaining templates..."
177
- csdefTemplate = get_value('ServiceDefinitionTemplate')
178
- File.write('ServiceDefinition.csdef', csdefTemplate)
179
- cscfgTemplate = get_value('ServiceConfigurationTemplate')
180
- File.write('ServiceConfiguration.cscfg', cscfgTemplate)
189
+ @config_files.concat(Dir.glob("**/RuntimeWeb/*Web.dll.config"))
181
190
 
182
- @configFiles.concat(Dir.glob("**/RuntimeWeb/*Web.dll.config"))
191
+ puts "Transforming csdef..."
192
+ transform_csdef
183
193
 
184
- puts "Transforming csdef..."
185
- transform_csdef
194
+ puts "Transforming cscfg..."
195
+ transform_cscfg
186
196
 
187
- puts "Transforming cscfg..."
188
- transform_cscfg
197
+ puts "Transforming diagnostics cfg..."
198
+ transform_diagnosticscfg
189
199
 
190
- puts "Transforming diagnostics cfg..."
191
- transform_diagnosticscfg
200
+ puts "Replacing service model settings..."
201
+ transform_servicemodelconfig
202
+
203
+ end
192
204
 
193
- puts "Replacing service model settings..."
194
- transform_servicemodelconfig
195
-
196
- end
205
+ puts "Replacing app settings..."
206
+ transform_appsettings
197
207
 
198
- puts "Replacing app settings..."
199
- transform_appsettings
208
+ puts "Removing debug compilation attributes..."
209
+ transform_systemwebcompilationattribs
200
210
 
201
- puts "Removing debug compilation attributes..."
202
- transform_systemwebcompilationattribs
211
+ return true
212
+ end
203
213
 
204
- return true
205
214
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suresh Batta