Skip to content
This repository was archived by the owner on Feb 16, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 9 additions & 36 deletions deployment/gem.rb
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
# This stuff should be moved into a gem
def get_value_from_parameters(key)
set :path, "./app/config/parameters.yml"

if File.exists?(path)
parameters = YAML.load_file(path).fetch("parameters", nil)

unless parameters.nil?
return parameters.fetch(key, nil)
end
end

return nil
YAML.load_file('./app/config/parameters.yml').fetch('parameters', {}).fetch(key, nil) rescue nil
end

def get_value_from_remote_parameters(key)
set :path, "app/config/parameters.yml"

begin
remoteParameters = capture("cat #{shared_path}/#{path}")
rescue
return nil
end

parameters = YAML.load(remoteParameters).fetch("parameters", nil)

unless parameters.nil?
return parameters.fetch(key, nil)
end

return nil
# We use echo in the end to reset exit code when file is missing (without it deployment will fail on this command)
remote_parameters = capture("cat #{shared_path}/app/config/parameters.yml 2>/dev/null; echo").to_s.strip
YAML.load(remote_parameters).fetch('parameters', {}).fetch(key, nil) rescue nil
end

def ask(question, default)
# \033[46m - cyanBg
# \033[33m - yellow
message = "\033[46m#{question}\033[0m"
unless default.empty?
message += " (\033[33m#{default}\033[0m)"
end
message += " (\033[33m#{default}\033[0m)" unless default.empty?
message += ":"

answer = Capistrano::CLI.ui.ask message
if answer.empty?
answer = default
end

answer
answer.empty? ? default : answer
end

namespace :sumo do
Expand Down Expand Up @@ -86,8 +60,7 @@ def ask(question, default)
Your current branch (#{working_branch}) is not the same as the
branch (#{branch_to_deploy}) that will be deployed.
EOF
error = CommandError.new(message)
raise error
raise CommandError.new(message)
end

# check if the branch is up to date
Expand Down