module Sct class DatabasePullCommand def error message UI.error message exit 1 end def execute args, options branch = ENV['CI_BRANCH'] if not branch or branch == "" branch = 'master' end # We need to set this locally, so that we don't save this at the repository pipeline_endpoint = ENV['CI_MERGE_REQUEST_PIPELINE'] if not pipeline_endpoint error "Pipeline endpoint not set" end # We need to set this locally, so that we don't save this at the repository private_token = ENV['CI_PRIVATE_TOKEN'] if not private_token error "Private token not set" end if options.all UI.important("Requesting to pull database changes for proactive frame and proactive config") process_request = `curl -X POST -F token=#{private_token} -F ref=master -F variables[DB_PULL_FRAME]=true -F variables[DB_PULL_CONFIG]=true -F variables[REMOTE_BRANCH_NAME]=#{branch} #{pipeline_endpoint}` else db_pull_frame = "" if options.proactive_frame UI.important("Requesting to pull database for proactive frame") db_pull_frame = "-F variables[DB_PULL_FRAME]=true" end db_pull_config = "" if options.proactive_config UI.important("Requesting to pull database for proactive config") db_pull_config = "-F variables[DB_PULL_CONFIG]=true" end if db_pull_frame != "" or db_pull_config != "" process_request = `curl -X POST -F token=#{private_token} -F ref=master #{db_pull_frame} #{db_pull_config} -F variables[REMOTE_BRANCH_NAME]=#{branch} #{pipeline_endpoint}` else error "Missing options. Use --help to see the available options" end end end end end