in lib/instance_agent/plugins/codedeploy/deployment_specification.rb [32:106]
def initialize(data)
raise 'Deployment Spec has no DeploymentId' unless property_set?(data, "DeploymentId")
raise 'Deployment Spec has no DeploymentGroupId' unless property_set?(data, "DeploymentGroupId")
raise 'Deployment Spec has no DeploymentGroupName' unless property_set?(data, "DeploymentGroupName")
raise 'Deployment Spec has no ApplicationName' unless property_set?(data, "ApplicationName")
@application_name = data["ApplicationName"]
@deployment_group_name = data["DeploymentGroupName"]
if data["DeploymentId"].start_with?("arn:")
@deployment_id = getDeploymentIdFromArn(data["DeploymentId"])
else
@deployment_id = data["DeploymentId"]
end
@deployment_group_id = data["DeploymentGroupId"]
@deployment_creator = data["DeploymentCreator"] || "user"
@deployment_type = data["DeploymentType"] || "IN_PLACE"
if property_set?(data, "AppSpecFilename")
@app_spec_path = data["AppSpecFilename"]
else
@app_spec_path = "appspec.yml"
end
raise 'Must specify a revison' unless data["Revision"]
@revision_source = data["Revision"]["RevisionType"]
raise 'Must specify a revision source' unless @revision_source
@file_exists_behavior = DEFAULT_FILE_EXISTS_BEHAVIOR
if property_set?(data, "AgentActionOverrides")
agentActionsOverrides = data["AgentActionOverrides"]
if property_set?(agentActionsOverrides, "AgentOverrides")
agentActionsOverridesMap = agentActionsOverrides["AgentOverrides"]
if property_set?(agentActionsOverridesMap, "FileExistsBehavior")
@file_exists_behavior = agentActionsOverridesMap["FileExistsBehavior"].upcase
end
end
end
if property_set?(data, 'AllPossibleLifecycleEvents')
@all_possible_lifecycle_events = data['AllPossibleLifecycleEvents']
end
case @revision_source
when 'S3'
@revision = data["Revision"]["S3Revision"]
raise 'S3Revision in Deployment Spec must specify Bucket, Key and BundleType' unless valid_s3_revision?(@revision)
raise 'BundleType in S3Revision must be tar, tgz or zip' unless valid_bundle_type?(@revision)
@bucket = @revision["Bucket"]
@key = @revision["Key"]
@bundle_type = @revision["BundleType"]
@version = @revision["Version"]
@etag = @revision["ETag"]
when 'GitHub'
@revision = data["Revision"]["GitHubRevision"]
raise 'GitHubRevision in Deployment Spec must specify Account, Repository and CommitId' unless valid_github_revision?(revision)
@external_account = revision["Account"]
@repository = revision["Repository"]
@commit_id = revision["CommitId"]
@external_auth_token = data["GitHubAccessToken"]
@anonymous = @external_auth_token.nil?
@bundle_type = @revision["BundleType"]
when 'Local File', 'Local Directory'
@revision = data["Revision"]["LocalRevision"]
raise 'LocalRevision in Deployment Spec must specify Location and BundleType' unless valid_local_revision?(revision)
raise 'BundleType in LocalRevision must be tar, tgz, zip, or directory' unless valid_local_bundle_type?(@revision)
@local_location = @revision["Location"]
@bundle_type = @revision["BundleType"]
else
raise 'Exactly one of S3Revision, GitHubRevision, or LocalRevision must be specified'
end
end