class InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::ApplicationSpecification

Attributes

files[R]
hooks[R]
os[R]
permissions[R]
version[R]

Public Class Methods

new(yaml_hash, opts = {}) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 10
def initialize(yaml_hash, opts = {})
  @version = parse_version(yaml_hash['version'])
  @os = parse_os(yaml_hash['os'])
  @hooks = parse_hooks(yaml_hash['hooks'] || {})
  @files = parse_files(yaml_hash['files'] || [])
  @permissions = parse_permissions(yaml_hash['permissions'] || [])
end
parse(app_spec_string) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 18
def self.parse(app_spec_string)
  new(YAML.load(app_spec_string))
end

Private Instance Methods

parse_acl(acl) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 132
def parse_acl(acl)
  acl.nil? ? nil : InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::AclInfo.new(acl)
end
parse_context(context) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 136
def parse_context(context)
  context.nil? ? nil : InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::ContextInfo.new(context)
end
parse_files(file_map_hash) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 45
def parse_files(file_map_hash)
  files = []
  #loop through hash and create fileInfo representations
  file_map_hash.each do |mapping|
    files << FileInfo.new(mapping['source'], mapping['destination'])
  end
  files
end
parse_hooks(hooks_hash) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 54
def parse_hooks(hooks_hash)
  temp_hooks_hash = Hash.new
  hooks_hash.each_pair do |hook, scripts|
    current_hook_scripts = []
    scripts.each do |script|
      if (script.has_key?('location') && !script['location'].nil?)
        current_hook_scripts << InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::ScriptInfo.new(script['location'].to_s.strip,
        {
          :runas => script.has_key?('runas') && !script['runas'].nil? ? script['runas'].to_s.strip : nil,
          :sudo => script['sudo'],
          :timeout => script['timeout']
        })
      else
        raise AppSpecValidationException, 'script provided without a location value'
      end
    end
    temp_hooks_hash[hook] = current_hook_scripts
  end
  temp_hooks_hash
end
parse_mode(mode) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 128
def parse_mode(mode)
  mode.nil? ? nil : InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::ModeInfo.new(mode)
end
parse_os(os) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 38
def parse_os(os)
  if !supported_oses.include?(os)
    raise AppSpecValidationException, "unsupported os: #{os}"
  end
  os
end
parse_permissions(permissions_list) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 75
def parse_permissions(permissions_list)
  permissions = []
  #loop through list and create permissionsInfo representations
  permissions_list.each do |permission|
    if !permission.has_key?('object') || permission['object'].nil?
      raise AppSpecValidationException, 'permission provided without a object value'
    end
    if @os.eql?('linux')
      permissions << InstanceAgent::Plugins::CodeDeployPlugin::ApplicationSpecification::LinuxPermissionInfo.new(permission['object'].to_s.strip,
      {
        :pattern => ('**'.eql?(permission['pattern']) || permission['pattern'].nil?) ? '**' : parse_simple_glob(permission['pattern']),
        :except => parse_simple_glob_list(permission['except']),
        :type => parse_type_list(permission['type']),
        :owner => permission['owner'],
        :group => permission['group'],
        :mode => parse_mode(permission['mode']),
        :acls => parse_acl(permission['acls']),
        :context => parse_context(permission['context'])
      })
    else
      raise AppSpecValidationException, 'permissions only supported with linux os currently'
    end
  end
  permissions
end
parse_simple_glob(glob) click to toggle source

placeholder for parsing globs: we should verify that the glob is only including what we expect. For now just returning it as it is.

# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 102
def parse_simple_glob(glob)
  glob
end
parse_simple_glob_list(glob_list) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 106
def parse_simple_glob_list(glob_list)
  temp_glob_list = []
  (glob_list || []).each do |glob|
    temp_glob_list << parse_simple_glob(glob)
  end
  temp_glob_list
end
parse_type_list(type_list) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 118
def parse_type_list(type_list)
  type_list ||= supported_types
  type_list.each do |type|
    if !supported_types.include?(type)
      raise AppSpecValidationException, "assigning permissions to objects of type #{type} not supported"
    end
  end
  type_list
end
parse_version(version) click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 27
def parse_version(version)
  if !supported_versions.include?(version)
    raise AppSpecValidationException, "unsupported version: #{version}"
  end
  version
end
supported_oses() click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 34
def supported_oses()
  InstanceAgent::Platform.util.supported_oses()
end
supported_types() click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 114
def supported_types
  ['file', 'directory']
end
supported_versions() click to toggle source
# File lib/instance_agent/plugins/codedeploy/application_specification/application_specification.rb, line 23
def supported_versions()
  [0.0]
end