vmc 0.4.5 → 0.4.6
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/cli/app/files.rb +61 -5
- data/lib/vmc/cli/app/push/interactions.rb +87 -0
- data/lib/vmc/cli/app/push/sync.rb +4 -4
- data/lib/vmc/cli/organization/create.rb +32 -0
- data/lib/vmc/cli/organization/delete.rb +73 -0
- data/lib/vmc/cli/service/bind.rb +44 -0
- data/lib/vmc/cli/service/unbind.rb +38 -0
- data/lib/vmc/cli/space/spaces.rb +3 -3
- data/lib/vmc/cli/start/base.rb +4 -26
- data/lib/vmc/cli/start/login.rb +30 -6
- data/lib/vmc/cli/start/target.rb +30 -6
- data/lib/vmc/cli/start/target_interactions.rb +35 -0
- data/lib/vmc/cli/user/base.rb +10 -0
- data/lib/vmc/cli/user/create.rb +37 -0
- data/lib/vmc/cli/user/delete.rb +25 -0
- data/lib/vmc/cli/user/passwd.rb +53 -0
- data/lib/vmc/cli/user/users.rb +32 -0
- data/lib/vmc/version.rb +1 -1
- data/spec/vmc/cli/app/push_spec.rb +3 -3
- metadata +18 -7
data/lib/vmc/cli/app/files.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "thread"
|
1
2
|
require "vmc/cli/app/base"
|
2
3
|
|
3
4
|
module VMC::App
|
@@ -67,19 +68,74 @@ module VMC::App
|
|
67
68
|
input :app, :argument => true,
|
68
69
|
:desc => "Application to inspect the file of",
|
69
70
|
:from_given => by_name("app")
|
70
|
-
input :path, :argument =>
|
71
|
-
:desc => "Path of file to stream"
|
71
|
+
input :path, :argument => :optional, :default => nil,
|
72
|
+
:desc => "Path of file to stream (default: all)"
|
72
73
|
def tail
|
73
74
|
app = input[:app]
|
74
|
-
path = input[:path]
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
lines = Queue.new
|
77
|
+
max_len = 0
|
78
|
+
|
79
|
+
if path = input[:path]
|
80
|
+
max_len = path.size
|
81
|
+
app.instances.each do |i|
|
82
|
+
Thread.new do
|
83
|
+
stream_path(lines, i, path.split("/"))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
else
|
87
|
+
app.instances.each do |i|
|
88
|
+
i.files("logs").each do |path|
|
89
|
+
len = path.join("/").size
|
90
|
+
max_len = len if len > max_len
|
91
|
+
|
92
|
+
Thread.new do
|
93
|
+
stream_path(lines, i, path)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
while line = lines.pop
|
100
|
+
instance, path, log = line
|
101
|
+
|
102
|
+
unless log.end_with?("\n")
|
103
|
+
log += i("%") if color?
|
104
|
+
log += "\n"
|
105
|
+
end
|
106
|
+
|
107
|
+
print "\##{c(instance.id, :instance)} "
|
108
|
+
print "#{c(path.join("/").ljust(max_len), :name)} "
|
109
|
+
print log
|
78
110
|
end
|
79
111
|
rescue CFoundry::NotFound
|
80
112
|
fail "Invalid path #{b(path)} for app #{b(app.name)}"
|
81
113
|
rescue CFoundry::FileError => e
|
82
114
|
fail e.description
|
83
115
|
end
|
116
|
+
|
117
|
+
def stream_path(lines, instance, path)
|
118
|
+
if verbose?
|
119
|
+
lines << [instance, path, c("streaming...", :good) + "\n"]
|
120
|
+
end
|
121
|
+
|
122
|
+
instance.stream_file(*path) do |contents|
|
123
|
+
contents.each_line do |line|
|
124
|
+
lines << [instance, path, line]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
lines << [instance, path, c("end of file", :bad) + "\n"]
|
129
|
+
rescue Timeout::Error
|
130
|
+
if verbose?
|
131
|
+
lines << [
|
132
|
+
instance,
|
133
|
+
path,
|
134
|
+
c("timed out; reconnecting...", :bad) + "\n"
|
135
|
+
]
|
136
|
+
end
|
137
|
+
|
138
|
+
retry
|
139
|
+
end
|
84
140
|
end
|
85
141
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module VMC::App
|
2
|
+
module PushInteractions
|
3
|
+
def ask_name
|
4
|
+
ask("Name")
|
5
|
+
end
|
6
|
+
|
7
|
+
def ask_url(name)
|
8
|
+
choices = url_choices(name)
|
9
|
+
|
10
|
+
options = {
|
11
|
+
:choices => choices + ["none"],
|
12
|
+
:allow_other => true
|
13
|
+
}
|
14
|
+
|
15
|
+
options[:default] = choices.first if choices.size == 1
|
16
|
+
|
17
|
+
url = ask "URL", options
|
18
|
+
|
19
|
+
unless url == "none"
|
20
|
+
url
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def ask_memory(default)
|
25
|
+
ask("Memory Limit",
|
26
|
+
:choices => memory_choices,
|
27
|
+
:allow_other => true,
|
28
|
+
:default => default || "64M")
|
29
|
+
end
|
30
|
+
|
31
|
+
def ask_instances
|
32
|
+
ask("Instances", :default => 1)
|
33
|
+
end
|
34
|
+
|
35
|
+
def ask_framework(choices, default, other)
|
36
|
+
ask_with_other("Framework", client.frameworks, choices, default, other)
|
37
|
+
end
|
38
|
+
|
39
|
+
def ask_runtime(choices, default, other)
|
40
|
+
ask_with_other("Runtime", client.runtimes, choices, default, other)
|
41
|
+
end
|
42
|
+
|
43
|
+
def ask_command
|
44
|
+
ask("Startup command")
|
45
|
+
end
|
46
|
+
|
47
|
+
def ask_create_services
|
48
|
+
line unless quiet?
|
49
|
+
ask "Create services for application?", :default => false
|
50
|
+
end
|
51
|
+
|
52
|
+
def ask_bind_services
|
53
|
+
return if all_instances.empty?
|
54
|
+
|
55
|
+
ask "Bind other services to application?", :default => false
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def ask_with_other(message, all, choices, default, other)
|
61
|
+
choices = choices.sort_by(&:name)
|
62
|
+
choices << other if other
|
63
|
+
|
64
|
+
opts = {
|
65
|
+
:choices => choices,
|
66
|
+
:display => proc { |x|
|
67
|
+
if other && x == other
|
68
|
+
"other"
|
69
|
+
else
|
70
|
+
x.name
|
71
|
+
end
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
opts[:default] = default if default
|
76
|
+
|
77
|
+
res = ask(message, opts)
|
78
|
+
|
79
|
+
if other && res == other
|
80
|
+
opts[:choices] = all
|
81
|
+
res = ask(message, opts)
|
82
|
+
end
|
83
|
+
|
84
|
+
res
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -20,10 +20,10 @@ module VMC::App
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def commit_changes(app)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
if app.changed?
|
24
|
+
with_progress("Updating #{c(app.name, :name)}") do
|
25
|
+
app.update!
|
26
|
+
end
|
27
27
|
end
|
28
28
|
|
29
29
|
if input[:restart] && app.started?
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "vmc/cli/organization/base"
|
2
|
+
|
3
|
+
module VMC::Organization
|
4
|
+
class Create < Base
|
5
|
+
desc "Create an organization"
|
6
|
+
group :organizations
|
7
|
+
input :name, :desc => "Organization name", :argument => :optional
|
8
|
+
input :target, :desc => "Switch to the organization after creation",
|
9
|
+
:alias => "-t", :default => true
|
10
|
+
input :add_self, :desc => "Add yourself to the organization",
|
11
|
+
:default => true
|
12
|
+
def create_org
|
13
|
+
org = client.organization
|
14
|
+
org.name = input[:name]
|
15
|
+
org.users = [client.current_user] if input[:add_self]
|
16
|
+
|
17
|
+
with_progress("Creating organization #{c(org.name, :name)}") do
|
18
|
+
org.create!
|
19
|
+
end
|
20
|
+
|
21
|
+
if input[:target]
|
22
|
+
invoke :target, :organization => org
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def ask_name
|
29
|
+
ask("Name")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "vmc/cli/organization/base"
|
2
|
+
|
3
|
+
module VMC::Organization
|
4
|
+
class Delete < Base
|
5
|
+
desc "Delete an organization"
|
6
|
+
group :organizations
|
7
|
+
input :organization, :desc => "Organization to delete",
|
8
|
+
:aliases => %w{--org -o}, :argument => :optional,
|
9
|
+
:from_given => by_name(:organization)
|
10
|
+
input :recursive, :desc => "Delete recursively", :alias => "-r",
|
11
|
+
:default => false, :forget => true
|
12
|
+
input :warn, :desc => "Show warning if it was the last org",
|
13
|
+
:default => true
|
14
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
15
|
+
:default => proc { force? || interact }
|
16
|
+
def delete_org
|
17
|
+
org = input[:organization]
|
18
|
+
return unless input[:really, org]
|
19
|
+
|
20
|
+
spaces = org.spaces
|
21
|
+
unless spaces.empty?
|
22
|
+
unless force?
|
23
|
+
line "This organization is not empty!"
|
24
|
+
line
|
25
|
+
line "spaces: #{name_list(spaces)}"
|
26
|
+
line
|
27
|
+
|
28
|
+
return unless input[:recursive]
|
29
|
+
end
|
30
|
+
|
31
|
+
spaces.each do |s|
|
32
|
+
invoke :delete_space, :space => s, :really => true,
|
33
|
+
:recursive => true, :warn => false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
is_current = org == client.current_organization
|
38
|
+
|
39
|
+
with_progress("Deleting organization #{c(org.name, :name)}") do
|
40
|
+
org.delete!
|
41
|
+
end
|
42
|
+
|
43
|
+
if orgs.size == 1
|
44
|
+
return unless input[:warn]
|
45
|
+
|
46
|
+
line
|
47
|
+
line c("There are no longer any organizations.", :warning)
|
48
|
+
line "You may want to create one with #{c("create-org", :good)}."
|
49
|
+
elsif is_current
|
50
|
+
invalidate_target
|
51
|
+
invoke :target
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def ask_organization
|
58
|
+
orgs = client.organizations
|
59
|
+
fail "No organizations." if orgs.empty?
|
60
|
+
|
61
|
+
ask("Which organization", :choices => orgs.sort_by(&:name),
|
62
|
+
:display => proc(&:name))
|
63
|
+
end
|
64
|
+
|
65
|
+
def ask_really(org)
|
66
|
+
ask("Really delete #{c(org.name, :name)}?", :default => false)
|
67
|
+
end
|
68
|
+
|
69
|
+
def ask_recursive
|
70
|
+
ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "vmc/detect"
|
2
|
+
|
3
|
+
require "vmc/cli/service/base"
|
4
|
+
|
5
|
+
module VMC::Service
|
6
|
+
class Bind < Base
|
7
|
+
desc "Bind a service to an application"
|
8
|
+
group :services, :manage
|
9
|
+
input :service, :desc => "Service to bind", :argument => true,
|
10
|
+
:from_given => by_name(:service_instance, "service")
|
11
|
+
input :app, :desc => "Application to bind to", :argument => true,
|
12
|
+
:from_given => by_name(:app)
|
13
|
+
def bind_service
|
14
|
+
app = input[:app]
|
15
|
+
service = input[:service, app]
|
16
|
+
|
17
|
+
with_progress(
|
18
|
+
"Binding #{c(service.name, :name)} to #{c(app.name, :name)}") do |s|
|
19
|
+
if app.binds?(service)
|
20
|
+
s.skip do
|
21
|
+
err "App #{b(app.name)} already binds #{b(service.name)}."
|
22
|
+
end
|
23
|
+
else
|
24
|
+
app.bind(service)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def ask_service(app)
|
32
|
+
services = client.service_instances
|
33
|
+
fail "No services." if services.empty?
|
34
|
+
|
35
|
+
ask "Which service?", :choices => services - app.services,
|
36
|
+
:display => proc(&:name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def ask_app
|
40
|
+
ask "Which application?", :choices => client.apps,
|
41
|
+
:display => proc(&:name)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "vmc/detect"
|
2
|
+
|
3
|
+
require "vmc/cli/service/base"
|
4
|
+
|
5
|
+
module VMC::Service
|
6
|
+
class Binding < Base
|
7
|
+
desc "Unbind a service from an application"
|
8
|
+
group :services, :manage
|
9
|
+
input :service, :desc => "Service to unbind", :argument => true,
|
10
|
+
:from_given => by_name(:service, :service_instance)
|
11
|
+
input :app, :desc => "Application to unbind from", :argument => true,
|
12
|
+
:from_given => by_name(:app)
|
13
|
+
def unbind_service
|
14
|
+
app = input[:app]
|
15
|
+
service = input[:service, app]
|
16
|
+
|
17
|
+
with_progress(
|
18
|
+
"Unbinding #{c(service.name, :name)} from #{c(app.name, :name)}") do
|
19
|
+
app.unbind(service)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def ask_service(app)
|
26
|
+
services = app.services
|
27
|
+
fail "No bound services." if services.empty?
|
28
|
+
|
29
|
+
ask "Which service?", :choices => services,
|
30
|
+
:display => proc(&:name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def ask_app
|
34
|
+
ask "Which application?", :choices => client.apps,
|
35
|
+
:display => proc(&:name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/vmc/cli/space/spaces.rb
CHANGED
@@ -19,13 +19,13 @@ module VMC::Space
|
|
19
19
|
org = input[:organization]
|
20
20
|
spaces =
|
21
21
|
with_progress("Getting spaces in #{c(org.name, :name)}") do
|
22
|
-
org.spaces
|
22
|
+
org.spaces(:depth => quiet? ? 0 : 1)
|
23
23
|
end
|
24
24
|
|
25
25
|
line unless quiet?
|
26
26
|
|
27
|
-
spaces.
|
28
|
-
space_matches?(s, input)
|
27
|
+
spaces.reject! do |s|
|
28
|
+
!space_matches?(s, input)
|
29
29
|
end
|
30
30
|
|
31
31
|
if input[:one_line]
|
data/lib/vmc/cli/start/base.rb
CHANGED
@@ -38,14 +38,8 @@ module VMC
|
|
38
38
|
changed_org = false
|
39
39
|
|
40
40
|
if input.given?(:organization) || !org_valid?(info[:organization])
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
if orgs.size == 1 && !input.given?(:organization)
|
45
|
-
org = orgs.first
|
46
|
-
else
|
47
|
-
org = input[:organization, orgs.sort_by(&:name)]
|
48
|
-
end
|
41
|
+
org = input[:organization]
|
42
|
+
return unless org
|
49
43
|
|
50
44
|
with_progress("Switching to organization #{c(org.name, :name)}") do
|
51
45
|
info[:organization] = org.guid
|
@@ -57,24 +51,8 @@ module VMC
|
|
57
51
|
|
58
52
|
# switching org means switching space
|
59
53
|
if changed_org || input.given?(:space) || !space_valid?(info[:space])
|
60
|
-
|
61
|
-
|
62
|
-
if spaces.empty?
|
63
|
-
if changed_org
|
64
|
-
line c("There are no spaces in #{b(org.name)}.", :warning)
|
65
|
-
line "You may want to create one with #{c("create-space", :good)}."
|
66
|
-
return
|
67
|
-
else
|
68
|
-
fail "No spaces!"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
if spaces.size == 1 && !input.given?(:space)
|
73
|
-
space = spaces.first
|
74
|
-
else
|
75
|
-
line if changed_org && input.interactive?(:organization)
|
76
|
-
space = input[:space, spaces.sort_by(&:name)]
|
77
|
-
end
|
54
|
+
space = input[:space, org]
|
55
|
+
return unless space
|
78
56
|
|
79
57
|
with_progress("Switching to space #{c(space.name, :name)}") do
|
80
58
|
info[:space] = space.guid
|
data/lib/vmc/cli/start/login.rb
CHANGED
@@ -9,14 +9,38 @@ module VMC::Start
|
|
9
9
|
:desc => "Account email"
|
10
10
|
input :password, :desc => "Account password"
|
11
11
|
input(:organization, :aliases => ["--org", "-o"],
|
12
|
-
:from_given =>
|
13
|
-
:desc => "Organization") {
|
14
|
-
|
12
|
+
:from_given => by_name("organization"),
|
13
|
+
:desc => "Organization") {
|
14
|
+
orgs = client.organizations(:depth => 0)
|
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
|
15
29
|
}
|
16
30
|
input(:space, :alias => "-s",
|
17
|
-
:from_given =>
|
18
|
-
:desc => "Space") { |
|
19
|
-
|
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
|
20
44
|
}
|
21
45
|
def login
|
22
46
|
show_context
|
data/lib/vmc/cli/start/target.rb
CHANGED
@@ -7,14 +7,38 @@ module VMC::Start
|
|
7
7
|
group :start
|
8
8
|
input :url, :argument => :optional, :desc => "Target URL to switch to"
|
9
9
|
input(:organization, :aliases => ["--org", "-o"],
|
10
|
-
:from_given =>
|
11
|
-
:desc => "Organization") {
|
12
|
-
|
10
|
+
:from_given => by_name("organization"),
|
11
|
+
:desc => "Organization") {
|
12
|
+
orgs = client.organizations(:depth => 0)
|
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
|
13
27
|
}
|
14
28
|
input(:space, :alias => "-s",
|
15
|
-
:from_given =>
|
16
|
-
:desc => "Space") { |
|
17
|
-
|
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
|
18
42
|
}
|
19
43
|
def target
|
20
44
|
if !input.given?(:url) && !input.given?(:organization) && !input.given?(:space)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module VMC::Start
|
2
|
+
module TargetInteractions
|
3
|
+
def ask_organization
|
4
|
+
orgs = client.organizations(:depth => 0)
|
5
|
+
|
6
|
+
if orgs.empty?
|
7
|
+
unless quiet?
|
8
|
+
line
|
9
|
+
line c("There are no organizations.", :warning)
|
10
|
+
line "You may want to create one with #{c("create-org", :good)}."
|
11
|
+
end
|
12
|
+
elsif orgs.size == 1 && !input.interactive?(:organization)
|
13
|
+
orgs.first
|
14
|
+
else
|
15
|
+
ask("Organization",
|
16
|
+
:choices => orgs.sort_by(&:name),
|
17
|
+
:display => proc(&:name))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def ask_space(org)
|
22
|
+
spaces = org.spaces(:depth => 0)
|
23
|
+
|
24
|
+
if spaces.empty?
|
25
|
+
unless quiet?
|
26
|
+
line
|
27
|
+
line c("There are no spaces in #{b(org.name)}.", :warning)
|
28
|
+
line "You may want to create one with #{c("create-space", :good)}."
|
29
|
+
end
|
30
|
+
else
|
31
|
+
ask("Space", :choices => spaces, :display => proc(&:name))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "vmc/cli/user/base"
|
2
|
+
|
3
|
+
module VMC::User
|
4
|
+
class Create < Base
|
5
|
+
desc "Create a user"
|
6
|
+
group :admin, :user, :hidden => true
|
7
|
+
input :email, :desc => "User email", :argument => true
|
8
|
+
input :password, :desc => "User password"
|
9
|
+
input :verify, :desc => "Repeat password"
|
10
|
+
def create_user
|
11
|
+
email = input[:email]
|
12
|
+
password = input[:password]
|
13
|
+
|
14
|
+
if !force? && password != input[:verify]
|
15
|
+
fail "Passwords don't match."
|
16
|
+
end
|
17
|
+
|
18
|
+
with_progress("Creating user") do
|
19
|
+
client.register(email, password)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
alias_command :create_user, :add_user
|
24
|
+
|
25
|
+
def ask_email
|
26
|
+
ask("Email")
|
27
|
+
end
|
28
|
+
|
29
|
+
def ask_password
|
30
|
+
ask("Password", :echo => "*", :forget => true)
|
31
|
+
end
|
32
|
+
|
33
|
+
def ask_verify
|
34
|
+
ask("Verify Password", :echo => "*", :forget => true)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "vmc/cli/user/base"
|
2
|
+
|
3
|
+
module VMC::User
|
4
|
+
class Delete < Base
|
5
|
+
desc "Delete a user"
|
6
|
+
group :admin, :user, :hidden => true
|
7
|
+
input :email, :desc => "User to delete", :argument => true
|
8
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
9
|
+
:default => proc { force? || interact }
|
10
|
+
def delete_user
|
11
|
+
email = input[:email]
|
12
|
+
return unless input[:really, email]
|
13
|
+
|
14
|
+
with_progress("Deleting #{c(email, :name)}") do
|
15
|
+
client.user(email).delete!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def ask_really(email)
|
22
|
+
ask("Really delete user #{c(email, :name)}?", :default => false)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "vmc/cli/user/base"
|
2
|
+
|
3
|
+
module VMC::User
|
4
|
+
class Passwd < Base
|
5
|
+
desc "Update a user's password"
|
6
|
+
group :admin, :user, :hidden => true
|
7
|
+
input :user, :desc => "User to update", :argument => :optional,
|
8
|
+
:default => proc { client.current_user },
|
9
|
+
:from_given => proc { |email|
|
10
|
+
if v2? && client.current_user.email != email
|
11
|
+
fail "You can only change your own password on V2."
|
12
|
+
else
|
13
|
+
client.user(email)
|
14
|
+
end
|
15
|
+
}
|
16
|
+
input :password, :desc => "Current password"
|
17
|
+
input :new_password, :desc => "New password"
|
18
|
+
input :verify, :desc => "Repeat new password"
|
19
|
+
def passwd
|
20
|
+
user = input[:user]
|
21
|
+
password = input[:password] if v2?
|
22
|
+
new_password = input[:new_password]
|
23
|
+
verify = input[:verify]
|
24
|
+
|
25
|
+
if new_password != verify
|
26
|
+
fail "Passwords don't match."
|
27
|
+
end
|
28
|
+
|
29
|
+
with_progress("Changing password") do
|
30
|
+
if v2?
|
31
|
+
user.change_password!(new_password, password)
|
32
|
+
else
|
33
|
+
user.password = new_password
|
34
|
+
user.update!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def ask_password
|
42
|
+
ask("Current Password", :echo => "*", :forget => true)
|
43
|
+
end
|
44
|
+
|
45
|
+
def ask_new_password
|
46
|
+
ask("New Password", :echo => "*", :forget => true)
|
47
|
+
end
|
48
|
+
|
49
|
+
def ask_verify
|
50
|
+
ask("Verify Password", :echo => "*", :forget => true)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "vmc/cli/user/base"
|
2
|
+
|
3
|
+
module VMC::User
|
4
|
+
class Users < Base
|
5
|
+
desc "List all users"
|
6
|
+
group :admin, :hidden => true
|
7
|
+
def users
|
8
|
+
users =
|
9
|
+
with_progress("Getting users") do
|
10
|
+
client.users(:depth => 0)
|
11
|
+
end
|
12
|
+
|
13
|
+
spaced(users) do |u|
|
14
|
+
display_user(u)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def display_user(u)
|
21
|
+
if quiet?
|
22
|
+
puts u.email
|
23
|
+
else
|
24
|
+
line "#{c(u.email, :name)}:"
|
25
|
+
|
26
|
+
indented do
|
27
|
+
line "admin?: #{c(u.admin?, u.admin? ? :yes : :no)}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/vmc/version.rb
CHANGED
@@ -266,12 +266,12 @@ describe VMC::App::Push do
|
|
266
266
|
end
|
267
267
|
|
268
268
|
context 'but there are no changes' do
|
269
|
-
let(:inputs) { { :restart => true} }
|
269
|
+
let(:inputs) { { :restart => true } }
|
270
270
|
|
271
|
-
it '
|
271
|
+
it 'invokes the restart command' do
|
272
272
|
stub(push).line
|
273
273
|
dont_allow(app).update!
|
274
|
-
|
274
|
+
mock(push).invoke(:restart, :app => app)
|
275
275
|
subject
|
276
276
|
end
|
277
277
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 6
|
10
|
+
version: 0.4.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Suraci
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-12-
|
18
|
+
date: 2012-12-11 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -90,12 +90,12 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
hash:
|
93
|
+
hash: 25
|
94
94
|
segments:
|
95
95
|
- 0
|
96
96
|
- 3
|
97
|
-
-
|
98
|
-
version: 0.3.
|
97
|
+
- 5
|
98
|
+
version: 0.3.5
|
99
99
|
type: :runtime
|
100
100
|
version_requirements: *id005
|
101
101
|
- !ruby/object:Gem::Dependency
|
@@ -263,12 +263,15 @@ files:
|
|
263
263
|
- lib/vmc/plugin.rb
|
264
264
|
- lib/vmc/constants.rb
|
265
265
|
- lib/vmc/cli.rb
|
266
|
+
- lib/vmc/cli/organization/create.rb
|
266
267
|
- lib/vmc/cli/organization/rename.rb
|
267
268
|
- lib/vmc/cli/organization/delete_org.rb
|
268
269
|
- lib/vmc/cli/organization/orgs.rb
|
269
270
|
- lib/vmc/cli/organization/base.rb
|
271
|
+
- lib/vmc/cli/organization/delete.rb
|
270
272
|
- lib/vmc/cli/organization/org.rb
|
271
273
|
- lib/vmc/cli/organization/create_org.rb
|
274
|
+
- lib/vmc/cli/start/target_interactions.rb
|
272
275
|
- lib/vmc/cli/start/targets.rb
|
273
276
|
- lib/vmc/cli/start/register.rb
|
274
277
|
- lib/vmc/cli/start/colors.rb
|
@@ -286,6 +289,7 @@ files:
|
|
286
289
|
- lib/vmc/cli/app/health.rb
|
287
290
|
- lib/vmc/cli/app/files.rb
|
288
291
|
- lib/vmc/cli/app/push/create.rb
|
292
|
+
- lib/vmc/cli/app/push/interactions.rb
|
289
293
|
- lib/vmc/cli/app/push/sync.rb
|
290
294
|
- lib/vmc/cli/app/rename.rb
|
291
295
|
- lib/vmc/cli/app/routes.rb
|
@@ -319,11 +323,18 @@ files:
|
|
319
323
|
- lib/vmc/cli/space/delete.rb
|
320
324
|
- lib/vmc/cli/service/service.rb
|
321
325
|
- lib/vmc/cli/service/binding.rb
|
326
|
+
- lib/vmc/cli/service/bind.rb
|
322
327
|
- lib/vmc/cli/service/create.rb
|
323
328
|
- lib/vmc/cli/service/rename.rb
|
324
329
|
- lib/vmc/cli/service/services.rb
|
330
|
+
- lib/vmc/cli/service/unbind.rb
|
325
331
|
- lib/vmc/cli/service/base.rb
|
326
332
|
- lib/vmc/cli/service/delete.rb
|
333
|
+
- lib/vmc/cli/user/passwd.rb
|
334
|
+
- lib/vmc/cli/user/create.rb
|
335
|
+
- lib/vmc/cli/user/base.rb
|
336
|
+
- lib/vmc/cli/user/delete.rb
|
337
|
+
- lib/vmc/cli/user/users.rb
|
327
338
|
- lib/vmc/cli/help.rb
|
328
339
|
- lib/vmc.rb
|
329
340
|
- spec/support/interact_helpers.rb
|