Module: Porkadot::Assets
- Included in:
- Addons, Bootstrap, EtcdNode, Kubelet, KubeletDefault, Kubernetes
- Defined in:
- lib/porkadot/assets.rb,
lib/porkadot/assets/etcd.rb,
lib/porkadot/assets/certs.rb,
lib/porkadot/assets/kubelet.rb,
lib/porkadot/assets/bootstrap.rb,
lib/porkadot/assets/kubernetes.rb
Defined Under Namespace
Modules: CertsUtils
Classes: Addons, Bootstrap, Certs, ErbUtils, EtcdList, EtcdNode, Kubelet, KubeletDefault, KubeletList, Kubernetes
Instance Method Summary
collapse
Instance Method Details
#render_erb(file, **opts) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/porkadot/assets.rb', line 18
def render_erb file, **opts
file = file.to_s
opts[:config] = self.config
opts[:global_config] = self.global_config
opts[:certs] = Porkadot::Assets::Certs.new(self.global_config)
opts[:u] = ErbUtils.new
logger.info "----> #{file}"
asset = config.asset_path(file)
if opts[:force] != nil && File.file?(asset)
logger.debug "------> Already exists: skipping #{file}"
return
end
asset_dir = File.dirname(asset)
FileUtils.mkdir_p(asset_dir) unless File.directory?(asset_dir)
open(File.join(self.class::TEMPLATE_DIR, "#{file}.erb")) do |io|
open(asset, 'w') do |out|
out.write ERB.new(io.read, trim_mode: '-').result_with_hash(opts)
end
end
end
|
#render_secrets_erb(file, opts = {}) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/porkadot/assets.rb', line 40
def render_secrets_erb file, opts={}
file = file.to_s
opts[:config] = self.config
opts[:global_config] = self.global_config
opts[:certs] = Porkadot::Assets::Certs.new(self.global_config)
opts[:u] = ErbUtils.new
logger.info "----> #{file}"
secret = config.secrets_path(file)
secret_dir = File.dirname(secret)
FileUtils.mkdir_p(secret_dir) unless File.directory?(secret_dir)
open(File.join(self.class::TEMPLATE_DIR, "#{file}.erb")) do |io|
open(secret, 'w') do |out|
out.write ERB.new(io.read, trim_mode: '-').result_with_hash(opts)
end
end
end
|