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



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/mrsk/cli/build.rb', line 45

def create
  with_lock do
    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
end

#deliverObject



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

def deliver
  with_lock do
    push
    pull
  end
end

#detailsObject



74
75
76
77
78
79
# File 'lib/mrsk/cli/build.rb', line 74

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

#pullObject



34
35
36
37
38
39
40
41
42
# File 'lib/mrsk/cli/build.rb', line 34

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

#pushObject



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

def push
  with_lock do
    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
end

#removeObject



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

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