Class: Porkadot::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Config

Returns a new instance of Config.



14
15
16
17
18
19
20
21
22
23
# File 'lib/porkadot/config.rb', line 14

def initialize path
  default_config = {}
  open(File.expand_path(File.join(Porkadot::ROOT, 'porkadot', 'default.yaml'))) do |io|
    default_config = YAML::load(io)
  end
  open(File.expand_path(path)) do |io|
    @raw = ::Porkadot::Raw.new(default_config.rmerge(YAML.load(io)))
  end
  @logger = Logger.new(STDOUT)
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



12
13
14
# File 'lib/porkadot/config.rb', line 12

def logger
  @logger
end

#rawObject (readonly)

Returns the value of attribute raw.



11
12
13
# File 'lib/porkadot/config.rb', line 11

def raw
  @raw
end

Instance Method Details

#addonsObject



34
35
36
# File 'lib/porkadot/config.rb', line 34

def addons
  @addons ||= Porkadot::Configs::Addons.new(self)
end

#assets_dirObject



84
85
86
# File 'lib/porkadot/config.rb', line 84

def assets_dir
  File.expand_path(raw.local.assets_dir)
end

#bootstrapObject



43
44
45
46
# File 'lib/porkadot/config.rb', line 43

def bootstrap
  @bootstrap ||= Porkadot::Configs::Bootstrap.new(self)
  return @bootstrap
end

#certsObject



25
26
27
28
# File 'lib/porkadot/config.rb', line 25

def certs
  @certs ||= Porkadot::Configs::Certs.new(self)
  return @certs
end

#connectionObject



30
31
32
# File 'lib/porkadot/config.rb', line 30

def connection
  self.raw.connection
end

#etcdObject



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

def etcd
  @etcd ||= Porkadot::Configs::Etcd.new(self)
  return @etcd
end

#etcd_nodesObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/porkadot/config.rb', line 73

def etcd_nodes
  @etcd_nodes ||= {}.tap do |nodes|
    self.raw.nodes.each do |k, v|
      if v && v.labels && v.labels.to_hash.keys.include?(Porkadot::ETCD_MEMBER_LABEL)
        nodes[k] = Porkadot::Configs::EtcdNode.new(self, k, v)
      end
    end
  end
  return @etcd_nodes
end

#kubelet_defaultObject



59
60
61
62
# File 'lib/porkadot/config.rb', line 59

def kubelet_default
  @kubelet_default ||= Porkadot::Configs::KubeletDefault.new(self)
  return @kubelet_default
end

#kubernetesObject Also known as: k8s



48
49
50
51
# File 'lib/porkadot/config.rb', line 48

def kubernetes
  @kubernetes ||= Porkadot::Configs::Kubernetes.new(self)
  return @kubernetes
end

#lbObject



38
39
40
41
# File 'lib/porkadot/config.rb', line 38

def lb
  @lb ||= Porkadot::Configs::Lb.new(self)
  return @lb
end

#nodesObject



64
65
66
67
68
69
70
71
# File 'lib/porkadot/config.rb', line 64

def nodes
  @nodes ||= {}.tap do |nodes|
    self.raw.nodes.each do |k, v|
      nodes[k] = Porkadot::Configs::Kubelet.new(self, k, v)
    end
  end
  return @nodes
end

#secrets_root_dirObject



88
89
90
# File 'lib/porkadot/config.rb', line 88

def secrets_root_dir
  File.join(self.assets_dir, 'secrets')
end