Class: DockerManager::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/dockermanager/config.rb

Constant Summary collapse

KEYS =
{
  env: {
    required: %i[host docker_user remote_directory remote_postgres_db_container local_postgres_db_container]
  },
  registry: {
    required: %i[login password],
    optional: %i[server]
  },
  required: [],
  optional: %i[containers_to_restart]
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env:, config_file:) ⇒ Config

Returns a new instance of Config.



17
18
19
20
# File 'lib/dockermanager/config.rb', line 17

def initialize(env:, config_file:)
  self.env = env
  self.config = YAML.load_file(config_file)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



15
16
17
# File 'lib/dockermanager/config.rb', line 15

def config
  @config
end

#envObject

Returns the value of attribute env.



15
16
17
# File 'lib/dockermanager/config.rb', line 15

def env
  @env
end

Instance Method Details

#local_deploy_pathObject



42
43
44
45
46
47
48
49
50
# File 'lib/dockermanager/config.rb', line 42

def local_deploy_path
  return @local_deploy_path if defined?(@local_deploy_path)
  @local_deploy_path = "#{local_docker_path}/deploy"
  unless Dir.exist?(@local_deploy_path)
    puts "invalid local deploy path : #{@local_deploy_path}"
    exit 5
  end
  @local_deploy_path
end

#local_docker_pathObject



32
33
34
35
36
37
38
39
40
# File 'lib/dockermanager/config.rb', line 32

def local_docker_path
  return @local_docker_path if defined?(@local_docker_path)
  @local_docker_path = "#{project_root_path}/docker"
  unless Dir.exist?(@local_docker_path)
    puts "invalid local docker path : #{@local_docker_path}"
    exit 4
  end
  @local_docker_path
end

#project_root_pathObject



22
23
24
25
26
27
28
29
30
# File 'lib/dockermanager/config.rb', line 22

def project_root_path
  return @project_root_path if defined?(@project_root_path)
  @project_root_path = value(key: :project_root_path, required: true)
  unless Dir.exist?(@project_root_path)
    puts "invalid project_root_path : #{@project_root_path}"
    exit 3
  end
  @project_root_path
end