Class: AppBuilder::Config
- Inherits:
-
Object
- Object
- AppBuilder::Config
- Defined in:
- lib/app_builder/config.rb
Constant Summary collapse
- CHANGEABLE_PARAMETERS =
[ :build_id, # default: timestamp :project_name, # default: repository name :remote_repository, # default: remote origin :branch, # default: TARGET_BRANCH or master :revision, # default: commit hash :resource_type, # :s3 or :http or :https (default: :s3) :upload_id, # bucket name or remote host (default: none) :remote_app_home_base, # default: /var/www :keep_release, # default: 5 :logger, # default: AppBuilder::Logger # hooks :before_archive, :after_archive, :before_build, :after_build, :before_upload, :after_upload, # source :remote_src_path, # default: assets # manifest :manifest_template_path, # default: lib/app_builder/template/manifest.yml.erb in this repository :remote_manifest_path, # default: manifests # Only use when upload to S3 :region, :access_key_id, :secret_access_key, # Only use when upload with scp :resource_host, :resource_user, :resource_ssh_options, :resource_document_root, ].freeze
- PARAMETERS =
[ :working_path, :repo_path, :archive_path, :build_path, :builded_src_path, :builded_manifest_path, :revision_path, :remote_src_file, :remote_manifest_file, :src_url, :manifest_url, :remote_app_home, ].concat(CHANGEABLE_PARAMETERS).freeze
Instance Method Summary collapse
- #archive_path ⇒ Object
- #build_name ⇒ Object
- #build_path ⇒ Object
- #builded_manifest_path ⇒ Object
- #builded_src_path ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #manifest_name ⇒ Object
- #manifest_url ⇒ Object
- #merge(params) ⇒ Object
- #remote_app_home ⇒ Object
- #remote_manifest_file ⇒ Object
- #remote_src_file ⇒ Object
- #repo_path ⇒ Object
- #reset ⇒ Object
- #revision_path ⇒ Object
- #src_url ⇒ Object
- #uploaded_url(path) ⇒ Object
- #working_path ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
59 60 61 62 |
# File 'lib/app_builder/config.rb', line 59 def initialize( = {}) reset merge() end |
Instance Method Details
#archive_path ⇒ Object
87 88 89 |
# File 'lib/app_builder/config.rb', line 87 def archive_path File.join(working_path, "archive", build_id) end |
#build_name ⇒ Object
71 72 73 |
# File 'lib/app_builder/config.rb', line 71 def build_name "#{build_id}.tar.gz" end |
#build_path ⇒ Object
91 92 93 |
# File 'lib/app_builder/config.rb', line 91 def build_path File.join(working_path, "build", build_id) end |
#builded_manifest_path ⇒ Object
99 100 101 |
# File 'lib/app_builder/config.rb', line 99 def builded_manifest_path File.join(build_path, manifest_name) end |
#builded_src_path ⇒ Object
95 96 97 |
# File 'lib/app_builder/config.rb', line 95 def builded_src_path File.join(build_path, build_name) end |
#manifest_name ⇒ Object
75 76 77 |
# File 'lib/app_builder/config.rb', line 75 def manifest_name "#{build_id}.yml" end |
#manifest_url ⇒ Object
119 120 121 |
# File 'lib/app_builder/config.rb', line 119 def manifest_url uploaded_url(remote_manifest_file) end |
#merge(params) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/app_builder/config.rb', line 64 def merge(params) params.each do |key, value| self.send("#{key}=", value) end self end |
#remote_app_home ⇒ Object
123 124 125 |
# File 'lib/app_builder/config.rb', line 123 def remote_app_home File.join(remote_app_home_base, project_name) end |
#remote_manifest_file ⇒ Object
111 112 113 |
# File 'lib/app_builder/config.rb', line 111 def remote_manifest_file File.join(remote_manifest_path, manifest_name) end |
#remote_src_file ⇒ Object
107 108 109 |
# File 'lib/app_builder/config.rb', line 107 def remote_src_file File.join(remote_src_path, build_name) end |
#repo_path ⇒ Object
83 84 85 |
# File 'lib/app_builder/config.rb', line 83 def repo_path File.join(working_path, "repo") end |
#reset ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/app_builder/config.rb', line 131 def reset @build_id = Time.now.strftime("%Y%m%d%H%M%S") @project_name = File.basename(`git rev-parse --show-toplevel`.chomp) @remote_repository = `git remote get-url origin`.chomp @branch = ENV.fetch("TARGET_BRANCH", `git symbolic-ref --short HEAD`.chomp) @revision = `git rev-parse #{branch}`.chomp @remote_src_path = "assets" @manifest_template_path = File.("template/manifest.yml.erb", __dir__) @remote_manifest_path = "manifests" @resource_user = ENV.fetch("USER", nil) @resource_ssh_options = {} @remote_app_home_base = "/var/www" @logger = Logger.new(STDOUT) @resource_type = :s3 @keep_release = 5 # for upload to S3 (from `.aws/config` and `.aws/credentials`) @region = ENV.fetch("AWS_DEFAULT_REGION", aws_config("region") || "ap-northeast-1") @access_key_id = ENV.fetch("AWS_ACCESS_KEY_ID", aws_credential("aws_access_key_id")) @secret_access_key = ENV.fetch("AWS_SECRET_ACCESS_KEY", aws_credential("aws_secret_access_key")) initialize_hooks end |
#revision_path ⇒ Object
103 104 105 |
# File 'lib/app_builder/config.rb', line 103 def revision_path File.join(archive_path, "revision.yml") end |
#src_url ⇒ Object
115 116 117 |
# File 'lib/app_builder/config.rb', line 115 def src_url uploaded_url(remote_src_file) end |
#uploaded_url(path) ⇒ Object
127 128 129 |
# File 'lib/app_builder/config.rb', line 127 def uploaded_url(path) "#{resource_type.to_s}://#{File.join(upload_id, path)}" end |
#working_path ⇒ Object
79 80 81 |
# File 'lib/app_builder/config.rb', line 79 def working_path File.join("/var/tmp", project_name) end |