peas-cli 0.1.0 → 0.1.1
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/VERSION +1 -1
- data/bin/peas +5 -0
- data/lib/peas/api.rb +5 -0
- data/lib/peas/commands/logs.rb +13 -0
- data/lib/peas/config.rb +13 -1
- data/peas-cli.gemspec +4 -3
- data/spec/cli_spec.rb +18 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e21b1eaec8ee7ce0d7a7b76dbf2a0912c6eaa3c
|
4
|
+
data.tar.gz: 13c9d9ce95cfbebcea8cfb787ca9e0661f3c444a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7405ef69c589de7140e5c463356b77d06f3836bd3788eca36401c74465ab6ced6ddc534f8bf362e69f26be829976d3d03466bb3511aa3c9a03ed491cd98064df
|
7
|
+
data.tar.gz: e377db4f59cc014a5cd10363d83d2235d11c55ea25c1cca358b8e833f68202d29283ba38b514acb75141239ded9f5f2f24cc311eb2f623a61699a3e8f755cf7f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/bin/peas
CHANGED
data/lib/peas/api.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
desc 'Show logs for an app'
|
2
|
+
command :logs do |c|
|
3
|
+
c.action do |global_options, options, args|
|
4
|
+
socket = API.switchboard_connection
|
5
|
+
socket.puts "stream_logs.#{Git.first_sha}"
|
6
|
+
begin
|
7
|
+
while line = socket.gets
|
8
|
+
puts line
|
9
|
+
end
|
10
|
+
rescue Interrupt, Errno::ECONNRESET
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/peas/config.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module Peas
|
2
2
|
|
3
|
+
# The port for Peas' Switchboard socket server
|
4
|
+
SWITCHBOARD_PORT = ENV['SWITCHBOARD_PORT'] || 9345
|
5
|
+
|
3
6
|
def self.config_file
|
4
7
|
"#{ENV['HOME']}/.peas"
|
5
8
|
end
|
@@ -14,13 +17,22 @@ module Peas
|
|
14
17
|
|
15
18
|
# Hierarchy of sources for the Peas API domain
|
16
19
|
def self.api_domain
|
17
|
-
if ENV['PEAS_API_ENDPOINT']
|
20
|
+
domain = if ENV['PEAS_API_ENDPOINT']
|
18
21
|
ENV['PEAS_API_ENDPOINT']
|
19
22
|
elsif Peas.config['domain']
|
20
23
|
Peas.config['domain']
|
21
24
|
else
|
22
25
|
'localhost:4000'
|
23
26
|
end
|
27
|
+
unless domain[/\Ahttp:\/\//] || domain[/\Ahttps:\/\//]
|
28
|
+
domain = "http://#{domain}"
|
29
|
+
else
|
30
|
+
domain
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.host
|
35
|
+
URI.parse(Peas.api_domain).host
|
24
36
|
end
|
25
37
|
|
26
38
|
def self.error_message string
|
data/peas-cli.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: peas-cli 0.1.
|
5
|
+
# stub: peas-cli 0.1.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "peas-cli"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Tom Buckley-Houston"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-06-14"
|
15
15
|
s.description = "Peas is an open source Heroku-style PaaS written in Ruby and using Docker"
|
16
16
|
s.email = "tom@tombh.co.uk"
|
17
17
|
s.executables = ["peas", "peas-dev"]
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/peas/commands/admin.rb",
|
32
32
|
"lib/peas/commands/app.rb",
|
33
33
|
"lib/peas/commands/config.rb",
|
34
|
+
"lib/peas/commands/logs.rb",
|
34
35
|
"lib/peas/config.rb",
|
35
36
|
"lib/peas/git.rb",
|
36
37
|
"lib/peas/version.rb",
|
data/spec/cli_spec.rb
CHANGED
@@ -57,7 +57,7 @@ describe 'Peas CLI' do
|
|
57
57
|
expect(output).to eq "scaling\n"
|
58
58
|
end
|
59
59
|
|
60
|
-
describe 'Config' do
|
60
|
+
describe 'Config ENV vars' do
|
61
61
|
it 'should set config for an app' do
|
62
62
|
stub_request(:put, TEST_DOMAIN + '/app/fakesha/config?vars=%7B%22FOO%22:%22BAR%22%7D')
|
63
63
|
.to_return(body: response_mock("{'FOO' => 'BAR'}"))
|
@@ -81,6 +81,23 @@ describe 'Peas CLI' do
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
describe 'Logs' do
|
85
|
+
it 'should stream logs' do
|
86
|
+
stub_const 'Peas::SWITCHBOARD_PORT', 79345
|
87
|
+
Thread.new do
|
88
|
+
server = TCPServer.new Peas.host, Peas::SWITCHBOARD_PORT
|
89
|
+
if peer = server.accept
|
90
|
+
peer.puts "Here's ya logs"
|
91
|
+
peer.puts "MOAR logs"
|
92
|
+
peer.close
|
93
|
+
end
|
94
|
+
end
|
95
|
+
sleep 0.3
|
96
|
+
output = cli %w(logs)
|
97
|
+
expect(output).to eq "Here's ya logs\nMOAR logs\n"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
84
101
|
it 'should retrieve and output a long-running command' do
|
85
102
|
stub_request(:get, /deploy/).to_return(body: '{"job": "123"}')
|
86
103
|
stub_request(:get, /status/).to_return(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peas-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Buckley-Houston
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/peas/commands/admin.rb
|
89
89
|
- lib/peas/commands/app.rb
|
90
90
|
- lib/peas/commands/config.rb
|
91
|
+
- lib/peas/commands/logs.rb
|
91
92
|
- lib/peas/config.rb
|
92
93
|
- lib/peas/git.rb
|
93
94
|
- lib/peas/version.rb
|