Sha256: 330640e820265c9e99ea562cf842732a6d7a2108a042601b97c9af62c02948ed

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

module Popito
  class DeployExecutor
    attr_accessor :config_payload

    def initialize(config_payload)
      self.config_payload = config_payload
      @deploy_files_dir = "#{config_payload.deploy_path}/deploy"
    end

    def check
      puts 'Validating generated files...'
      system "kubectl apply --validate=true --dry-run=client -f #{@deploy_files_dir}", exception: true
    end

    def deploy
      puts 'Applying generated files...'
      system "kubectl apply -f #{@deploy_files_dir}", exception: true
    end

    def push_deployed_tag
      yaml_build_config["build"].each do |build|
        tag = build["tags"].first
        puts "Pushing #{build["image"]}:#{tag} to #{build["image"]}:popito-#{config_payload.build_config[:ENVIRONMENT]}"
        system "docker image tag #{build["image"]}:#{tag} #{build["image"]}:popito-#{config_payload.build_config[:ENVIRONMENT]}", exception: true
        system "docker push #{build["image"]}:popito-#{config_payload.build_config['ENVIRONMENT']}", exception: true
      end
    end

    private
    
    def yaml_build_config
      @yaml_config ||= load_build_yaml
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
popito-0.0.9.alpha lib/popito/deployer/deploy/deploy_executor.rb