gearship 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/gearship.gemspec +1 -1
  3. data/lib/gearship/cli.rb +39 -37
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 130d1bc5e651c3a5863a8fefa6b14844af7aca2d
4
- data.tar.gz: 279b8db270159a6969a99f0c220f3398004ae356
3
+ metadata.gz: 3893ba4345cc9005374a5568012a3ec5ccb5b07c
4
+ data.tar.gz: d725cd188273a288e3f406ce9ea335d11717cc6a
5
5
  SHA512:
6
- metadata.gz: 6b05625cfe8b73be24ffbcdcdb1fbba612f626f08afd9957488217708965eb92501d404961dfa6bf67cd922fdcaf63b6493f2e2d73b79c1e03b8fdff0178b570
7
- data.tar.gz: 26461c3a8ddd5b2d7a7b8c6e061dc5941adb2824b00be82dbc6c9fda9905f1a19ecfbcdadd0521571798440a448f512ac1624540853b2a072a4d500c70bd09c7
6
+ metadata.gz: fd11e99fe1e66d4753ab4a1fe5615800375f563e73d082d60bd618c6d8a3f682c9042828e2483e964ad4ff59357d64dbb5a4eba1ea789325bbfd6d0d26be69ae
7
+ data.tar.gz: b2f73a0b0a336514bcb9f121b4cb3e48fb20f8a5ac668ceb326e57cd9ecd032a08572640b14e44a95f490de4c3c432d065090be93279c7508c2eaa8b74f5133b
data/gearship.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'gearship'
5
- spec.version = '0.2.2'
5
+ spec.version = '0.2.3'
6
6
  spec.authors = ['Leonas']
7
7
  spec.email = ['leonas@leonas.io']
8
8
  spec.homepage = 'http://github.com/leonas/gearship'
data/lib/gearship/cli.rb CHANGED
@@ -8,23 +8,18 @@ module Gearship
8
8
 
9
9
  desc 'init', 'Initialize gearship project'
10
10
  def init(project = 'gearship')
11
- do_init(project)
11
+ init!(project)
12
12
  end
13
13
 
14
- desc 'go [mission] [--sudo]', 'Send gearship on a mission'
14
+ desc 'go [mission] [--sudo]', 'Send gearship on a mission with ssh.'
15
15
  method_options :sudo => false
16
16
  def go(target, *args)
17
- do_go(target, *args)
17
+ go!(target, *args)
18
18
  end
19
-
19
+
20
20
  desc 'compile', 'Compile gearship project for debugging'
21
21
  def compile(mission = nil)
22
- do_compile(mission)
23
- end
24
-
25
- desc 'version', 'Show gearship version'
26
- def version
27
- puts Gem.loaded_specs['gearship'].version.to_s
22
+ compile!(mission)
28
23
  end
29
24
 
30
25
  no_tasks do
@@ -34,7 +29,7 @@ module Gearship
34
29
  File.expand_path('../../',__FILE__)
35
30
  end
36
31
 
37
- def do_init(project)
32
+ def init!(project)
38
33
  copy_file 'templates/.dockerignore', ".dockerignore"
39
34
  copy_file 'templates/.gitignore', "#{project}/.gitignore"
40
35
  copy_file 'templates/gearship.yml', "#{project}/gearship.yml"
@@ -54,33 +49,39 @@ module Gearship
54
49
  copy_file 'templates/cargo/sample.conf', "#{project}/cargo/sample.conf"
55
50
  end
56
51
 
57
- def do_go(*args)
52
+ def go!(*args)
58
53
  mission = args[0]
54
+ compile!(mission)
55
+ sudo = 'sudo ' if options.sudo?
59
56
 
60
- do_compile(mission)
57
+ if mission.include? 'local'
58
+ local_commands = <<-EOS
59
+ bash compiled/gearship.sh
60
+ EOS
61
+ else
62
+
63
+ user, host, port = parse_target(@config['attributes']['ssh_target'])
64
+ endpoint = "#{user}@#{host}"
65
+
66
+ # Remove server key from known hosts to avoid mismatch errors when VMs change.
67
+ `ssh-keygen -R #{host} 2> /dev/null`
68
+
69
+ remote_commands = <<-EOS
70
+ rm -rf ~/gearship &&
71
+ mkdir ~/gearship &&
72
+ cd ~/gearship &&
73
+ tar xz &&
74
+ #{sudo}bash gearship.sh
75
+ EOS
76
+
77
+ remote_commands.strip! << ' && rm -rf ~/gearship' if @config['preferences'] and @config['preferences']['erase_remote_folder']
78
+
79
+ local_commands = <<-EOS
80
+ cd compiled
81
+ tar cz . | ssh -o 'StrictHostKeyChecking no' #{endpoint} -p #{port} '#{remote_commands}'
82
+ EOS
83
+ end
61
84
 
62
- sudo = 'sudo ' if options.sudo?
63
- user, host, port = parse_target(@config['attributes']['ssh_target'])
64
- endpoint = "#{user}@#{host}"
65
-
66
- # Remove server key from known hosts to avoid mismatch errors when VMs change.
67
- `ssh-keygen -R #{host} 2> /dev/null`
68
-
69
- remote_commands = <<-EOS
70
- rm -rf ~/gearship &&
71
- mkdir ~/gearship &&
72
- cd ~/gearship &&
73
- tar xz &&
74
- #{sudo}bash gearship.sh
75
- EOS
76
-
77
- remote_commands.strip! << ' && rm -rf ~/gearship' if @config['preferences'] and @config['preferences']['erase_remote_folder']
78
-
79
- local_commands = <<-EOS
80
- cd compiled
81
- tar cz . | ssh -o 'StrictHostKeyChecking no' #{endpoint} -p #{port} '#{remote_commands}'
82
- EOS
83
-
84
85
  Open3.popen3(local_commands) do |stdin, stdout, stderr|
85
86
  stdin.close
86
87
  t = Thread.new do
@@ -94,8 +95,9 @@ module Gearship
94
95
  t.join
95
96
  end
96
97
  end
97
-
98
- def do_compile(mission)
98
+
99
+
100
+ def compile!(mission)
99
101
  abort_with 'You must be in the gearship folder' unless File.exists?('gearship.yml')
100
102
  abort_with "#{mission} doesn't exist!" if mission and !File.exists?("missions/#{mission}.sh")
101
103
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gearship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonas