Sha256: 8de8c98f3d4e901eddba9bbf55ff50f93295efee0307aedb525ba47ae1c614bc
Contents?: true
Size: 1.63 KB
Versions: 13
Compression:
Stored size: 1.63 KB
Contents
require 'pry' module Pfab class Yamls def initialize(apps:, application_yaml:, image_name:, env:, sha:, config:) @apps = apps namespace = application_yaml.dig(env.to_s, "namespace") || application_yaml["namespace"] raise "No namespace founds" unless namespace @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, 'namespace' => namespace, } end def env_vars(app) template = Pfab::Templates::Base.new(data_for(app, @apps[app])) template.env_vars end def data_for(app, props) data = @base_data.clone data['props'] = props data['deployed_name'] = app data end def namespace @base_data['namespace'] end def generate(keys) keys.each do |key| props = @apps[key] data = data_for(key, props) filename = ".application-k8s-#{data["env"]}-#{key}.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 end end
Version data entries
13 entries across 13 versions & 1 rubygems