Module: Dapp::Project::SystemShellout

Included in:
Dapp::Project
Defined in:
lib/dapp/project/system_shellout.rb

Constant Summary collapse

SYSTEM_SHELLOUT_IMAGE =
'ubuntu:16.04'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_env_keysObject



65
66
67
# File 'lib/dapp/project/system_shellout.rb', line 65

def default_env_keys
  @default_env_keys ||= []
end

Instance Method Details

#system_shellout(command, raise_error: false, **kwargs) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dapp/project/system_shellout.rb', line 7

def system_shellout(command, raise_error: false, **kwargs)
  system_shellout_extra(volume: (git_path ? File.dirname(git_path) : path)) do
    begin
      if raise_error
        shellout! _to_system_shellout_command(command), **kwargs
      else
        shellout _to_system_shellout_command(command), **kwargs
      end
    rescue Error::Shellout
      log_warning(
        desc: { code: :launched_command,
                data: { command: _to_system_shellout_command(command) },
                context: :system_shellout }
      )
      raise
    end
  end
end

#system_shellout!(command, **kwargs) ⇒ Object



26
27
28
# File 'lib/dapp/project/system_shellout.rb', line 26

def system_shellout!(command, **kwargs)
  system_shellout(command, raise_error: true, **kwargs)
end

#system_shellout_extra(volume: [], workdir: nil, &blk) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/dapp/project/system_shellout.rb', line 30

def system_shellout_extra(volume: [], workdir: nil, &blk)
  old = system_shellout_opts.dup

  system_shellout_opts[:volume] += Array(volume)
  system_shellout_opts[:workdir] = workdir if workdir

  yield if block_given?
ensure
  @system_shellout_opts = old
end