Sha256: 892135ed60f1cd7fca46ea012fcafe3a662cc22212e888686851ce35d815fb64

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require 'thor'
require 'pp'

class ArisControl::Thor < Thor
  desc 'add/update appname', 'Adds/Updates  an aris app.'
  method_option :email,    type: :string, desc: 'The apps email address. Used for web login.'
  method_option :ssh_key,  type: :string, desc: 'The apps ssh public key. Used for git access via ssh.'
  method_option :env_vars, type: :hash,   desc: 'The apps app env vars. Env vars will be accessible inside the app via ENV[VAR-NAME].'
  def add(name)
    opts = Hash.new.tap do |o|
      o[:email]    = options[:email]
      o[:ssh_key]  = options[:ssh_key]  if options[:ssh_key]
      o[:env_vars] = options[:env_vars] if options[:env_vars]
    end
    bookkeeper.add(name, **opts)
    puts "Added/Updated app: #{name}, #{opts}"
    puts "-----------------------------"
    print_current_aris_apps
  end

  desc 'delete name', 'Deletes aris app'
  def delete(name)
    bookkeeper.delete(name)
    puts "Removed app: #{name}"
    puts "-----------------------------"
    print_current_aris_apps
  end

  desc 'list', 'Lists current aris-apps'
  def list
    print_current_aris_apps
  end

  desc 'rollout', 'Runs ansible to provision the current apps.yml state'
  def rollout
    provsioner.rollout
    print_current_aris_apps
  end

  desc 'version', 'Prints out aris-control version'
  def version
    puts ArisControl::VERSION
  end

  private

  def print_current_aris_apps
    puts "Current aris app database"
    puts "-----------------------------"
    pp bookkeeper.list
  end

  def bookkeeper
    @bookkeeper ||= ArisControl::Bookkeeper.new
  end

  def provsioner
    @provsioner ||= ArisControl::Provisioner.new
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aris-control-3.2.0 lib/aris-control/thor.rb