Class: Mrsk::Cli::Build

Inherits:
Base
  • Object
show all
Defined in:
lib/mrsk/cli/build.rb

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?, #initialize

Constructor Details

This class inherits a constructor from Mrsk::Cli::Base

Instance Method Details

#createObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mrsk/cli/build.rb', line 38

def create
  run_locally do
    begin
      debug "Using builder: #{MRSK.builder.name}"
      execute *MRSK.builder.create
    rescue SSHKit::Command::Failed => e
      if e.message =~ /stderr=(.*)/
        error "Couldn't create remote builder: #{$1}"
        false
      else
        raise
      end
    end
  end
end

#deliverObject



3
4
5
6
# File 'lib/mrsk/cli/build.rb', line 3

def deliver
  invoke :push
  invoke :pull
end

#detailsObject



63
64
65
66
67
68
# File 'lib/mrsk/cli/build.rb', line 63

def details
  run_locally do
    puts "Builder: #{MRSK.builder.name}"
    puts capture(*MRSK.builder.info)
  end
end

#pullObject



30
31
32
33
34
35
# File 'lib/mrsk/cli/build.rb', line 30

def pull
  on(MRSK.hosts) do
    execute *MRSK.auditor.record("Pulled image with version #{MRSK.version}"), verbosity: :debug
    execute *MRSK.builder.pull
  end
end

#pushObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mrsk/cli/build.rb', line 9

def push
  cli = self

  run_locally do
    begin
      MRSK.with_verbosity(:debug) { execute *MRSK.builder.push }
    rescue SSHKit::Command::Failed => e
      if e.message =~ /(no builder)|(no such file or directory)/
        error "Missing compatible builder, so creating a new one first"

        if cli.create
          MRSK.with_verbosity(:debug) { execute *MRSK.builder.push }
        end
      else
        raise
      end
    end
  end
end

#removeObject



55
56
57
58
59
60
# File 'lib/mrsk/cli/build.rb', line 55

def remove
  run_locally do
    debug "Using builder: #{MRSK.builder.name}"
    execute *MRSK.builder.remove
  end
end