Sha256: deef5c5fee33e99b2421966c3f67236179a61b6dcc445ca4ef74ca87596d6bc7

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'optparse'
require_relative '../lib/popito/deployer/deployer'

params = {}
OptionParser.new do |opts|
  opts.on('--build', 'Generate docker images.')
  opts.on('--release', 'Push docker images to registry (must run after or together with build).')
  opts.on('--deploy', 'Run kubectl apply against deploy files.')
  opts.on('--check', 'Run kubectl apply --dry-run against generated yaml files.')
  opts.on('--tag IMAGE_TAG', 'This tag will used to build docker images and deploy.')
  opts.on('--tag-alt IMAGE_TAG_ALT', 'This tag will used to build docker images.')
  opts.on('--env ENVIRONMENT', 'It define environment used to build images and deploy files.')
  opts.on('--endpoint https://popito.mydomain.com', 'It defines popito endpoint.')
  opts.on('--token POPITO_TOKEN', 'This popito token used to auth this client in a specific project.')
  opts.on('--path ./project_path', 'Root folder of the app.')
end.parse!(into: params)

raise ArgumentError, 'You can choose --deploy and --check together.' if params[:check] && params[:deploy]

stages = []
stages.push('build') if params[:build]
stages.push('release') if params[:release]
stages.push('check') if params[:check]
stages.push('deploy') if params[:deploy]

config_payload = Popito::ConfigPayload.new(
  project_path: params[:path],
  stages: stages,
  project_token: params[:token],
  build_config: {
    IMAGE_TAG: params[:tag],
    IMAGE_TAG_ALT: params[:tag_alt],
    ENVIRONMENT: params[:env]
  }
)

if params[:build] || params[:release]
  Popito::StagePreparing.new(config_payload).create_deployer_folder(stage: 'build')
  builder = Popito::BuildExecutor.new(config_payload)
  builder.build if params[:build]
  builder.release if params[:release]
end

if params[:check] || params[:deploy]
  Popito::StagePreparing.new(config_payload).create_deployer_folder(stage: 'deploy')
  deployer = Popito::DeployExecutor.new(config_payload)
  deployer.check if params[:check]
  deployer.deploy if params[:deploy]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
popito-0.0.1.alpha exe/popito