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 git_branch]
  },
  registry: {
    required: i[ password],
    optional: i[server]
  },
  required: i[git_repository],
  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



45
46
47
48
49
50
51
52
53
# File 'lib/dockermanager/config.rb', line 45

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



35
36
37
38
39
40
41
42
43
# File 'lib/dockermanager/config.rb', line 35

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

#local_git_tmp_pathObject



55
56
57
# File 'lib/dockermanager/config.rb', line 55

def local_git_tmp_path
  @local_git_tmp_path ||= "#{local_deploy_path}/tmp"
end

#project_root_pathObject



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

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