peas-cli 0.2.0 → 0.2.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 +1 -1
- data/lib/peas/commands/admin.rb +4 -1
- data/lib/peas/commands/app.rb +26 -5
- data/lib/peas/config.rb +3 -0
- data/peas-cli.gemspec +3 -3
- data/spec/cli_spec.rb +16 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 620734d8a5713490dbf9b4f79a669ebba23f0147
|
4
|
+
data.tar.gz: f758e5a9bcf974c88c15a48f26839d6bcdd295fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fa88458e995231523a05e1c9746956cf84f95901e515514c85478e9c63915bf080e6627f4b5b752e46341ddf93713b8a7864c7b0160d7bc1372d31b5ebeaedc
|
7
|
+
data.tar.gz: 33395d9b38d39c016a244010e537e6eafaadce6084e5cd990920128e6aef47c4f9ee165d9100a221f1c343287f4a3f53099b870e30e205e4c074bb73a83d464c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/bin/peas
CHANGED
@@ -35,7 +35,7 @@ end
|
|
35
35
|
on_error do |exception|
|
36
36
|
# Show a custom error message with backtrace if it's not a GLI error
|
37
37
|
if exception.class.to_s.split('::').first != 'GLI'
|
38
|
-
if exception.class
|
38
|
+
if [Errno::ECONNREFUSED, SocketError].include? exception.class
|
39
39
|
Peas.error_message "Couldn't connect to the Peas API. The current endpoint is '#{Peas.api_domain}', make " \
|
40
40
|
"sure it is up and accessible."
|
41
41
|
else
|
data/lib/peas/commands/admin.rb
CHANGED
@@ -20,9 +20,12 @@ command :admin do |admin|
|
|
20
20
|
if args.first == 'peas.domain'
|
21
21
|
domain = args[1]
|
22
22
|
domain = "http://#{domain}" unless domain.start_with? 'http://'
|
23
|
+
# Update Git config
|
24
|
+
Git.sh "git config peas.domain #{domain}"
|
25
|
+
# Update file
|
23
26
|
content = Peas.config.merge('domain' => domain).to_json
|
24
27
|
File.open(Peas.config_file, 'w+') { |f| f.write(content) }
|
25
|
-
@api = API.new # Refresh settings from file because there's a new domain URI
|
28
|
+
@api = API.new # Refresh settings from git/file because there's a new domain URI
|
26
29
|
end
|
27
30
|
@api.request(:put, '/admin/settings', args[0] => args[1]) { |response| format_settings response }
|
28
31
|
else
|
data/lib/peas/commands/app.rb
CHANGED
@@ -1,9 +1,28 @@
|
|
1
|
+
desc 'List all apps'
|
2
|
+
command :apps do |c|
|
3
|
+
c.action do |_global_options, _options, _args|
|
4
|
+
@api.request(:get, "/app")
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
1
8
|
desc 'Create an app'
|
2
9
|
command :create do |c|
|
3
10
|
c.action do |_global_options, _options, _args|
|
4
|
-
@api.request
|
5
|
-
|
11
|
+
@api.request(
|
12
|
+
:post,
|
13
|
+
"/app/#{Git.first_sha}",
|
14
|
+
remote: Git.remote
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
6
18
|
|
19
|
+
desc 'Destroy an app'
|
20
|
+
command :destroy do |c|
|
21
|
+
c.action do |_global_options, _options, _args|
|
22
|
+
@api.request(
|
23
|
+
:delete,
|
24
|
+
"/app/#{Git.first_sha}"
|
25
|
+
)
|
7
26
|
end
|
8
27
|
end
|
9
28
|
|
@@ -30,8 +49,10 @@ command :scale do |c|
|
|
30
49
|
quantity = parts[1]
|
31
50
|
scaling_hash[process_type] = quantity
|
32
51
|
end
|
33
|
-
@api.request
|
34
|
-
|
35
|
-
|
52
|
+
@api.request(
|
53
|
+
:put,
|
54
|
+
"/app/#{Git.first_sha}/scale",
|
55
|
+
scaling_hash: scaling_hash.to_json
|
56
|
+
)
|
36
57
|
end
|
37
58
|
end
|
data/lib/peas/config.rb
CHANGED
@@ -16,9 +16,12 @@ module Peas
|
|
16
16
|
|
17
17
|
# Hierarchy of sources for the Peas API domain
|
18
18
|
def self.api_domain
|
19
|
+
git_domain = Git.sh 'git config peas.domain'
|
19
20
|
domain =
|
20
21
|
if ENV['PEAS_API_ENDPOINT']
|
21
22
|
ENV['PEAS_API_ENDPOINT']
|
23
|
+
elsif !git_domain.nil? && git_domain != ''
|
24
|
+
git_domain
|
22
25
|
elsif Peas.config['domain']
|
23
26
|
Peas.config['domain']
|
24
27
|
else
|
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.2.
|
5
|
+
# stub: peas-cli 0.2.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "peas-cli"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.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-08-01"
|
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"]
|
data/spec/cli_spec.rb
CHANGED
@@ -14,6 +14,7 @@ describe 'Peas CLI' do
|
|
14
14
|
it 'should set and use the domain setting' do
|
15
15
|
stub_request(:put, 'http://new-domain.com:4000/admin/settings?peas.domain=new-domain.com:4000')
|
16
16
|
.to_return(body: response_mock({}))
|
17
|
+
expect(Git).to receive(:sh).with("git config peas.domain http://new-domain.com:4000")
|
17
18
|
cli %w(admin settings peas.domain new-domain.com:4000)
|
18
19
|
config = JSON.parse File.open('/tmp/.peas').read
|
19
20
|
expect(config).to eq("domain" => "http://new-domain.com:4000")
|
@@ -22,7 +23,7 @@ describe 'Peas CLI' do
|
|
22
23
|
it 'should set a normal setting' do
|
23
24
|
stub_request(:put, 'http://vcap.me:4000/admin/settings?mongodb.uri=mongodb://uri')
|
24
25
|
.to_return(body: response_mock(
|
25
|
-
defaults: {'peas.domain' => 'http://boss.com'},
|
26
|
+
defaults: { 'peas.domain' => 'http://boss.com' },
|
26
27
|
services: {
|
27
28
|
'mongodb.uri' => 'mongodb://uri',
|
28
29
|
'postgres.uri' => 'xsgfd'
|
@@ -35,6 +36,13 @@ describe 'Peas CLI' do
|
|
35
36
|
end
|
36
37
|
|
37
38
|
describe 'App methods' do
|
39
|
+
it 'should list all apps' do
|
40
|
+
stub_request(:get, TEST_DOMAIN + '/app')
|
41
|
+
.to_return(body: response_mock(["coolapp"]))
|
42
|
+
output = cli ['apps']
|
43
|
+
expect(output).to eq "coolapp\n"
|
44
|
+
end
|
45
|
+
|
38
46
|
it 'should create an app' do
|
39
47
|
stub_request(:post, TEST_DOMAIN + '/app/fakesha?remote=git@github.com:test/test.git')
|
40
48
|
.to_return(body: response_mock("App 'test' successfully created"))
|
@@ -42,6 +50,13 @@ describe 'Peas CLI' do
|
|
42
50
|
expect(output).to eq "App 'test' successfully created\n"
|
43
51
|
end
|
44
52
|
|
53
|
+
it 'should destroy an app' do
|
54
|
+
stub_request(:delete, TEST_DOMAIN + '/app/fakesha')
|
55
|
+
.to_return(body: response_mock("App 'test' successfully destroyed"))
|
56
|
+
output = cli ['destroy']
|
57
|
+
expect(output).to eq "App 'test' successfully destroyed\n"
|
58
|
+
end
|
59
|
+
|
45
60
|
it 'should deploy an app', :with_socket do
|
46
61
|
stub_request(:get, /deploy/).to_return(body: '{"job": "123"}')
|
47
62
|
allow(@socket).to receive(:gets).and_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.2.
|
4
|
+
version: 0.2.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-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|