Sha256: 9a13502f0d3ab2e4c6b0ab3676b559ad5c5586eeef18fefc9c3baad1dcc19075

Contents?: true

Size: 1.35 KB

Versions: 17

Compression:

Stored size: 1.35 KB

Contents

require 'idlc-sdk-pfm/command/base'
require 'mixlib/shellout'

module Pfm
  module Command
    class Destroy < Base
      banner 'Usage: pfm destroy [options]'

      def initialize
        super
        @params_valid = true
        @errors = []
      end

      def run(params)
        @params = params
        read_and_validate_params

        if params_valid?
          deploy_setup
          destroy
          # @workspace.cleanup causing bundler issues
          0
        else
          @errors.each { |error| err("Error: #{error}") }
          parse_options(params)
          msg(opt_parser)
          1
        end
      rescue DeploymentFailure => e
        err("ERROR: #{e.message}\n")
        1
      end

      def destroy
        Idlc::Deploy::Config.add_deployment_var('build', ENV['SERVER_BUILD'])
        Idlc::Deploy::Config.add_deployment_var('app_release', 'null')

        Terraform::Binary.destroy("#{@workspace.tmp_dir}")
      rescue
        raise DeploymentFailure, 'Finished with errors'
      end

      def read_and_validate_params
        arguments = parse_options(@params)

        @params_valid = case arguments.size
                        when 0
                          true
                        else
                          false
                        end
      end

      def params_valid?
        @params_valid
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
idlc-sdk-pfm-1.0.3 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.2 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.1 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc18 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc17 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc16 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc15 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc14 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc13 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc12 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc11 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc10 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc9 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc8 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc7 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc6 lib/idlc-sdk-pfm/command/destroy.rb
idlc-sdk-pfm-1.0.0.rc5 lib/idlc-sdk-pfm/command/destroy.rb