Class: Circus::BoothTool
- Inherits:
-
Object
- Object
- Circus::BoothTool
- Defined in:
- lib/circus/booth_tool.rb
Instance Method Summary collapse
- #admit(name, apps, options) ⇒ Object
- #connect(name, booth, options = {}) ⇒ Object
-
#initialize(logger, config) ⇒ BoothTool
constructor
A new instance of BoothTool.
Constructor Details
#initialize(logger, config) ⇒ BoothTool
Returns a new instance of BoothTool.
8 9 10 11 |
# File 'lib/circus/booth_tool.rb', line 8 def initialize(logger, config) @logger = logger @config = config end |
Instance Method Details
#admit(name, apps, options) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/circus/booth_tool.rb', line 48 def admit(name, apps, ) booth = get_booth_or_default(name) return false unless booth repo_helper = Repos.find_repo_by_id(booth[:repo_type]).new(File.('.')) current_rev = repo_helper.current_revision unless current_rev @logger.error("Could not detect current repository version") return false end @logger.info("Starting admission into #{name} of version #{current_rev}") connection = ConnectionBuilder.new(booth).build(booth[:booth]) # connection.configure_bg!(OpenStruct.new(booth)) client = BoothClient.new(connection, @logger) apply_patch_fn = if [:uncommitted] patch_fn = Tempfile.new('booth').path repo_helper.write_patch(patch_fn) connection.send_file(patch_fn) else '' end admitted = Circus::Agents::Encoding.decode(client.admit(booth[:booth], booth[:booth_id], current_rev, apply_patch_fn, apps).result) return false if booth[:target] == 'none' clown_connection = ConnectionBuilder.new().build(booth[:target]) clown_client = ClownClient.new(clown_connection, @logger) admitted.each do |name, url| @logger.info("Executing deployment of #{name} from #{url} to #{booth[:target]}") clown_client.deploy(booth[:target], name, url).result end true end |
#connect(name, booth, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/circus/booth_tool.rb', line 13 def connect(name, booth, = {}) # Detect the facets of the repository repo_type_clazz = if [:repo_type] Repos.find_repo_by_id([:repo_type]) else Repos.find_repo_from_dir(File.('.')) end repo_type = repo_type_clazz.type_id repo_url = if [:repo_url] [:repo_url] else repo_helper = repo_type_clazz.new(File.('.')) repo_helper.repo_url end unless repo_url @logger.error("Could not detect repository source url") return false end app_name = [:app_name] || File.basename(File.('.')) @logger.info("Creating booth connection #{name} on #{booth} for #{repo_url} as #{app_name}") connection = ConnectionBuilder.new().build(booth) client = BoothClient.new(connection, @logger) booth_id = client.create_booth(booth, app_name, repo_type, repo_url).result @config.booths[name] = { :booth => booth, :booth_id => booth_id, :repo_type => repo_type, :target => [:deploy_target] || booth } end |