geordi 2.12.1 → 2.12.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '080677a5fee73a4a5ddc02c2f68b5927ec66cb95b328ccbac62abf6aa26d0e19'
4
- data.tar.gz: 78da560700b6bd7e72424fa1d7f5df556e88d2b80e834aaf7582f6012e31d94c
3
+ metadata.gz: 72b80aa5fcd6e4f4bb048f76aac069a7cb99310a3900b933f53c5549e737f52e
4
+ data.tar.gz: 1a0bba5ab27c1759e9b0b5a7f3b79f946596605d903129f332f53f4afb33b324
5
5
  SHA512:
6
- metadata.gz: 10384fad288da0e83e9add107b9b46dcfb83c9f06c777389975127a10d98e94829ffd9414b1607246a31fbfc201d5f732934072ad93e95bb07f28eeac174388e
7
- data.tar.gz: d76fae6a3b79ebf391aa51df3b9348c263e5903afb1dd89b53f99e2893469bac285b5a5f438d5d120cfa60f5938b22d84e882f7b2dd1aa0f6d966e3b82af8f4c
6
+ metadata.gz: aa1a3c5c3bc2278cb10f347d4b94dbea177cb94a65ce27459819cc32f87a82a6cf9408f4e659fdc3d9ca1f005e957f82e0867063d645367aec2019f721159ead
7
+ data.tar.gz: fd92c28543206ac2c61dca8efa017a944612e6ce84fa3f7c513b9b9056e358dc7423dae3163d3954cc56d4abf974620c76c9469a1c2a832f46836923fc0c0da1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (2.12.1)
4
+ geordi (2.12.2)
5
5
  thor (~> 0.18.0)
6
6
 
7
7
  GEM
@@ -13,9 +13,16 @@ GEM
13
13
  contracts (~> 0.9)
14
14
  cucumber (>= 1.3.19)
15
15
  rspec-expectations (>= 2.99)
16
+ axiom-types (0.1.1)
17
+ descendants_tracker (~> 0.0.4)
18
+ ice_nine (~> 0.11.0)
19
+ thread_safe (~> 0.3, >= 0.3.1)
16
20
  builder (3.2.4)
17
21
  childprocess (0.5.9)
18
22
  ffi (~> 1.0, >= 1.0.11)
23
+ coderay (1.1.3)
24
+ coercible (1.0.0)
25
+ descendants_tracker (~> 0.0.1)
19
26
  contracts (0.9)
20
27
  cucumber (1.3.20)
21
28
  builder (>= 2.1.2)
@@ -23,18 +30,40 @@ GEM
23
30
  gherkin (~> 2.12)
24
31
  multi_json (>= 1.7.5, < 2.0)
25
32
  multi_test (>= 0.1.2)
33
+ declarative (0.0.20)
34
+ declarative-option (0.1.0)
35
+ descendants_tracker (0.0.4)
36
+ thread_safe (~> 0.3, >= 0.3.1)
26
37
  diff-lcs (1.2.5)
38
+ equalizer (0.0.11)
39
+ excon (0.78.0)
40
+ faraday (1.1.0)
41
+ multipart-post (>= 1.2, < 3)
42
+ ruby2_keywords
43
+ faraday_middleware (1.0.0)
44
+ faraday (~> 1.0)
27
45
  ffi (1.9.18)
28
46
  gherkin (2.12.2)
29
47
  multi_json (~> 1.3)
30
48
  highline (1.6.21)
49
+ ice_nine (0.11.2)
31
50
  launchy (2.4.3)
32
51
  addressable (~> 2.3)
52
+ method_source (1.0.0)
53
+ mimemagic (0.3.5)
33
54
  multi_json (1.15.0)
34
55
  multi_test (0.1.2)
56
+ multipart-post (2.1.1)
35
57
  parallel (0.5.16)
36
58
  parallel_tests (0.6.18)
37
59
  parallel
60
+ pry (0.13.1)
61
+ coderay (~> 1.1)
62
+ method_source (~> 1.0)
63
+ representable (3.0.4)
64
+ declarative (< 0.1.0)
65
+ declarative-option (< 0.2.0)
66
+ uber (< 0.2.0)
38
67
  rspec-expectations (3.4.0)
39
68
  diff-lcs (>= 1.2.0, < 2.0)
40
69
  rspec-support (~> 3.4.0)
@@ -42,7 +71,25 @@ GEM
42
71
  diff-lcs (>= 1.2.0, < 2.0)
43
72
  rspec-support (~> 3.4.0)
44
73
  rspec-support (3.4.1)
74
+ ruby2_keywords (0.0.2)
45
75
  thor (0.18.1)
76
+ thread_safe (0.3.6)
77
+ tracker_api (1.11.0)
78
+ addressable
79
+ equalizer
80
+ excon
81
+ faraday
82
+ faraday_middleware
83
+ mimemagic
84
+ multi_json
85
+ representable
86
+ virtus
87
+ uber (0.1.0)
88
+ virtus (1.0.5)
89
+ axiom-types (~> 0.1)
90
+ coercible (~> 1.0)
91
+ descendants_tracker (~> 0.0, >= 0.0.3)
92
+ equalizer (~> 0.0, >= 0.0.9)
46
93
 
47
94
  PLATFORMS
48
95
  ruby
@@ -54,7 +101,9 @@ DEPENDENCIES
54
101
  highline
55
102
  launchy
56
103
  parallel_tests
104
+ pry
57
105
  rspec-mocks
106
+ tracker_api
58
107
 
59
108
  BUNDLED WITH
60
109
  1.17.3
@@ -48,7 +48,7 @@ Feature: The docker command
48
48
  And the output should contain "x You need to install docker first"
49
49
 
50
50
 
51
- Scenario: Shell runs docker-compose run main
51
+ Scenario: Shell runs docker-compose run main, and docker-compose stop
52
52
  Given a file named "docker-compose.yml" with:
53
53
  """
54
54
  services:
@@ -60,3 +60,27 @@ Feature: The docker command
60
60
 
61
61
  When I run `geordi docker shell`
62
62
  Then the output should contain "docker-compose run --service-ports -v /path/to/sock:/path/to/sock -e SSH_AUTH_SOCK=/path/to/sock/ssh main"
63
+ Then the output should contain "docker-compose stop"
64
+
65
+
66
+ Scenario: One can attach to a running shell
67
+ Given the docker command finds a running shell "project_main_run_foo"
68
+ And a file named "docker-compose.yml" with:
69
+ """
70
+ services:
71
+ main: foo
72
+ """
73
+
74
+ When I run `geordi docker shell --secondary`
75
+ Then the output should contain "Could not find a running shell"
76
+
77
+
78
+ Scenario: Attaching fails if no shell is running
79
+ Given a file named "docker-compose.yml" with:
80
+ """
81
+ services:
82
+ main: foo
83
+ """
84
+
85
+ When I run `geordi docker shell --secondary`
86
+ Then the output should contain "Could not find a running shell"
@@ -8,3 +8,14 @@ Given(/the docker command cannot find the "(.*?)" binary/) do |command|
8
8
  end
9
9
  end
10
10
  end
11
+
12
+ Given(/^the docker command finds a running shell "(.*?)"$/) do |shell_name|
13
+ require 'geordi/docker'
14
+ expect_any_instance_of(Geordi::Docker).to receive(:mock_parse).at_least(:once).and_wrap_original do |original, *args|
15
+ if args[0] =~ /docker-compose ps/
16
+ "other_shell\nshell_name foo"
17
+ else
18
+ original.call(*args)
19
+ end
20
+ end
21
+ end
@@ -5,9 +5,10 @@ class DockerCLI < Thor
5
5
  end
6
6
 
7
7
  desc 'shell', 'Open a shell in the main docker container for the current project.'
8
+ option :secondary, default: false, :type => :boolean
8
9
  map 'shell' => '_shell'
9
10
  def _shell
10
- docker.shell
11
+ docker.shell(:secondary => options[:secondary])
11
12
  end
12
13
 
13
14
  desc 'vnc', 'Open a vnc viewer connecting to the docker container.'
@@ -18,12 +18,13 @@ module Geordi
18
18
  end
19
19
  end
20
20
 
21
- def shell
21
+ def shell(options = {})
22
22
  check_installation_and_config
23
- command = [:exec, 'docker-compose', 'run', '--service-ports']
24
- command += ssh_agent_forward
25
- command += ['main']
26
- execute(*command)
23
+ if options[:secondary]
24
+ attach_to_running_shell
25
+ else
26
+ run_shell
27
+ end
27
28
  end
28
29
 
29
30
  def vnc
@@ -32,10 +33,32 @@ module Geordi
32
33
 
33
34
  private
34
35
 
36
+ def attach_to_running_shell
37
+ running_containers = execute(:`, 'docker-compose ps').split("\n")
38
+ if (main_container_line = running_containers.grep(/_main_run/).first)
39
+ container_name = main_container_line.split(' ').first
40
+ execute(:system, 'docker', 'exec', '-it', container_name, 'bash')
41
+ else
42
+ fail('Could not find a running shell. Start without --secondary first.')
43
+ end
44
+ end
45
+
46
+ def run_shell
47
+ command = [:system, 'docker-compose', 'run', '--service-ports']
48
+ command += ssh_agent_forward
49
+ command += ['main']
50
+ execute(*command)
51
+ execute(:system, 'docker-compose', 'stop')
52
+ end
53
+
35
54
  def execute(kind, *args)
36
55
  if ENV['GEORDI_TESTING']
37
56
  puts "Stubbed run #{args.join(' ')}"
38
- mock_run(*args)
57
+ if kind == :`
58
+ mock_parse(*args)
59
+ else
60
+ mock_run(*args)
61
+ end
39
62
  else
40
63
  send(kind, *args)
41
64
  end
@@ -46,6 +69,11 @@ module Geordi
46
69
  true
47
70
  end
48
71
 
72
+ def mock_parse(*args)
73
+ # exists just to be stubbed in tests
74
+ 'command output'
75
+ end
76
+
49
77
  def check_installation_and_config
50
78
  unless command_exists?('docker')
51
79
  fail('You need to install docker first with `sudo apt install docker`. After installation please log out and back in to your system once.')
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '2.12.1'
2
+ VERSION = '2.12.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geordi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.1
4
+ version: 2.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch