Sha256: 7dc2a5f15cf121b66e176f6cf924c0a334dd30a3ed113247de1daeee26ca080c

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

require_relative './builders/docker'
require 'yaml'

module Popito
  class BuildExecutor
    attr_accessor :config_payload

    def initialize(config_payload)
      self.config_payload = config_payload
    end

    def yaml_config
      @yaml_config ||= load_yaml
    end

    def build
      yaml_config["build"].each do |build|
        builder = Popito::BuildExecutor::Builders::Docker.new(
          root_path: config_payload.project_path,
          dockerfile: "#{config_payload.build_path}/#{build['dockerfile']}",
          image: build["image"],
          tags: build["tags"]
        )
        builder.build
      end
    end

    def release
      yaml_config["build"].each do |build|
        builder = Popito::BuildExecutor::Builders::Docker.new(
          root_path: config_payload.project_path,
          dockerfile: "#{config_payload.build_path}/#{build['dockerfile']}",
          image: build["image"],
          tags: build["tags"]
        )
        builder.push
      end
    end

    private

    def camelize(value)
      value.to_s.capitalize.gsub(/_(\w)/) { Regexp.last_match(1).upcase }
    end

    def load_yaml
      YAML.safe_load(File.read("#{config_payload.build_path}/build.yaml"))
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
popito-0.0.11.alpha lib/popito/deployer/build/build_executor.rb
popito-0.0.10.alpha lib/popito/deployer/build/build_executor.rb
popito-0.0.9.alpha lib/popito/deployer/build/build_executor.rb
popito-0.0.8.alpha lib/popito/deployer/build/build_executor.rb
popito-0.0.7.alpha lib/popito/deployer/build/build_executor.rb
popito-0.0.6.alpha lib/popito/deployer/build/build_executor.rb
popito-0.0.5.alpha lib/popito/deployer/build/build_executor.rb
popito-0.0.4.alpha lib/popito/deployer/build/build_executor.rb