Class: Release

Inherits:
Object
  • Object
show all
Defined in:
lib/karist/release.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(release, release_file_obj) ⇒ Release

Returns a new instance of Release.



6
7
8
9
10
11
12
# File 'lib/karist/release.rb', line 6

def initialize(release, release_file_obj)
  @release_file = release_file_obj
  @name = release.fetch(:name)
  @namespace = release.fetch(:namespace, "default")
  @template = release.fetch(:template)
  @results = {}
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/karist/release.rb', line 4

def name
  @name
end

#resultsObject (readonly)

Returns the value of attribute results.



4
5
6
# File 'lib/karist/release.rb', line 4

def results
  @results
end

Instance Method Details

#marshal_all_yamlObject



26
27
28
29
30
# File 'lib/karist/release.rb', line 26

def marshal_all_yaml
  @results.map do |k, _|
    marshal_yaml(k)
  end
end

#marshal_yaml(k) ⇒ Object



32
33
34
# File 'lib/karist/release.rb', line 32

def marshal_yaml(k)
  @results[k].deep_stringify_keys.to_yaml
end

#renderObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/karist/release.rb', line 14

def render
  custom_file = "#{@release_file.env_path}/#{@name}/custom.yml"
  mutations = YAML.safe_load(File.read(custom_file)).deep_symbolize_keys

  manifests_path = "#{@release_file.templates_path}/#{@template}/manifests/**.yml"
  manifest_files = Dir.glob(manifests_path)
  manifest_files.each do |manifest_file|
    content = YAML.safe_load(File.read(manifest_file)).deep_symbolize_keys
    @results[manifest_file] = content.mutate(mutations)
  end
end