peas-cli 0.1.3 → 0.2.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/VERSION +1 -1
- data/lib/peas/api.rb +6 -4
- data/lib/peas/commands/admin.rb +28 -28
- data/lib/peas/config.rb +6 -5
- data/peas-cli.gemspec +3 -3
- data/spec/cli_spec.rb +16 -10
- data/spec/spec_helper.rb +1 -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: 84c1f06f1534d59fff16068ac6709e3c92e8448d
|
4
|
+
data.tar.gz: c1f74d412a7eed2cbf4c44a8fe40d52f483bb2e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e04075dea2bbb31efee01e1f52c7b7f97ed1d980b26fd02f97523d47812ac993953dd44432b41120cdcdfae1b100016f0cc4d6c38472ddc8b18230d8abbf443e
|
7
|
+
data.tar.gz: f48ebe5a3b750face0bb48d4f56d97404647b89a0125218036103481ff146305705b98e1808a9e7ad14e77a989ae5d83d14a099545627e7edf5019ac56c4dcc8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/peas/api.rb
CHANGED
@@ -35,9 +35,7 @@ class API
|
|
35
35
|
if api_version[0] != client_version[0]
|
36
36
|
version_mismatch = true
|
37
37
|
else
|
38
|
-
if api_version[1] != client_version[1]
|
39
|
-
version_mismatch = true
|
40
|
-
end
|
38
|
+
version_mismatch = true if api_version[1] != client_version[1]
|
41
39
|
end
|
42
40
|
if version_mismatch
|
43
41
|
Peas.warning_message "Your version of the CLI client is out of date " \
|
@@ -45,7 +43,11 @@ class API
|
|
45
43
|
"Please update using `gem install peas-cli`."
|
46
44
|
end
|
47
45
|
# Normal API response
|
48
|
-
|
46
|
+
if block_given?
|
47
|
+
yield json['message']
|
48
|
+
else
|
49
|
+
puts json['message']
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
data/lib/peas/commands/admin.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
options['domain'] = "http://#{options['domain']}"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
# Gli seems to provide a String and Symbol key for every option, so the options hash needs
|
13
|
-
# de-duplicating
|
14
|
-
deduped = {}
|
15
|
-
options.each do |k, v|
|
16
|
-
deduped[k] = v if k.is_a? String
|
1
|
+
def format_settings(hash)
|
2
|
+
puts "Available settings"
|
3
|
+
puts ''
|
4
|
+
hash.each do |type, settings|
|
5
|
+
puts "#{type.capitalize}:"
|
6
|
+
settings.each do |setting, value|
|
7
|
+
value = '[unset]' if value == ''
|
8
|
+
puts " #{setting} #{value}"
|
17
9
|
end
|
18
|
-
|
19
|
-
content = Peas.config.merge(deduped).to_json
|
20
|
-
File.open(Peas.config_file, 'w+') { |f| f.write(content) }
|
21
|
-
# Save the settings on the server as well
|
22
|
-
@api = API.new # Refresh settings from file
|
23
|
-
@api.request :put, '/admin/settings', options
|
24
|
-
puts "New settings:"
|
25
|
-
puts JSON.pretty_generate(Peas.config)
|
10
|
+
puts ''
|
26
11
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Admin commands"
|
15
|
+
command :admin do |admin|
|
16
|
+
admin.desc 'Set Peas global system settings'
|
17
|
+
admin.command :settings do |settings|
|
18
|
+
settings.action do |_global_options, _options, args|
|
19
|
+
if args.count > 1
|
20
|
+
if args.first == 'peas.domain'
|
21
|
+
domain = args[1]
|
22
|
+
domain = "http://#{domain}" unless domain.start_with? 'http://'
|
23
|
+
content = Peas.config.merge('domain' => domain).to_json
|
24
|
+
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
|
26
|
+
end
|
27
|
+
@api.request(:put, '/admin/settings', args[0] => args[1]) { |response| format_settings response }
|
28
|
+
else
|
29
|
+
@api.request(:get, '/admin/settings') { |response| format_settings response }
|
30
|
+
end
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/peas/config.rb
CHANGED
@@ -16,15 +16,16 @@ module Peas
|
|
16
16
|
|
17
17
|
# Hierarchy of sources for the Peas API domain
|
18
18
|
def self.api_domain
|
19
|
-
domain =
|
20
|
-
|
19
|
+
domain =
|
20
|
+
if ENV['PEAS_API_ENDPOINT']
|
21
|
+
ENV['PEAS_API_ENDPOINT']
|
21
22
|
elsif Peas.config['domain']
|
22
|
-
|
23
|
+
Peas.config['domain']
|
23
24
|
else
|
24
|
-
'
|
25
|
+
'vcap.me:4000'
|
25
26
|
end
|
26
27
|
unless domain[/\Ahttp:\/\//] || domain[/\Ahttps:\/\//]
|
27
|
-
|
28
|
+
"http://#{domain}"
|
28
29
|
else
|
29
30
|
domain
|
30
31
|
end
|
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.
|
5
|
+
# stub: peas-cli 0.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "peas-cli"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.0"
|
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-07-
|
14
|
+
s.date = "2014-07-23"
|
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
@@ -11,21 +11,27 @@ describe 'Peas CLI' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'Settings' do
|
14
|
-
it 'should set
|
15
|
-
stub_request(:put, 'http://new-domain.com:4000/admin/settings?domain=new-domain.com:4000')
|
16
|
-
.to_return(body: response_mock(
|
17
|
-
|
18
|
-
expect(output).to eq "\nNew settings:\n{\n \"domain\": \"http://new-domain.com:4000\"\n}\n"
|
14
|
+
it 'should set and use the domain setting' do
|
15
|
+
stub_request(:put, 'http://new-domain.com:4000/admin/settings?peas.domain=new-domain.com:4000')
|
16
|
+
.to_return(body: response_mock({}))
|
17
|
+
cli %w(admin settings peas.domain new-domain.com:4000)
|
19
18
|
config = JSON.parse File.open('/tmp/.peas').read
|
20
19
|
expect(config).to eq("domain" => "http://new-domain.com:4000")
|
21
20
|
end
|
22
21
|
|
23
|
-
it 'should
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
it 'should set a normal setting' do
|
23
|
+
stub_request(:put, 'http://vcap.me:4000/admin/settings?mongodb.uri=mongodb://uri')
|
24
|
+
.to_return(body: response_mock(
|
25
|
+
defaults: {'peas.domain' => 'http://boss.com'},
|
26
|
+
services: {
|
27
|
+
'mongodb.uri' => 'mongodb://uri',
|
28
|
+
'postgres.uri' => 'xsgfd'
|
29
|
+
}
|
30
|
+
))
|
31
|
+
output = cli %w(admin settings mongodb.uri mongodb://uri)
|
32
|
+
expect(output).to eq("Available settings\n\nDefaults:\n peas.domain http://boss.com\n\nServices:\n mongodb.uri mongodb://uri\n postgres.uri xsgfd\n\n")
|
28
33
|
end
|
34
|
+
|
29
35
|
end
|
30
36
|
|
31
37
|
describe 'App methods' do
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,7 @@ require 'lib/peas'
|
|
8
8
|
ENV['GLI_ENV'] = 'test'
|
9
9
|
ROOT = File.join(File.expand_path(File.dirname(__FILE__)), '..')
|
10
10
|
$LOAD_PATH.unshift(File.join(ROOT, 'lib'))
|
11
|
-
TEST_DOMAIN = 'http://
|
11
|
+
TEST_DOMAIN = 'http://vcap.me:4000'
|
12
12
|
SWITCHBOARD_TEST_PORT = 79_345
|
13
13
|
|
14
14
|
RSpec.configure do |config|
|
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.
|
4
|
+
version: 0.2.0
|
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-07-
|
11
|
+
date: 2014-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|