Class: App::Deployments

Inherits:
Object
  • Object
show all
Defined in:
lib/core/deployments.rb

Constant Summary collapse

SCHEMA_FILE =
"#{App::Opt::get_base_path}#{App::Opt::OPT_PATH}/awx/deployment-schema.yml"
@@deployments =
nil

Class Method Summary collapse

Class Method Details

.init(deployments) ⇒ Object

Takes a Hash that will have all the deployment info.

Returns:

  • void

Raises:

  • (RuntimeError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/core/deployments.rb', line 11

def self.init(deployments)
    raise RuntimeError, 'Cannot run App::Deployments::init() more than once.' unless @@deployments.nil?
    raise RuntimeError, "Need either a Local or S3Bucket key, found neither: #{deployments.keys}" unless deployments.has_key?('Local') || deployments.has_key?('S3Bucket')
    @@deployments = {}

    if deployments.has_key?('Local')
        source_file = File.expand_path(deployments['Local']['File'])
        # Throw error if source file doesn't exist.
        Blufin::Terminal::error("Cannot find source file: #{Blufin::Terminal::format_directory(source_file)}") unless Blufin::Files::file_exists(source_file)
        # Validate the source file against the expected schema.
        process_source_file(source_file)
    elsif deployments.has_key?('S3Bucket')

        # TODO - Finish this once we start running this on an EC2 instance (build/deploy server).
        # TODO - Whatever file we validate should be available on disk locally.
        # TODO - If the source is an S3 bucket, pull it down into a /tmp folder (on EC2 instance) and validate from there.

    end




end