Module: Kapten::Helpers

Defined in:
lib/kapten/helpers.rb

Constant Summary collapse

TYPES =
{
  'ruby' => 'ruby:latest',
  'python' => 'python:latest',
  'node' => 'node:latest',
  'elixir' => 'elixir:latest',
  'php' => 'php:latest',
  'go' => 'golang:latest',
  'haskell' => 'haskell:latest',
  'java' => 'openjdk:latest',
  'perl' => 'perl:latest',
}

Class Method Summary collapse

Class Method Details

.get_image(type) ⇒ Object

Get Docker image by environment type



43
44
45
46
47
# File 'lib/kapten/helpers.rb', line 43

def self.get_image(type)

  return Kapten::Helpers::TYPES[ type ]

end

.get_typesObject

Get all available environment types



51
52
53
54
55
# File 'lib/kapten/helpers.rb', line 51

def self.get_types

  return Kapten::Helpers::TYPES.keys

end

.remove(name) ⇒ Object

Remove all traces of Kapten (stop and destory container, delete config file)



59
60
61
62
63
64
65
# File 'lib/kapten/helpers.rb', line 59

def self.remove(name)

  Kapten::DockerApi::destroy( name )

  File.delete( Kapten::Config::CONFIG_FILE )

end

.validate_installObject

Validate that Kapten is initalized and Docker is installed



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/kapten/helpers.rb', line 19

def self.validate_install

  config = Kapten::Config::get

  # Make sure a config exists (Kapten has been initialized)
  unless config
    puts 'Kapten not initalized'.red
    puts 'Run "kapten init" to get started'.red
    return false
  end

  # Make sure Docker is instsalled
  unless Kapten::DockerApi::has_docker?
    puts 'Kapten requires Docker'.red
    puts 'Install and then try running command again: https://www.docker.com'.red
    return false
  end

  return config

end