azdeploy 1.0.3 → 1.0.4
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/azdeploy.gemspec +1 -1
- data/lib/azdeploy.rb +1 -1
- data/lib/transform.rb +174 -165
- 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: 568d52c0cf58f450921d0c2a230008cf3e9c07ae
|
4
|
+
data.tar.gz: 46f4a975b55a31ee59505564c20cee1d2e2806a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0233f3afcd694be9d466e0576dc8582570fae1c262134dfc4df3e7f84aa2587fa24d127a8dca1ff014489c42bbd7f54d3c83f48b226d5a912bdaa4d5b51ff50
|
7
|
+
data.tar.gz: 7aaad78029ced4b08490dcfa539cde948a24614443559039331336cfef6abd30cefeae4a81b8622c9eaa19ac91b1f9a451cd1196459c0043aca9581d1e34701b
|
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.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'
|
data/lib/azdeploy.rb
CHANGED
data/lib/transform.rb
CHANGED
@@ -1,205 +1,214 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
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
|
-
|
36
|
-
|
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
|
39
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
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
|
-
|
89
|
-
|
90
|
-
|
95
|
+
def transform_csdef
|
96
|
+
csdef = Dir.glob("**/*.csdef")
|
97
|
+
csdef.each{ |file|
|
98
|
+
doc = Nokogiri::XML(File.read(file))
|
91
99
|
|
92
|
-
|
93
|
-
|
100
|
+
node = doc.at_css "ServiceDefinition"
|
101
|
+
node['name'] = ENV['ServiceName'] if !node.nil?
|
94
102
|
|
95
|
-
|
96
|
-
|
103
|
+
node = doc.at_css "WebRole"
|
104
|
+
node['name'] = ENV['ServiceName'] if !node.nil?
|
97
105
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
108
|
-
|
109
|
-
end
|
115
|
+
File.write(file, doc.to_xml)
|
116
|
+
}
|
117
|
+
end
|
110
118
|
|
111
|
-
def transform_cscfg
|
112
|
-
|
113
|
-
|
114
|
-
|
119
|
+
def transform_cscfg
|
120
|
+
csdef = Dir.glob("**/*.cscfg")
|
121
|
+
csdef.each{ |file|
|
122
|
+
doc = Nokogiri::XML(File.read(file))
|
115
123
|
|
116
|
-
|
117
|
-
|
124
|
+
node = doc.at_css "ServiceConfiguration"
|
125
|
+
node['serviceName'] = ENV['ServiceName'] if !node.nil?
|
118
126
|
|
119
|
-
|
120
|
-
|
127
|
+
node = doc.at_css "Role"
|
128
|
+
node['name'] = ENV['ServiceName'] if !node.nil?
|
121
129
|
|
122
|
-
|
123
|
-
|
130
|
+
node = doc.at_css "Certificates"
|
131
|
+
node.replace(get_value('Certificates_cscfg')) if !node.nil?
|
124
132
|
|
125
|
-
|
126
|
-
|
127
|
-
end
|
133
|
+
File.write(file, doc.to_xml)
|
134
|
+
}
|
135
|
+
end
|
128
136
|
|
129
|
-
def transform_diagnosticscfg
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
147
|
-
|
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
|
-
|
154
|
-
puts 'Target to transform is not a service...' if @is_service == 'nosvc'
|
164
|
+
puts "Transforming config for environment: #{@env} ..."
|
155
165
|
|
156
|
-
|
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
|
-
|
159
|
-
|
160
|
-
Azure.config.storage_access_key = ENV['StorageAccountKey']
|
161
|
-
@table = ENV['ConfigSettingsTable']
|
171
|
+
# table service
|
172
|
+
@svc = Azure::TableService.new
|
162
173
|
|
163
|
-
|
164
|
-
|
174
|
+
# get all settings for environment
|
175
|
+
@settings = get_all
|
165
176
|
|
166
|
-
|
167
|
-
|
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
|
-
|
170
|
-
@configFiles = Dir.glob("**/app.config")
|
171
|
-
@configFiles.concat(Dir.glob("**/web.config"))
|
181
|
+
if is_service
|
172
182
|
|
173
|
-
|
174
|
-
|
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
|
-
|
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
|
-
|
191
|
+
puts "Transforming csdef..."
|
192
|
+
transform_csdef
|
183
193
|
|
184
|
-
|
185
|
-
|
194
|
+
puts "Transforming cscfg..."
|
195
|
+
transform_cscfg
|
186
196
|
|
187
|
-
|
188
|
-
|
197
|
+
puts "Transforming diagnostics cfg..."
|
198
|
+
transform_diagnosticscfg
|
189
199
|
|
190
|
-
|
191
|
-
|
200
|
+
puts "Replacing service model settings..."
|
201
|
+
transform_servicemodelconfig
|
202
|
+
|
203
|
+
end
|
192
204
|
|
193
|
-
puts "Replacing
|
194
|
-
|
195
|
-
|
196
|
-
end
|
205
|
+
puts "Replacing app settings..."
|
206
|
+
transform_appsettings
|
197
207
|
|
198
|
-
|
199
|
-
|
208
|
+
puts "Removing debug compilation attributes..."
|
209
|
+
transform_systemwebcompilationattribs
|
200
210
|
|
201
|
-
|
202
|
-
|
211
|
+
return true
|
212
|
+
end
|
203
213
|
|
204
|
-
return true
|
205
214
|
end
|