capistrano-get_s3 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-get_s3-get_s3.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Lars Fronius
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Capistrano::Get::S3
2
+
3
+ gets codebase as a tar.gz from s3 and allows you to deploy from that.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-get-s3'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-get-s3
18
+
19
+ ## Usage
20
+
21
+ Just add following to your deploy.rb
22
+ ```
23
+ set :scm, :get_s3
24
+ set :aws_access_key_id, 'foo'
25
+ set :aws_secret_access_key, 'bar'
26
+ set :filename, 'my-codebase.tar.gz'
27
+ set :bucket, 'codebase-bucket'
28
+ set :bucket_region, 'EU'
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/capistrano-get_s3/version', __FILE__)
3
+
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "capistrano-get_s3"
7
+ spec.version = Capistrano::Get_S3::VERSION
8
+ spec.authors = ["Lars Fronius"]
9
+ spec.email = ["l.fronius@googlemail.com"]
10
+ spec.description = %q{Introduces a new deployment strategy where we pull the codebase as a tar.gz of an s3 bucket}
11
+ spec.summary = %q{Deploy from S3}
12
+ spec.homepage = "http://github.com/LarsFronius/capistrano-get_s3"
13
+ spec.license = "MIT"
14
+ spec.add_dependency 'capistrano', "< 3.0.0"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,86 @@
1
+ require "capistrano/recipes/deploy/scm/base"
2
+ require "fog"
3
+ require "tempfile"
4
+
5
+ module Capistrano
6
+ module Deploy
7
+ module SCM
8
+ class GetS3 < Base
9
+
10
+ default_command = "tar xvfh"
11
+
12
+ def head
13
+ configuration[:branch] || "current"
14
+ end
15
+
16
+ def query_revision(revision)
17
+ return revision
18
+ end
19
+
20
+ def checkout(revision, destination)
21
+
22
+ tar = command
23
+
24
+ execute = []
25
+ execute << "tmpdir=`mktemp -dt deploy.XXXXXXXX`"
26
+ execute << "cfgfile=`mktemp -t cfg.XXXXXXXX`"
27
+ s3cmd.split("\n").each do |s3string|
28
+ execute << printf_to_cfg(s3string)
29
+ end
30
+ execute << "mkdir -p #{destination}"
31
+ execute << "s3cmd -c $cfgfile get s3://#{configuration[:bucket]}/#{configuration[:filename]} $tmpdir/#{configuration[:filename]}"
32
+ execute << "tar xvfh $tmpdir/#{configuration[:filename]} -C #{destination}"
33
+ execute << "rm -rf $tmpdir $cfgfile"
34
+
35
+ execute.join(' && ')
36
+
37
+ end
38
+
39
+ def printf_to_cfg(s3_cld)
40
+ return 'printf "%b\n" "' + s3_cld + '" >> $cfgfile'
41
+ end
42
+
43
+ def s3cmd
44
+ "[default]
45
+ access_key = #{configuration[:aws_access_key_id]}
46
+ bucket_location = #{configuration[:bucket_region] || "EU"}
47
+ cloudfront_host = cloudfront.amazonaws.com
48
+ cloudfront_resource = /2010-07-15/distribution
49
+ default_mime_type = binary/octet-stream
50
+ delete_removed = False
51
+ dry_run = False
52
+ encoding = UTF-8
53
+ encrypt = False
54
+ follow_symlinks = False
55
+ force = False
56
+ get_continue = False
57
+ gpg_command = /usr/bin/gpg
58
+ gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
59
+ gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
60
+ gpg_passphrase =
61
+ guess_mime_type = True
62
+ host_base = s3.amazonaws.com
63
+ host_bucket = %(bucket)s.s3.amazonaws.com
64
+ human_readable_sizes = False
65
+ list_md5 = False
66
+ log_target_prefix =
67
+ preserve_attrs = True
68
+ progress_meter = True
69
+ proxy_host =
70
+ proxy_port = 0
71
+ recursive = False
72
+ recv_chunk = 4096
73
+ reduced_redundancy = False
74
+ secret_key = #{configuration[:aws_secret_access_key]}
75
+ send_chunk = 4096
76
+ simpledb_host = sdb.amazonaws.com
77
+ skip_existing = False
78
+ socket_timeout = 10
79
+ urlencoding_mode = normal
80
+ use_https = True
81
+ verbosity = WARNING"
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Get_S3
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require "capistrano-get_s3/version"
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-get_s3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Lars Fronius
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-10-16 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: capistrano
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - <
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 3
32
+ - 0
33
+ - 0
34
+ version: 3.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 9
46
+ segments:
47
+ - 1
48
+ - 3
49
+ version: "1.3"
50
+ type: :development
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: rake
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :development
65
+ version_requirements: *id003
66
+ description: Introduces a new deployment strategy where we pull the codebase as a tar.gz of an s3 bucket
67
+ email:
68
+ - l.fronius@googlemail.com
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files: []
74
+
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - capistrano-get_s3.gemspec
82
+ - lib/capistrano-get_s3.rb
83
+ - lib/capistrano-get_s3/version.rb
84
+ - lib/capistrano/recipes/deploy/scm/get_s3.rb
85
+ has_rdoc: true
86
+ homepage: http://github.com/LarsFronius/capistrano-get_s3
87
+ licenses:
88
+ - MIT
89
+ post_install_message:
90
+ rdoc_options: []
91
+
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ requirements: []
113
+
114
+ rubyforge_project:
115
+ rubygems_version: 1.6.2
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: Deploy from S3
119
+ test_files: []
120
+