gisha 0.0.10 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +28 -0
- data/Gemfile.lock +81 -0
- data/Rakefile +1 -1
- data/bin/gisha +3 -0
- data/lib/gisha/cli.rb +0 -46
- data/lib/gisha/commands/deploy.rb +19 -7
- data/lib/gisha/commands/receive.rb +1 -1
- data/lib/gisha/version.rb +1 -1
- data/lib/gisha.rb +1 -2
- metadata +4 -20
- data/.gitignore +0 -17
- data/gisha.gemspec +0 -28
- data/hooks/update +0 -18
- data/lib/gisha/commands/key.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2b2c495bbde5ba6ea9d3387f75753de05844422
|
4
|
+
data.tar.gz: 44de1301df26889574ec4535522de696dc34444b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb97f5e10f5e831325c5057fba8d217c882d9b60f1899924184870f42e7f054571c7f137ced67d484b0fa3bfc251e9d6857e0a57c56efeff72a412f4ef43e4e
|
7
|
+
data.tar.gz: 3e4f7a3980c42c068a48d4392d846af59fda6e3f8b076cf0670e48ba0dd20187e04580a6ecb2cfe97271a8a8ee141b6b4020a2b2715afc48efaaf9c813fcf54c
|
data/Dockerfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# spass/receiver
|
2
|
+
#
|
3
|
+
#
|
4
|
+
|
5
|
+
FROM spass/base:latest
|
6
|
+
|
7
|
+
# Set the env variables
|
8
|
+
ENV GITHOME /home/git
|
9
|
+
ENV GITUSER git
|
10
|
+
|
11
|
+
RUN apt-get update -y
|
12
|
+
RUN apt-get install --no-install-recommends -qy cmake pkg-config libgit2-dev
|
13
|
+
|
14
|
+
RUN rm -f /etc/ssh/ssh_host_*
|
15
|
+
RUN dpkg-reconfigure openssh-server 2> /dev/null
|
16
|
+
RUN mkdir -p /var/run/sshd
|
17
|
+
|
18
|
+
# configure git user
|
19
|
+
RUN useradd -create-home --home $GITHOME --shell /bin/bash --password "`</dev/urandom tr -dc A-Za-z0-9 | head -c20`" $GITUSER
|
20
|
+
RUN mkdir -p $GITHOME/.ssh && chown git:git $GITHOME/.ssh && chmod 700 $GITHOME/.ssh
|
21
|
+
|
22
|
+
RUN chown -R $GITUSER:$GITUSER $GITHOME
|
23
|
+
|
24
|
+
RUN gem install gisha
|
25
|
+
|
26
|
+
EXPOSE 22
|
27
|
+
|
28
|
+
CMD /usr/sbin/sshd -D
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gisha (0.1.0)
|
5
|
+
clamp
|
6
|
+
dotenv
|
7
|
+
em-eventsource
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.3.6)
|
13
|
+
clamp (0.6.3)
|
14
|
+
cookiejar (0.3.2)
|
15
|
+
coveralls (0.7.2)
|
16
|
+
multi_json (~> 1.3)
|
17
|
+
rest-client (= 1.6.7)
|
18
|
+
simplecov (>= 0.7)
|
19
|
+
term-ansicolor (= 1.2.2)
|
20
|
+
thor (= 0.18.1)
|
21
|
+
crack (0.4.2)
|
22
|
+
safe_yaml (~> 1.0.0)
|
23
|
+
diff-lcs (1.2.5)
|
24
|
+
docile (1.1.5)
|
25
|
+
dotenv (1.0.2)
|
26
|
+
em-eventsource (0.2.0)
|
27
|
+
em-http-request (>= 1.0.0)
|
28
|
+
eventmachine (>= 1.0.0.beta3)
|
29
|
+
em-http-request (1.1.2)
|
30
|
+
addressable (>= 2.3.4)
|
31
|
+
cookiejar
|
32
|
+
em-socksify (>= 0.3)
|
33
|
+
eventmachine (>= 1.0.3)
|
34
|
+
http_parser.rb (>= 0.6.0)
|
35
|
+
em-socksify (0.3.0)
|
36
|
+
eventmachine (>= 1.0.0.beta.4)
|
37
|
+
eventmachine (1.0.7)
|
38
|
+
http_parser.rb (0.6.0)
|
39
|
+
mime-types (2.4.3)
|
40
|
+
multi_json (1.10.1)
|
41
|
+
rake (10.1.0)
|
42
|
+
rest-client (1.6.7)
|
43
|
+
mime-types (>= 1.16)
|
44
|
+
rspec (3.1.0)
|
45
|
+
rspec-core (~> 3.1.0)
|
46
|
+
rspec-expectations (~> 3.1.0)
|
47
|
+
rspec-mocks (~> 3.1.0)
|
48
|
+
rspec-core (3.1.7)
|
49
|
+
rspec-support (~> 3.1.0)
|
50
|
+
rspec-expectations (3.1.2)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.1.0)
|
53
|
+
rspec-mocks (3.1.3)
|
54
|
+
rspec-support (~> 3.1.0)
|
55
|
+
rspec-support (3.1.2)
|
56
|
+
safe_yaml (1.0.4)
|
57
|
+
simplecov (0.9.1)
|
58
|
+
docile (~> 1.1.0)
|
59
|
+
multi_json (~> 1.0)
|
60
|
+
simplecov-html (~> 0.8.0)
|
61
|
+
simplecov-html (0.8.0)
|
62
|
+
term-ansicolor (1.2.2)
|
63
|
+
tins (~> 0.8)
|
64
|
+
thor (0.18.1)
|
65
|
+
tins (0.13.2)
|
66
|
+
vcr (2.9.3)
|
67
|
+
webmock (1.20.4)
|
68
|
+
addressable (>= 2.3.6)
|
69
|
+
crack (>= 0.3.2)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
bundler (~> 1.5)
|
76
|
+
coveralls
|
77
|
+
gisha!
|
78
|
+
rake
|
79
|
+
rspec
|
80
|
+
vcr
|
81
|
+
webmock
|
data/Rakefile
CHANGED
data/bin/gisha
CHANGED
data/lib/gisha/cli.rb
CHANGED
@@ -14,46 +14,6 @@ module Gisha
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
class AddKeyCommand < Clamp::Command
|
18
|
-
parameter 'ID', 'id to identify the key'
|
19
|
-
parameter 'KEY', 'public key that was provided to the server'
|
20
|
-
parameter 'AUTH_FILE', 'file containing public keys for public key authentication'
|
21
|
-
|
22
|
-
def execute
|
23
|
-
Commands::Key.new(auth_file, id, key).add
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
class DeleleteKeyCommand < Clamp::Command
|
29
|
-
parameter 'ID', 'id to identify the key'
|
30
|
-
parameter 'AUTH_FILE', 'file containing public keys for public key authentication;'
|
31
|
-
|
32
|
-
def execute
|
33
|
-
Commands::Key.new(auth_file, id).del
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class CreateRepositoryCommand < Clamp::Command
|
38
|
-
parameter 'PATH', 'path to create repository'
|
39
|
-
|
40
|
-
def execute
|
41
|
-
Rugged::Repository.init_at(path, :bare)
|
42
|
-
FileUtils.cp("#{root_path}/hooks/update", "#{path}/hooks")
|
43
|
-
end
|
44
|
-
|
45
|
-
def root_path
|
46
|
-
@root_path ||= File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class DeleteRepositoryCommand < Clamp::Command
|
51
|
-
parameter 'PATH', 'path to delete repository'
|
52
|
-
|
53
|
-
def execute
|
54
|
-
FileUtils.rm_rf(path)
|
55
|
-
end
|
56
|
-
end
|
57
17
|
|
58
18
|
class DeployCommand < Clamp::Command
|
59
19
|
parameter 'URL', 'url to deploy'
|
@@ -67,12 +27,6 @@ module Gisha
|
|
67
27
|
end
|
68
28
|
|
69
29
|
class CLI < Clamp::Command
|
70
|
-
subcommand 'keys:add', 'add new key', AddKeyCommand
|
71
|
-
subcommand 'keys:del', 'delete key', DeleleteKeyCommand
|
72
|
-
|
73
|
-
subcommand 'repositories:create', 'create repository', CreateRepositoryCommand
|
74
|
-
subcommand 'repositories:delete', 'delete repository', DeleteRepositoryCommand
|
75
|
-
|
76
30
|
subcommand 'receive', 'receive what is pushed into the repository', ReceiveCommand
|
77
31
|
subcommand 'deploy', 'deploy to spass', DeployCommand
|
78
32
|
end
|
@@ -2,24 +2,31 @@ require 'em-eventsource'
|
|
2
2
|
|
3
3
|
module Gisha
|
4
4
|
class Commands::Deploy
|
5
|
-
attr_accessor :url, :key_id, :
|
5
|
+
attr_accessor :url, :key_id, :app_name, :revision
|
6
6
|
|
7
|
-
def initialize(url, key_id,
|
7
|
+
def initialize(url, key_id, app_name, revision)
|
8
8
|
@url = url
|
9
9
|
@key_id = key_id
|
10
|
-
@
|
10
|
+
@app_name = app_name
|
11
11
|
@revision = revision
|
12
12
|
end
|
13
13
|
|
14
14
|
def exec
|
15
15
|
EM.run do
|
16
|
-
source = EventMachine::EventSource.new(
|
16
|
+
source = EventMachine::EventSource.new(deploy_url)
|
17
17
|
|
18
|
-
source.
|
18
|
+
source.inactivity_timeout = 180
|
19
|
+
|
20
|
+
source.on('start') do |message|
|
21
|
+
write(message)
|
22
|
+
end
|
23
|
+
|
24
|
+
source.on('chunk') do |message|
|
19
25
|
write(message)
|
20
26
|
end
|
21
27
|
|
22
|
-
source.on('
|
28
|
+
source.on('stop') do |message|
|
29
|
+
write(message)
|
23
30
|
source.close
|
24
31
|
EM.stop
|
25
32
|
end
|
@@ -30,6 +37,7 @@ module Gisha
|
|
30
37
|
EM.stop
|
31
38
|
raise ArgumentError, error
|
32
39
|
end
|
40
|
+
|
33
41
|
source.start
|
34
42
|
end
|
35
43
|
|
@@ -37,6 +45,10 @@ module Gisha
|
|
37
45
|
|
38
46
|
private
|
39
47
|
|
48
|
+
def deploy_url
|
49
|
+
"#{url}?key_id=#{key_id}&app_name=#{app_name}&revision=#{revision}"
|
50
|
+
end
|
51
|
+
|
40
52
|
def repo_name
|
41
53
|
repo_path.split('/').last
|
42
54
|
end
|
@@ -46,7 +58,7 @@ module Gisha
|
|
46
58
|
$stdout.sync = true
|
47
59
|
$stdout
|
48
60
|
end
|
49
|
-
@stdout.write
|
61
|
+
@stdout.write msg
|
50
62
|
end
|
51
63
|
|
52
64
|
end
|
data/lib/gisha/version.rb
CHANGED
data/lib/gisha.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gisha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salvatore Ferrucci
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rugged
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: em-eventsource
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,18 +88,16 @@ executables:
|
|
102
88
|
extensions: []
|
103
89
|
extra_rdoc_files: []
|
104
90
|
files:
|
105
|
-
-
|
91
|
+
- Dockerfile
|
106
92
|
- Gemfile
|
93
|
+
- Gemfile.lock
|
107
94
|
- LICENSE.txt
|
108
95
|
- README.md
|
109
96
|
- Rakefile
|
110
97
|
- bin/gisha
|
111
|
-
- gisha.gemspec
|
112
|
-
- hooks/update
|
113
98
|
- lib/gisha.rb
|
114
99
|
- lib/gisha/cli.rb
|
115
100
|
- lib/gisha/commands/deploy.rb
|
116
|
-
- lib/gisha/commands/key.rb
|
117
101
|
- lib/gisha/commands/receive.rb
|
118
102
|
- lib/gisha/version.rb
|
119
103
|
- spec/lib/gisha/commands/receive_spec.rb
|
data/.gitignore
DELETED
data/gisha.gemspec
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'gisha/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'gisha'
|
8
|
-
spec.version = Gisha::VERSION
|
9
|
-
spec.authors = ['Salvatore Ferrucci']
|
10
|
-
spec.email = ['salvatore@algonauti.com']
|
11
|
-
spec.summary = %q{Easily accept and handle arbitrary git pushes}
|
12
|
-
spec.description = %q{Easily accept and handle arbitrary git pushes}
|
13
|
-
spec.homepage = 'https://github.com/algonauti/gisha'
|
14
|
-
spec.license = 'MIT'
|
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_dependency 'dotenv'
|
22
|
-
spec.add_dependency 'clamp'
|
23
|
-
spec.add_dependency 'rugged'
|
24
|
-
spec.add_dependency 'em-eventsource'
|
25
|
-
|
26
|
-
spec.add_development_dependency 'bundler', '~> 1.5'
|
27
|
-
spec.add_development_dependency 'rake'
|
28
|
-
end
|
data/hooks/update
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'dotenv'
|
3
|
-
Dotenv.load('/etc/environment')
|
4
|
-
|
5
|
-
require 'gisha'
|
6
|
-
|
7
|
-
ref_name = ARGV[0]
|
8
|
-
old_revision = ARGV[1]
|
9
|
-
new_revision = ARGV[2]
|
10
|
-
repository_path = Dir.pwd
|
11
|
-
key_id = ENV['KEY_ID']
|
12
|
-
deploy_url = ENV['SPASS_DEPLOY_URL']
|
13
|
-
|
14
|
-
begin
|
15
|
-
Gisha::CLI.run 'gisha', ['deploy', deploy_url, key_id, repository_path, new_revision]
|
16
|
-
rescue
|
17
|
-
exit 1
|
18
|
-
end
|
data/lib/gisha/commands/key.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
module Gisha
|
2
|
-
class Commands::Key
|
3
|
-
attr_reader :auth_file, :id, :key
|
4
|
-
|
5
|
-
def initialize(auth_file, id, key = nil)
|
6
|
-
@auth_file = auth_file
|
7
|
-
@id = id
|
8
|
-
@key = key
|
9
|
-
end
|
10
|
-
|
11
|
-
def add
|
12
|
-
lock do
|
13
|
-
open(auth_file, 'a') { |file| file.puts(key_line) }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def del
|
18
|
-
lock do
|
19
|
-
Tempfile.open('authorized_keys') do |temp|
|
20
|
-
open(auth_file, 'r+') do |current|
|
21
|
-
current.each do |line|
|
22
|
-
temp.puts(line) unless line.include?("gisha receive key-#{id}")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
temp.close
|
26
|
-
FileUtils.cp(temp.path, auth_file)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def key_line
|
35
|
-
auth_line = "command=\"gisha receive key-#{id}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty #{key}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def lock(timeout = 10)
|
39
|
-
File.open(lock_file, "w+") do |f|
|
40
|
-
begin
|
41
|
-
f.flock File::LOCK_EX
|
42
|
-
Timeout::timeout(timeout) { yield }
|
43
|
-
ensure
|
44
|
-
f.flock File::LOCK_UN
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def lock_file
|
50
|
-
@lock_file ||= auth_file + '.lock'
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|