Class: Commands::CIC::Command

Inherits:
Thor
  • Object
show all
Defined in:
lib/commands/cic/command.rb

Defined Under Namespace

Classes: CICDirectoryMissing, ContainerAlreadyRunningError

Constant Summary collapse

CONTAINER_NOT_RUNNING_MSG =
'Container is not running'.freeze
CONTAINER_STOPPED_MSG =
'Container stopped'.freeze

Instance Method Summary collapse

Instance Method Details

#connect(container_name) ⇒ Object



24
25
26
27
28
# File 'lib/commands/cic/command.rb', line 24

def connect(container_name)
  command = "-it #{container_id(container_name)} "
  command << (options[:command] || 'bash -l')
  docker_exec(command)
end

#downObject



32
33
34
35
36
37
38
# File 'lib/commands/cic/command.rb', line 32

def down
  in_cic_directory do
    execute "#{courseware_environment} docker-compose down",
            pass_message: "Environment cic'd down :)",
            fail_message: 'Failed to cic down the environment see above output for details'
  end
end

#upObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/commands/cic/command.rb', line 45

def up
  in_cic_directory do
    commands = ["#{courseware_environment} docker-compose up -d --remove-orphans"]

    before_script = 'before'
    commands << "./#{before_script}" if File.exist?(before_script)

    after_script = 'after'
    commands << "./#{after_script}" if File.exist?(after_script)

    execute(*commands,
            pass_message: "Environment cic'd up :)",
            fail_message: 'Failed to cic up the environment see above output for details')
  end
end