174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/cosmos/models/microservice_model.rb', line 174
def deploy(gem_path, variables, validate_only: false)
return unless @folder_name
variables["microservice_name"] = @name
start_path = "/microservices/#{@folder_name}/"
Dir.glob(gem_path + start_path + "**/*") do |filename|
next if filename == '.' or filename == '..' or File.directory?(filename)
path = filename.split(gem_path)[-1]
key = "#{@scope}/microservices/#{@name}/" + path.split(start_path)[-1]
data = File.read(filename, mode: "rb")
Cosmos.set_working_dir(File.dirname(filename)) do
data = ERB.new(data, trim_mode: "-").result(binding.set_variables(variables)) if data.is_printable?
end
unless validate_only
Aws::S3::Client.new.put_object(bucket: 'config', key: key, body: data)
ConfigTopic.write({ kind: 'created', type: 'microservice', name: @name, plugin: @plugin }, scope: @scope)
end
end
end
|