vmc 0.4.7 → 0.5.0.beta.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.
- data/lib/vmc.rb +1 -2
- data/lib/vmc/cli.rb +33 -31
- data/lib/vmc/cli/app/app.rb +2 -2
- data/lib/vmc/cli/app/apps.rb +4 -5
- data/lib/vmc/cli/app/crashes.rb +2 -3
- data/lib/vmc/cli/app/delete.rb +28 -25
- data/lib/vmc/cli/app/env.rb +11 -19
- data/lib/vmc/cli/app/files.rb +11 -15
- data/lib/vmc/cli/app/health.rb +2 -3
- data/lib/vmc/cli/app/instances.rb +3 -3
- data/lib/vmc/cli/app/logs.rb +7 -10
- data/lib/vmc/cli/app/push.rb +17 -89
- data/lib/vmc/cli/app/push/create.rb +2 -0
- data/lib/vmc/cli/app/rename.rb +17 -13
- data/lib/vmc/cli/app/restart.rb +4 -7
- data/lib/vmc/cli/app/routes.rb +14 -11
- data/lib/vmc/cli/app/scale.rb +17 -15
- data/lib/vmc/cli/app/start.rb +4 -7
- data/lib/vmc/cli/app/stats.rb +2 -3
- data/lib/vmc/cli/app/stop.rb +3 -5
- data/lib/vmc/cli/domain/add_domain.rb +3 -5
- data/lib/vmc/cli/domain/create_domain.rb +5 -8
- data/lib/vmc/cli/domain/delete_domain.rb +23 -18
- data/lib/vmc/cli/domain/domains.rb +4 -7
- data/lib/vmc/cli/domain/remove_domain.rb +12 -10
- data/lib/vmc/cli/organization/org.rb +6 -7
- data/lib/vmc/cli/organization/orgs.rb +19 -19
- data/lib/vmc/cli/organization/rename.rb +18 -14
- data/lib/vmc/cli/route/create_route.rb +20 -13
- data/lib/vmc/cli/route/{delete_route.rb → delete.rb} +22 -17
- data/lib/vmc/cli/service/bind.rb +2 -2
- data/lib/vmc/cli/service/create.rb +57 -53
- data/lib/vmc/cli/service/delete.rb +33 -31
- data/lib/vmc/cli/service/rename.rb +17 -14
- data/lib/vmc/cli/service/service.rb +5 -8
- data/lib/vmc/cli/service/services.rb +14 -18
- data/lib/vmc/cli/service/unbind.rb +4 -4
- data/lib/vmc/cli/space/create.rb +16 -17
- data/lib/vmc/cli/space/delete.rb +34 -31
- data/lib/vmc/cli/space/rename.rb +20 -17
- data/lib/vmc/cli/space/space.rb +11 -14
- data/lib/vmc/cli/space/spaces.rb +14 -16
- data/lib/vmc/cli/space/take.rb +1 -3
- data/lib/vmc/cli/start/base.rb +2 -0
- data/lib/vmc/cli/start/colors.rb +0 -1
- data/lib/vmc/cli/start/info.rb +8 -10
- data/lib/vmc/cli/start/login.rb +11 -40
- data/lib/vmc/cli/start/logout.rb +0 -1
- data/lib/vmc/cli/start/register.rb +18 -12
- data/lib/vmc/cli/start/target.rb +7 -36
- data/lib/vmc/cli/start/target_interactions.rb +3 -1
- data/lib/vmc/cli/start/targets.rb +0 -1
- data/lib/vmc/cli/user/create.rb +4 -2
- data/lib/vmc/version.rb +1 -1
- data/spec/factories/organization_factory.rb +5 -0
- data/spec/factories/space_factory.rb +15 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/vmc/cli/app/push/create_spec.rb +2 -1
- data/spec/vmc/cli/app/push_spec.rb +1 -1
- data/spec/vmc/cli/organization/orgs_spec.rb +119 -0
- data/spec/vmc/cli/route/delete_route_spec.rb +3 -3
- data/spec/vmc/cli/service/bind_spec.rb +34 -0
- data/spec/vmc/cli/service/delete_spec.rb +32 -0
- data/spec/vmc/cli/service/service_spec.rb +32 -0
- data/spec/vmc/cli/service/unbind_spec.rb +34 -0
- data/spec/vmc/cli/space/spaces_spec.rb +120 -0
- data/spec/vmc/cli/start/info_spec.rb +38 -0
- data/spec/vmc/cli/start/login_spec.rb +40 -0
- metadata +127 -113
- data/lib/vmc/cli/organization/create_org.rb +0 -28
- data/lib/vmc/cli/organization/delete_org.rb +0 -65
- data/lib/vmc/cli/service/binding.rb +0 -66
- data/lib/vmc/cli/user.rb +0 -118
data/lib/vmc/cli/start/login.rb
CHANGED
@@ -1,54 +1,25 @@
|
|
1
|
-
require "vmc/detect"
|
2
1
|
require "vmc/cli/start/base"
|
2
|
+
require "vmc/cli/start/target_interactions"
|
3
3
|
|
4
4
|
module VMC::Start
|
5
5
|
class Login < Base
|
6
6
|
desc "Authenticate with the target"
|
7
7
|
group :start
|
8
|
-
input :username, :
|
9
|
-
:
|
8
|
+
input :username, :value => :email, :desc => "Account email",
|
9
|
+
:alias => "--email", :argument => :optional
|
10
10
|
input :password, :desc => "Account password"
|
11
|
-
input
|
12
|
-
:from_given => by_name(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
if orgs.empty?
|
17
|
-
unless quiet?
|
18
|
-
line
|
19
|
-
line c("There are no organizations.", :warning)
|
20
|
-
line "You may want to create one with #{c("create-org", :good)}."
|
21
|
-
end
|
22
|
-
elsif orgs.size == 1 && !input.interactive?(:organization)
|
23
|
-
orgs.first
|
24
|
-
else
|
25
|
-
ask("Organization",
|
26
|
-
:choices => orgs.sort_by(&:name),
|
27
|
-
:display => proc(&:name))
|
28
|
-
end
|
29
|
-
}
|
30
|
-
input(:space, :alias => "-s",
|
31
|
-
:from_given => by_name("space"),
|
32
|
-
:desc => "Space") { |org|
|
33
|
-
spaces = org.spaces(:depth => 0)
|
34
|
-
|
35
|
-
if spaces.empty?
|
36
|
-
unless quiet?
|
37
|
-
line
|
38
|
-
line c("There are no spaces in #{b(org.name)}.", :warning)
|
39
|
-
line "You may want to create one with #{c("create-space", :good)}."
|
40
|
-
end
|
41
|
-
else
|
42
|
-
ask("Space", :choices => spaces, :display => proc(&:name))
|
43
|
-
end
|
44
|
-
}
|
11
|
+
input :organization, :desc => "Organization" , :aliases => %w{--org -o},
|
12
|
+
:from_given => by_name(:organization)
|
13
|
+
input :space, :desc => "Space", :alias => "-s",
|
14
|
+
:from_given => by_name(:space)
|
15
|
+
interactions TargetInteractions
|
45
16
|
def login
|
46
17
|
show_context
|
47
18
|
|
48
19
|
credentials =
|
49
|
-
|
50
|
-
|
51
|
-
|
20
|
+
{ :username => input[:username],
|
21
|
+
:password => input[:password]
|
22
|
+
}
|
52
23
|
|
53
24
|
prompts = client.login_prompts
|
54
25
|
|
data/lib/vmc/cli/start/logout.rb
CHANGED
@@ -1,21 +1,13 @@
|
|
1
|
-
require "vmc/detect"
|
2
1
|
require "vmc/cli/start/base"
|
3
2
|
|
4
3
|
module VMC::Start
|
5
4
|
class Register < Base
|
6
5
|
desc "Create a user and log in"
|
7
6
|
group :start, :hidden => true
|
8
|
-
input
|
9
|
-
|
10
|
-
|
11
|
-
input
|
12
|
-
ask("Password", :echo => "*", :forget => true)
|
13
|
-
}
|
14
|
-
input(:verify, :desc => "Repeat password") {
|
15
|
-
ask("Confirm Password", :echo => "*", :forget => true)
|
16
|
-
}
|
17
|
-
input :login, :type => :boolean, :default => true,
|
18
|
-
:desc => "Automatically log in?"
|
7
|
+
input :email, :desc => "Desired email", :argument => :optional
|
8
|
+
input :password, :desc => "Desired password"
|
9
|
+
input :verify, :desc => "Repeat password"
|
10
|
+
input :login, :desc => "Automatically log in?", :default => true
|
19
11
|
def register
|
20
12
|
show_context
|
21
13
|
|
@@ -34,5 +26,19 @@ module VMC::Start
|
|
34
26
|
invoke :login, :username => email, :password => password
|
35
27
|
end
|
36
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def ask_email
|
33
|
+
ask("Email")
|
34
|
+
end
|
35
|
+
|
36
|
+
def ask_passsword
|
37
|
+
ask("Password", :echo => "*", :forget => true)
|
38
|
+
end
|
39
|
+
|
40
|
+
def ask_verify
|
41
|
+
ask("Confirm Password", :echo => "*", :forget => true)
|
42
|
+
end
|
37
43
|
end
|
38
44
|
end
|
data/lib/vmc/cli/start/target.rb
CHANGED
@@ -1,45 +1,16 @@
|
|
1
|
-
require "vmc/detect"
|
2
1
|
require "vmc/cli/start/base"
|
2
|
+
require "vmc/cli/start/target_interactions"
|
3
3
|
|
4
4
|
module VMC::Start
|
5
5
|
class Target < Base
|
6
6
|
desc "Set or display the target cloud, organization, and space"
|
7
7
|
group :start
|
8
|
-
input :url, :
|
9
|
-
input
|
10
|
-
:from_given => by_name(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
if orgs.empty?
|
15
|
-
unless quiet?
|
16
|
-
line
|
17
|
-
line c("There are no organizations.", :warning)
|
18
|
-
line "You may want to create one with #{c("create-org", :good)}."
|
19
|
-
end
|
20
|
-
elsif orgs.size == 1 && !input.interactive?(:organization)
|
21
|
-
orgs.first
|
22
|
-
else
|
23
|
-
ask("Organization",
|
24
|
-
:choices => orgs.sort_by(&:name),
|
25
|
-
:display => proc(&:name))
|
26
|
-
end
|
27
|
-
}
|
28
|
-
input(:space, :alias => "-s",
|
29
|
-
:from_given => by_name("space"),
|
30
|
-
:desc => "Space") { |org|
|
31
|
-
spaces = org.spaces(:depth => 0)
|
32
|
-
|
33
|
-
if spaces.empty?
|
34
|
-
unless quiet?
|
35
|
-
line
|
36
|
-
line c("There are no spaces in #{b(org.name)}.", :warning)
|
37
|
-
line "You may want to create one with #{c("create-space", :good)}."
|
38
|
-
end
|
39
|
-
else
|
40
|
-
ask("Space", :choices => spaces, :display => proc(&:name))
|
41
|
-
end
|
42
|
-
}
|
8
|
+
input :url, :desc => "Target URL to switch to", :argument => :optional
|
9
|
+
input :organization, :desc => "Organization" , :aliases => %w{--org -o},
|
10
|
+
:from_given => by_name(:organization)
|
11
|
+
input :space, :desc => "Space", :alias => "-s",
|
12
|
+
:from_given => by_name(:space)
|
13
|
+
interactions TargetInteractions
|
43
14
|
def target
|
44
15
|
if !input.given?(:url) && !input.given?(:organization) && !input.given?(:space)
|
45
16
|
display_target
|
@@ -27,9 +27,11 @@ module VMC::Start
|
|
27
27
|
line c("There are no spaces in #{b(org.name)}.", :warning)
|
28
28
|
line "You may want to create one with #{c("create-space", :good)}."
|
29
29
|
end
|
30
|
+
elsif spaces.size == 1 && !input.interactive?(:spaces)
|
31
|
+
spaces.first
|
30
32
|
else
|
31
33
|
ask("Space", :choices => spaces, :display => proc(&:name))
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
35
|
-
end
|
37
|
+
end
|
data/lib/vmc/cli/user/create.rb
CHANGED
@@ -4,7 +4,7 @@ module VMC::User
|
|
4
4
|
class Create < Base
|
5
5
|
desc "Create a user"
|
6
6
|
group :admin, :user, :hidden => true
|
7
|
-
input :email, :desc => "User email", :argument =>
|
7
|
+
input :email, :desc => "User email", :argument => :optional
|
8
8
|
input :password, :desc => "User password"
|
9
9
|
input :verify, :desc => "Repeat password"
|
10
10
|
def create_user
|
@@ -20,7 +20,9 @@ module VMC::User
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
alias_command :
|
23
|
+
alias_command :add_user, :create_user
|
24
|
+
|
25
|
+
private
|
24
26
|
|
25
27
|
def ask_email
|
26
28
|
ask("Email")
|
data/lib/vmc/version.rb
CHANGED
@@ -5,6 +5,7 @@ FactoryGirl.define do
|
|
5
5
|
|
6
6
|
ignore do
|
7
7
|
spaces []
|
8
|
+
domains []
|
8
9
|
end
|
9
10
|
|
10
11
|
initialize_with do
|
@@ -12,7 +13,11 @@ FactoryGirl.define do
|
|
12
13
|
end
|
13
14
|
|
14
15
|
after_build do |org, evaluator|
|
16
|
+
evaluator.spaces.each { |s| s.organization = org }
|
17
|
+
evaluator.domains.each { |s| s.owning_organization = org }
|
18
|
+
|
15
19
|
RR.stub(org).spaces { evaluator.spaces }
|
20
|
+
RR.stub(org).domains { evaluator.domains }
|
16
21
|
end
|
17
22
|
end
|
18
23
|
end
|
@@ -3,8 +3,23 @@ FactoryGirl.define do
|
|
3
3
|
guid { FactoryGirl.generate(:guid) }
|
4
4
|
name { FactoryGirl.generate(:random_string) }
|
5
5
|
|
6
|
+
ignore do
|
7
|
+
apps []
|
8
|
+
service_instances []
|
9
|
+
domains []
|
10
|
+
end
|
11
|
+
|
6
12
|
initialize_with do
|
7
13
|
CFoundry::V2::Space.new(nil, nil)
|
8
14
|
end
|
15
|
+
|
16
|
+
after_build do |org, evaluator|
|
17
|
+
evaluator.apps.each { |s| s.space = org }
|
18
|
+
evaluator.service_instances.each { |s| s.space = org }
|
19
|
+
|
20
|
+
RR.stub(org).apps { evaluator.apps }
|
21
|
+
RR.stub(org).service_instances { evaluator.service_instances }
|
22
|
+
RR.stub(org).domains { evaluator.domains }
|
23
|
+
end
|
9
24
|
end
|
10
25
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -15,3 +15,19 @@ RSpec.configure do |c|
|
|
15
15
|
c.mock_with :rr
|
16
16
|
end
|
17
17
|
|
18
|
+
|
19
|
+
def reassign_stdout_to(output)
|
20
|
+
old_out = $stdout
|
21
|
+
$stdout = output
|
22
|
+
yield $stdout
|
23
|
+
ensure
|
24
|
+
$stdout = old_out
|
25
|
+
end
|
26
|
+
|
27
|
+
def name_list(xs)
|
28
|
+
if xs.empty?
|
29
|
+
"none"
|
30
|
+
else
|
31
|
+
xs.collect(&:name).join(", ")
|
32
|
+
end
|
33
|
+
end
|
@@ -29,8 +29,9 @@ describe VMC::App::Create do
|
|
29
29
|
|
30
30
|
let(:create) do
|
31
31
|
create = VMC::App::Push.new
|
32
|
-
create.path = "
|
32
|
+
create.path = "some-path"
|
33
33
|
create.input = Mothership::Inputs.new(Mothership.commands[:push], create, inputs, given, global)
|
34
|
+
create.extend VMC::App::PushInteractions
|
34
35
|
create
|
35
36
|
end
|
36
37
|
|
@@ -39,7 +39,7 @@ describe VMC::App::Push do
|
|
39
39
|
describe 'arguments' do
|
40
40
|
subject { command.arguments }
|
41
41
|
it 'has the correct argument order' do
|
42
|
-
should eq([{ :type => :
|
42
|
+
should eq([{ :type => :optional, :value => nil, :name => :name }])
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
describe VMC::Organization::Orgs do
|
5
|
+
let(:global) { { :color => false } }
|
6
|
+
let(:inputs) { {} }
|
7
|
+
let(:given) { {} }
|
8
|
+
let(:output) { StringIO.new }
|
9
|
+
let!(:org_1) { FactoryGirl.build(:organization, :name => "bb_second", :spaces => FactoryGirl.build_list(:space, 2), :domains => [FactoryGirl.build(:domain)]) }
|
10
|
+
let!(:org_2) { FactoryGirl.build(:organization, :name => "aa_first", :spaces => [FactoryGirl.build(:space)], :domains => FactoryGirl.build_list(:domain, 3)) }
|
11
|
+
let!(:org_3) { FactoryGirl.build(:organization, :name => "cc_last", :spaces => FactoryGirl.build_list(:space, 2), :domains => FactoryGirl.build_list(:domain, 2)) }
|
12
|
+
let(:organizations) { [org_1, org_2, org_3]}
|
13
|
+
let(:client) { FactoryGirl.build(:client, :organizations => organizations) }
|
14
|
+
|
15
|
+
before do
|
16
|
+
any_instance_of(VMC::CLI) do |cli|
|
17
|
+
stub(cli).client { client }
|
18
|
+
stub(cli).precondition { nil }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
subject do
|
23
|
+
reassign_stdout_to output do
|
24
|
+
Mothership.new.invoke(:orgs, inputs, given, global)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'metadata' do
|
29
|
+
let(:command) { Mothership.commands[:orgs] }
|
30
|
+
|
31
|
+
describe 'command' do
|
32
|
+
subject { command }
|
33
|
+
its(:description) { should eq "List available organizations" }
|
34
|
+
it { expect(Mothership::Help.group(:organizations)).to include(subject) }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'inputs' do
|
38
|
+
subject { command.inputs }
|
39
|
+
|
40
|
+
it "is not missing any descriptions" do
|
41
|
+
subject.each do |_, attrs|
|
42
|
+
expect(attrs[:description]).to be
|
43
|
+
expect(attrs[:description].strip).to_not be_empty
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'arguments' do
|
49
|
+
subject { command.arguments }
|
50
|
+
it 'has no arguments' do
|
51
|
+
should be_empty
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should have the correct first two lines' do
|
57
|
+
subject
|
58
|
+
|
59
|
+
output.rewind
|
60
|
+
expect(output.readline).to match /Getting organizations.*OK/
|
61
|
+
expect(output.readline).to eq "\n"
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when there are no orgnaizations' do
|
65
|
+
let(:organizations) { [] }
|
66
|
+
|
67
|
+
context 'and the full flag is given' do
|
68
|
+
let(:inputs) { {:full => true} }
|
69
|
+
|
70
|
+
it 'displays yaml-style output with all organization details' do
|
71
|
+
any_instance_of VMC::Organization::Orgs do |orgs|
|
72
|
+
dont_allow(orgs).invoke
|
73
|
+
end
|
74
|
+
subject
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'and the full flag is not given (default is false)' do
|
79
|
+
it 'should show only the progress' do
|
80
|
+
subject
|
81
|
+
|
82
|
+
output.rewind
|
83
|
+
expect(output.readline).to match /Getting organizations.*OK/
|
84
|
+
expect(output).to be_eof
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'when there are organizations' do
|
90
|
+
context 'and the full flag is given' do
|
91
|
+
let(:inputs) { {:full => true} }
|
92
|
+
|
93
|
+
it 'displays yaml-style output with all organization details' do
|
94
|
+
any_instance_of VMC::Organization::Orgs do |orgs|
|
95
|
+
mock(orgs).invoke(:org, :organization => org_2, :full => true).ordered
|
96
|
+
mock(orgs).invoke(:org, :organization => org_1, :full => true).ordered
|
97
|
+
mock(orgs).invoke(:org, :organization => org_3, :full => true).ordered
|
98
|
+
end
|
99
|
+
subject
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'and the full flag is not given (default is false)' do
|
104
|
+
it 'displays tabular output with names, spaces and domains' do
|
105
|
+
subject
|
106
|
+
|
107
|
+
output.rewind
|
108
|
+
output.readline
|
109
|
+
output.readline
|
110
|
+
|
111
|
+
expect(output.readline).to match /name\s+spaces\s+domains/
|
112
|
+
organizations.sort_by(&:name).each do |org|
|
113
|
+
expect(output.readline).to match /#{org.name}\s+#{name_list(org.spaces)}\s+#{name_list(org.domains)}/
|
114
|
+
end
|
115
|
+
expect(output).to be_eof
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require "vmc/cli/route/
|
2
|
+
require "vmc/cli/route/delete"
|
3
3
|
|
4
|
-
describe VMC::Route::
|
4
|
+
describe VMC::Route::Delete do
|
5
5
|
let(:global) { { :color => false, :quiet => true } }
|
6
6
|
let(:inputs) { {} }
|
7
7
|
let(:given) { {} }
|
@@ -45,7 +45,7 @@ describe VMC::Route::DeleteRoute do
|
|
45
45
|
context 'when there are no routes' do
|
46
46
|
context 'and a name is given' do
|
47
47
|
let(:given) { { :route => "some-route" } }
|
48
|
-
it { expect { subject }.to raise_error(VMC::UserError, "
|
48
|
+
it { expect { subject }.to raise_error(VMC::UserError, "Unknown route 'some-route'.") }
|
49
49
|
end
|
50
50
|
|
51
51
|
context 'and a name is not given' do
|