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



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

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



5
6
7
8
# File 'lib/mrsk/cli/build.rb', line 5

def deliver
  invoke :push
  invoke :pull
end

#detailsObject



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

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

#pullObject



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

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

#pushObject



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

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



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

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