Class: Porkadot::Assets::Addons

Inherits:
Object
  • Object
show all
Includes:
Porkadot::Assets
Defined in:
lib/porkadot/assets/kubernetes.rb

Constant Summary collapse

TEMPLATE_DIR =
File.join(File.dirname(__FILE__), "kubernetes", "manifests", "addons")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Porkadot::Assets

#render_erb, #render_secrets_erb

Constructor Details

#initialize(global_config) ⇒ Addons

Returns a new instance of Addons.



65
66
67
68
69
# File 'lib/porkadot/assets/kubernetes.rb', line 65

def initialize global_config
  @global_config = global_config
  @config = global_config.addons
  @logger = global_config.logger
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



62
63
64
# File 'lib/porkadot/assets/kubernetes.rb', line 62

def config
  @config
end

#global_configObject (readonly)

Returns the value of attribute global_config.



61
62
63
# File 'lib/porkadot/assets/kubernetes.rb', line 61

def global_config
  @global_config
end

#loggerObject (readonly)

Returns the value of attribute logger.



63
64
65
# File 'lib/porkadot/assets/kubernetes.rb', line 63

def logger
  @logger
end

Class Method Details

.register_manifests(name, manifests, secrets: [], crds: []) ⇒ Object



99
100
101
102
103
104
105
106
# File 'lib/porkadot/assets/kubernetes.rb', line 99

def self.register_manifests name, manifests, secrets: [], crds: []
  @@manifests ||= {}
  @@manifests[name] = manifests
  @@secrets_manifests ||= {}
  @@secrets_manifests[name] = secrets
  @@crds ||= {}
  @@crds[name] = crds
end

Instance Method Details

#copy_crds(file) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/porkadot/assets/kubernetes.rb', line 91

def copy_crds file
  logger.info "----> #{file}"
  crd_path = File.join(config.target_crd_dir_path, file)
  crd_dir = File.dirname(crd_path)
  FileUtils.mkdir_p(crd_dir) unless File.directory?(crd_dir)
  FileUtils.copy(File.join(TEMPLATE_DIR, file), crd_path)
end

#renderObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/porkadot/assets/kubernetes.rb', line 71

def render
  logger.info "--> Rendering kubernetes addons"
  render_erb "kustomization.yaml"

  self.config.enabled.each do |name|
    manifests = @@manifests[name]
    manifests.each do |m|
      render_erb(m)
    end
    secrets = @@secrets_manifests[name]
    secrets.each do |m|
      render_secrets_erb(m)
    end
    crds = @@crds[name]
    crds.each do |m|
      copy_crds(m)
    end
  end
end