class Pfab::Yamls
Public Class Methods
new(apps:, application_yaml:, image_name:, env:, sha:, config:)
click to toggle source
# File lib/pfab/yamls.rb, line 5 def initialize(apps:, application_yaml:, image_name:, env:, sha:, config:) @apps = apps @base_data = { "env" => env.to_s, 'image_name' => image_name, 'sha' => sha, 'container_repository' => config["container.repository"], 'config' => config, 'application' => application_yaml["name"], 'application_yaml' => application_yaml } end
Public Instance Methods
data_for(app, props)
click to toggle source
# File lib/pfab/yamls.rb, line 23 def data_for(app, props) data = @base_data.clone data['props'] = props data['deployed_name'] = app data end
env_vars(app)
click to toggle source
# File lib/pfab/yamls.rb, line 18 def env_vars(app) template = Pfab::Templates::Base.new(data_for(app, @apps[app])) template.env_vars end
generate_all()
click to toggle source
# File lib/pfab/yamls.rb, line 30 def generate_all @apps.map do |app, props| data = data_for(app, props) filename = ".application-k8s-#{data["env"]}-#{app}.yaml" File.open(filename, "w") do |f| case props[:deployable_type] when "web" then processed = Pfab::Templates::Web.new(data).write_to(f) when "job" then processed = Pfab::Templates::Job.new(data).write_to(f) when "daemon" then processed = Pfab::Templates::Daemon.new(data).write_to(f) when "cron" then processed = Pfab::Templates::Cron.new(data).write_to(f) end end filename end end