Class: Capistrano::NetStorage::S3::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/net_storage/s3/config.rb

Instance Method Summary collapse

Instance Method Details

#archive_urlURI::Generic

S3 URL of the application archive for current deployment

Returns:

  • (URI::Generic)


110
111
112
113
114
115
116
117
118
# File 'lib/capistrano/net_storage/s3/config.rb', line 110

def archive_url
  @archive_url ||= begin
    unless revision = fetch(:current_revision)
      raise Capistrano::NetStorage::Error, ':current_revision is not set!'
    end
    archive_file = "#{revision}.#{Capistrano::NetStorage.config.archive_suffix}"
    archives_url + archive_file
  end
end

#archives_directoryString

Directory path on S3 bucket for application archives

Returns:

  • (String)


88
89
90
91
92
93
94
# File 'lib/capistrano/net_storage/s3/config.rb', line 88

def archives_directory
  # append '/' in case missing
  @archives_directory ||= begin
    dir = fetch(:net_storage_s3_archives_directory)
    dir.sub(%r{[^/]\Z}, '\&/') if dir
  end
end

#archives_urlURI::Generic

S3 URL which contains application archives

Returns:

  • (URI::Generic)


98
99
100
101
102
103
104
105
106
# File 'lib/capistrano/net_storage/s3/config.rb', line 98

def archives_url
  @archives_url ||= begin
    if archives_directory
      bucket_url + archives_directory
    else
      bucket_url
    end
  end
end

#aws_access_key_idString

Returns AWS Access Key ID.

Returns:

  • (String)

    AWS Access Key ID



25
26
27
# File 'lib/capistrano/net_storage/s3/config.rb', line 25

def aws_access_key_id
  @aws_access_key_id ||= fetch(:net_storage_s3_aws_access_key_id, ENV['AWS_ACCESS_KEY_ID'])
end

#aws_config_fileObject

AWS Config File



51
52
53
# File 'lib/capistrano/net_storage/s3/config.rb', line 51

def aws_config_file
  @aws_config_file ||= fetch(:net_storage_s3_aws_config_file, ENV['AWS_CONFIG_FILE'])
end

#aws_environmentsHash

Returns AWS environment variables.

Returns:

  • (Hash)

    AWS environment variables



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/capistrano/net_storage/s3/config.rb', line 56

def aws_environments
  @aws_environments ||= begin
    environments = {}
    environments[:aws_config_file]       = aws_config_file       if aws_config_file
    environments[:aws_default_profile]   = aws_profile           if aws_profile
    environments[:aws_default_region]    = aws_region            if aws_region
    environments[:aws_access_key_id]     = aws_access_key_id     if aws_access_key_id
    environments[:aws_secret_access_key] = aws_secret_access_key if aws_secret_access_key
    environments[:aws_session_token]     = aws_session_token     if aws_session_token
    environments
  end
end

#aws_profileString

Returns AWS Profile.

Returns:

  • (String)

    AWS Profile



46
47
48
# File 'lib/capistrano/net_storage/s3/config.rb', line 46

def aws_profile
  @aws_profile ||= fetch(:net_storage_s3_aws_profile, ENV['AWS_DEFAULT_PROFILE'])
end

#aws_regionString

Returns AWS Region.

Returns:

  • (String)

    AWS Region



41
42
43
# File 'lib/capistrano/net_storage/s3/config.rb', line 41

def aws_region
  @aws_region ||= fetch(:net_storage_s3_aws_region, ENV['AWS_DEFAULT_REGION'])
end

#aws_secret_access_keyString

Returns AWS Secret Access Key.

Returns:

  • (String)

    AWS Secret Access Key



30
31
32
33
# File 'lib/capistrano/net_storage/s3/config.rb', line 30

def aws_secret_access_key
  @aws_secret_access_key ||= fetch(:net_storage_s3_aws_secret_access_key)
  @aws_secret_access_key ||= ENV['AWS_SECRET_ACCESS_KEY']
end

#aws_session_tokenString

Returns AWS Session Token.

Returns:

  • (String)

    AWS Session Token



36
37
38
# File 'lib/capistrano/net_storage/s3/config.rb', line 36

def aws_session_token
  @aws_session_token ||= fetch(:net_storage_s3_aws_session_token, ENV['AWS_SESSION_TOKEN'])
end

#brokerCapistrano::NetStorage::S3::Broker::Base

Broker object for transport operations



11
12
13
14
15
16
17
18
19
20
# File 'lib/capistrano/net_storage/s3/config.rb', line 11

def broker
  @broker ||= begin
    case fetch(:net_storage_s3_broker, :aws_cli)
    when :aws_cli
      Broker::AwsCLI.new
    else
      raise Capistrano::NetStorage::S3::Error, "No broker defined! #{fetch(:net_storage_s3_broker)}"
    end
  end
end

#bucketString

S3 bucket name via which one transports application archives

Returns:

  • (String)


71
72
73
74
75
76
77
78
# File 'lib/capistrano/net_storage/s3/config.rb', line 71

def bucket
  @bucket ||= begin
    unless bucket = fetch(:net_storage_s3_bucket)
      raise Capistrano::NetStorage::S3::Error, ':net_storage_s3_bucket is not configured!'
    end
    bucket
  end
end

#bucket_urlURI::Generic

S3 bucket URL via which one transports application archives

Returns:

  • (URI::Generic)


82
83
84
# File 'lib/capistrano/net_storage/s3/config.rb', line 82

def bucket_url
  @bucket_url ||= URI.parse("s3://#{bucket}")
end

#max_retryFixnum

Max retrial number for S3 operations

Returns:

  • (Fixnum)


122
123
124
# File 'lib/capistrano/net_storage/s3/config.rb', line 122

def max_retry
  @max_retry ||= fetch(:net_storage_s3_max_retry, 3)
end