vmc 0.4.0.beta.93 → 0.4.0.beta.94
Sign up to get free protection for your applications and to get access to all the features.
- data/vmc-ng/Rakefile +21 -30
- data/vmc-ng/lib/vmc.rb +4 -3
- data/vmc-ng/lib/vmc/cli.rb +10 -9
- data/vmc-ng/lib/vmc/cli/app/app.rb +45 -0
- data/vmc-ng/lib/vmc/cli/app/apps.rb +97 -0
- data/vmc-ng/lib/vmc/cli/app/base.rb +82 -0
- data/vmc-ng/lib/vmc/cli/app/crashes.rb +41 -0
- data/vmc-ng/lib/vmc/cli/app/delete.rb +90 -0
- data/vmc-ng/lib/vmc/cli/app/deprecated.rb +11 -0
- data/vmc-ng/lib/vmc/cli/app/env.rb +86 -0
- data/vmc-ng/lib/vmc/cli/app/files.rb +85 -0
- data/vmc-ng/lib/vmc/cli/app/health.rb +27 -0
- data/vmc-ng/lib/vmc/cli/app/instances.rb +49 -0
- data/vmc-ng/lib/vmc/cli/app/logs.rb +80 -0
- data/vmc-ng/lib/vmc/cli/app/push.rb +336 -0
- data/vmc-ng/lib/vmc/cli/app/rename.rb +31 -0
- data/vmc-ng/lib/vmc/cli/app/restart.rb +23 -0
- data/vmc-ng/lib/vmc/cli/app/routes.rb +97 -0
- data/vmc-ng/lib/vmc/cli/app/scale.rb +67 -0
- data/vmc-ng/lib/vmc/cli/app/start.rb +96 -0
- data/vmc-ng/lib/vmc/cli/app/stats.rb +68 -0
- data/vmc-ng/lib/vmc/cli/app/stop.rb +29 -0
- data/vmc-ng/lib/vmc/cli/domain/add_domain.rb +27 -0
- data/vmc-ng/lib/vmc/cli/domain/base.rb +12 -0
- data/vmc-ng/lib/vmc/cli/domain/create_domain.rb +31 -0
- data/vmc-ng/lib/vmc/cli/domain/delete_domain.rb +51 -0
- data/vmc-ng/lib/vmc/cli/domain/domains.rb +43 -0
- data/vmc-ng/lib/vmc/cli/domain/remove_domain.rb +26 -0
- data/vmc-ng/lib/vmc/cli/help.rb +0 -1
- data/vmc-ng/lib/vmc/cli/interactive.rb +4 -0
- data/vmc-ng/lib/vmc/cli/route/base.rb +12 -0
- data/vmc-ng/lib/vmc/cli/route/create_route.rb +42 -0
- data/vmc-ng/lib/vmc/cli/route/delete_route.rb +42 -0
- data/vmc-ng/lib/vmc/cli/route/routes.rb +26 -0
- data/vmc-ng/lib/vmc/detect.rb +2 -2
- data/vmc-ng/lib/vmc/spec_helper.rb +1 -0
- data/vmc-ng/lib/vmc/version.rb +1 -1
- data/vmc-ng/spec/cli/app/push_spec.rb +34 -0
- data/vmc-ng/spec/cli/app/rename_spec.rb +108 -0
- data/vmc-ng/spec/cli/route/delete_route_spec.rb +160 -0
- data/vmc-ng/spec/detect_spec.rb +54 -0
- data/vmc-ng/spec/factories/app_factory.rb +9 -0
- data/vmc-ng/spec/factories/client_factory.rb +16 -0
- data/vmc-ng/spec/factories/domain_factory.rb +9 -0
- data/vmc-ng/spec/factories/factory.rb +3 -0
- data/vmc-ng/spec/factories/framework_factory.rb +9 -0
- data/vmc-ng/spec/factories/route_factory.rb +10 -0
- data/vmc-ng/spec/spec_helper.rb +17 -0
- data/vmc-ng/spec/support/interact_helpers.rb +23 -0
- metadata +135 -62
- data/vmc-ng/lib/vmc/cli/app.rb +0 -1333
- data/vmc-ng/lib/vmc/cli/domain.rb +0 -164
- data/vmc-ng/lib/vmc/cli/route.rb +0 -106
- data/vmc-ng/lib/vmc/spec_helpers.rb +0 -431
- data/vmc-ng/lib/vmc/spec_helpers/eventlog.rb +0 -277
- data/vmc-ng/lib/vmc/spec_helpers/patches.rb +0 -94
- data/vmc-ng/spec/Rakefile +0 -13
- data/vmc-ng/spec/app/app_spec.rb +0 -19
- data/vmc-ng/spec/app/apps_spec.rb +0 -79
- data/vmc-ng/spec/app/push_spec.rb +0 -74
- data/vmc-ng/spec/assets/hello-sinatra/Gemfile +0 -2
- data/vmc-ng/spec/assets/hello-sinatra/main.rb +0 -5
- data/vmc-ng/spec/assets/hello-sinatra/manifest.yml +0 -9
- data/vmc-ng/spec/helpers.rb +0 -7
- data/vmc-ng/spec/start/target_spec.rb +0 -60
@@ -1,277 +0,0 @@
|
|
1
|
-
require "thread"
|
2
|
-
|
3
|
-
class FakeTTY
|
4
|
-
attr_accessor :event
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@input = Queue.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def getc
|
11
|
-
@input.pop
|
12
|
-
end
|
13
|
-
|
14
|
-
def fake(input)
|
15
|
-
return if @input.nil?
|
16
|
-
|
17
|
-
input.each_char do |c|
|
18
|
-
@input << c
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def close
|
23
|
-
@input = nil
|
24
|
-
end
|
25
|
-
|
26
|
-
def tty?
|
27
|
-
true
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class EventLog
|
32
|
-
attr_accessor :process
|
33
|
-
attr_reader :events, :interaction, :inputs
|
34
|
-
|
35
|
-
def initialize(input)
|
36
|
-
@input = input
|
37
|
-
|
38
|
-
@queue = Queue.new
|
39
|
-
@events = []
|
40
|
-
@inputs = {}
|
41
|
-
end
|
42
|
-
|
43
|
-
def finish_input
|
44
|
-
@input.close
|
45
|
-
end
|
46
|
-
|
47
|
-
def kill_process
|
48
|
-
@process.kill
|
49
|
-
@process.join
|
50
|
-
end
|
51
|
-
|
52
|
-
def next_event
|
53
|
-
if @queue.empty?
|
54
|
-
if @process.status == false
|
55
|
-
raise "Expected more events, but the process has finished."
|
56
|
-
elsif @process.status == nil
|
57
|
-
begin
|
58
|
-
@process.join
|
59
|
-
rescue => e
|
60
|
-
raise "Expected more events, but process has thrown an exception: #{e}."
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
val = @queue.pop
|
66
|
-
@events << val
|
67
|
-
val
|
68
|
-
end
|
69
|
-
|
70
|
-
def pending_events
|
71
|
-
events = []
|
72
|
-
|
73
|
-
until @queue.empty?
|
74
|
-
events << @queue.pop
|
75
|
-
end
|
76
|
-
|
77
|
-
events
|
78
|
-
end
|
79
|
-
|
80
|
-
def wait_for_event(type)
|
81
|
-
val = next_event
|
82
|
-
|
83
|
-
until val.is_a?(type)
|
84
|
-
if val.important?
|
85
|
-
raise "Tried to skip important event while waiting for a #{type}: #{val}"
|
86
|
-
end
|
87
|
-
|
88
|
-
val = next_event
|
89
|
-
end
|
90
|
-
|
91
|
-
val
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
def pick_random_option
|
96
|
-
options = @interaction.options
|
97
|
-
choices = options[:choices]
|
98
|
-
chosen = choices[rand(choices.size)]
|
99
|
-
|
100
|
-
if display = options[:display]
|
101
|
-
provide("#{display.call(chosen)}\n")
|
102
|
-
else
|
103
|
-
provide("#{chosen}\n")
|
104
|
-
end
|
105
|
-
|
106
|
-
chosen
|
107
|
-
end
|
108
|
-
|
109
|
-
def provide(input)
|
110
|
-
@input.fake(input)
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
def printed(line)
|
115
|
-
@queue << Printed.new(line)
|
116
|
-
end
|
117
|
-
|
118
|
-
def asking(message, options = {})
|
119
|
-
@interaction = Asked.new(message, options)
|
120
|
-
@queue << @interaction
|
121
|
-
end
|
122
|
-
|
123
|
-
def got_input(name, val)
|
124
|
-
@inputs[name] = val
|
125
|
-
@queue << GotInput.new(name, val)
|
126
|
-
end
|
127
|
-
|
128
|
-
def raised(exception)
|
129
|
-
@queue << Raised.new(exception)
|
130
|
-
end
|
131
|
-
|
132
|
-
def did(message)
|
133
|
-
@queue << Did.new(message)
|
134
|
-
end
|
135
|
-
|
136
|
-
def skipped(message)
|
137
|
-
@queue << Skipped.new(message)
|
138
|
-
end
|
139
|
-
|
140
|
-
def failed_to(message)
|
141
|
-
@queue << FailedTo.new(message)
|
142
|
-
end
|
143
|
-
|
144
|
-
def gave_up(message)
|
145
|
-
@queue << GaveUp.new(message)
|
146
|
-
end
|
147
|
-
|
148
|
-
|
149
|
-
class Event
|
150
|
-
def important?
|
151
|
-
true
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
class Printed < Event
|
156
|
-
attr_reader :line
|
157
|
-
|
158
|
-
def initialize(line)
|
159
|
-
@line = line
|
160
|
-
end
|
161
|
-
|
162
|
-
def to_s
|
163
|
-
"<Printed '#@line'>"
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
class Asked < Event
|
168
|
-
attr_reader :message, :options
|
169
|
-
|
170
|
-
def initialize(message, options = {})
|
171
|
-
@message = message
|
172
|
-
@options = options
|
173
|
-
end
|
174
|
-
|
175
|
-
def to_s
|
176
|
-
"<Asked '#@message'>"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
class GotInput < Event
|
181
|
-
attr_reader :name, :value
|
182
|
-
|
183
|
-
def initialize(name, value)
|
184
|
-
@name = name
|
185
|
-
@value = value
|
186
|
-
end
|
187
|
-
|
188
|
-
def to_s
|
189
|
-
"<GotInput #@name '#@value'>"
|
190
|
-
end
|
191
|
-
|
192
|
-
def important?
|
193
|
-
false
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
class Raised < Event
|
198
|
-
attr_reader :exception
|
199
|
-
|
200
|
-
def initialize(exception)
|
201
|
-
@exception = exception
|
202
|
-
end
|
203
|
-
|
204
|
-
def to_s
|
205
|
-
"<Raised #{@exception.class} '#@exception'>"
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
class Progress < Event
|
210
|
-
attr_reader :message
|
211
|
-
|
212
|
-
def initialize(message)
|
213
|
-
@message = message
|
214
|
-
end
|
215
|
-
|
216
|
-
def ==(other)
|
217
|
-
other.is_a?(self.class) &&
|
218
|
-
@message == other.message
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
class Did < Progress
|
223
|
-
def to_s
|
224
|
-
"<Did '#@message'>"
|
225
|
-
end
|
226
|
-
|
227
|
-
def report
|
228
|
-
"do '#@message'"
|
229
|
-
end
|
230
|
-
|
231
|
-
def report_past
|
232
|
-
"did '#@message'"
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
class Skipped < Progress
|
237
|
-
def to_s
|
238
|
-
"<Skipped '#@message'>"
|
239
|
-
end
|
240
|
-
|
241
|
-
def report
|
242
|
-
"skip '#@message'"
|
243
|
-
end
|
244
|
-
|
245
|
-
def report_past
|
246
|
-
"skipped '#@message'"
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
class FailedTo < Progress
|
251
|
-
def to_s
|
252
|
-
"<FailedTo '#@message'>"
|
253
|
-
end
|
254
|
-
|
255
|
-
def report
|
256
|
-
"fail to '#@message'"
|
257
|
-
end
|
258
|
-
|
259
|
-
def report_past
|
260
|
-
"failed to '#@message'"
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
class GaveUp < Progress
|
265
|
-
def to_s
|
266
|
-
"<GaveUp '#@message'>"
|
267
|
-
end
|
268
|
-
|
269
|
-
def report
|
270
|
-
"give up on '#@message'"
|
271
|
-
end
|
272
|
-
|
273
|
-
def report_past
|
274
|
-
"gave up on '#@message'"
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require "mothership"
|
2
|
-
require "interact"
|
3
|
-
require "vmc"
|
4
|
-
|
5
|
-
# [EventLog]
|
6
|
-
$vmc_event = nil
|
7
|
-
|
8
|
-
class VMC::CLI
|
9
|
-
def run(name)
|
10
|
-
if input[:help]
|
11
|
-
invoke :help, :command => cmd.name.to_s
|
12
|
-
else
|
13
|
-
precondition
|
14
|
-
super
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class ProgressEventReporter
|
19
|
-
def initialize(message, skipper)
|
20
|
-
@message = message
|
21
|
-
@skipper = skipper
|
22
|
-
@skipped = false
|
23
|
-
end
|
24
|
-
|
25
|
-
def skip(&blk)
|
26
|
-
@skipped = true
|
27
|
-
$vmc_event.skipped(@message)
|
28
|
-
@skipper.skip(&blk)
|
29
|
-
end
|
30
|
-
|
31
|
-
def fail(&blk)
|
32
|
-
@skipped = true
|
33
|
-
$vmc_event.failed_to(@message)
|
34
|
-
@skipper.fail(&blk)
|
35
|
-
end
|
36
|
-
|
37
|
-
def give_up(&blk)
|
38
|
-
@skipped = true
|
39
|
-
$vmc_event.gave_up(@message)
|
40
|
-
@skipper.give_up(&blk)
|
41
|
-
end
|
42
|
-
|
43
|
-
def skipped?
|
44
|
-
@skipped
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def ask(*args)
|
49
|
-
$vmc_event.asking(*args) if $vmc_event
|
50
|
-
super
|
51
|
-
end
|
52
|
-
|
53
|
-
def line(*args)
|
54
|
-
$vmc_event.printed(*args) if $vmc_event
|
55
|
-
super
|
56
|
-
end
|
57
|
-
|
58
|
-
def force?
|
59
|
-
false
|
60
|
-
end
|
61
|
-
|
62
|
-
def with_progress(msg, &blk)
|
63
|
-
super(msg) do |s|
|
64
|
-
reporter = ProgressEventReporter.new(msg, s)
|
65
|
-
|
66
|
-
res = blk.call(reporter)
|
67
|
-
|
68
|
-
$vmc_event.did(msg) unless reporter.skipped?
|
69
|
-
|
70
|
-
res
|
71
|
-
end
|
72
|
-
rescue
|
73
|
-
$vmc_event.failed_to(msg)
|
74
|
-
raise
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
class Mothership::Inputs
|
79
|
-
alias_method :vmc_spec_get, :get
|
80
|
-
|
81
|
-
def get(name, context, *args)
|
82
|
-
val = vmc_spec_get(name, context, *args)
|
83
|
-
$vmc_event.got_input(name, val) if $vmc_event
|
84
|
-
val
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
module Interactive
|
89
|
-
def set_input_state(input)
|
90
|
-
end
|
91
|
-
|
92
|
-
def restore_input_state(input, before)
|
93
|
-
end
|
94
|
-
end
|
data/vmc-ng/spec/Rakefile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
Bundler.require(:default, :development)
|
4
|
-
|
5
|
-
require 'rake/dsl_definition'
|
6
|
-
require 'rake'
|
7
|
-
require 'rspec'
|
8
|
-
require 'rspec/core/rake_task'
|
9
|
-
|
10
|
-
RSpec::Core::RakeTask.new do |t|
|
11
|
-
t.pattern = "**/*_spec.rb"
|
12
|
-
t.rspec_opts = ["--format", "documentation", "--colour"]
|
13
|
-
end
|
data/vmc-ng/spec/app/app_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require File.expand_path("../../helpers", __FILE__)
|
2
|
-
|
3
|
-
describe "App#app" do
|
4
|
-
it "shows the app name if it exists" do
|
5
|
-
with_random_app do |app|
|
6
|
-
running(:app, {}, :app => app.name) do
|
7
|
-
outputs(app.name)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it "fails if an unknown app is provided" do
|
13
|
-
running(:app, {}, :app => "unknown-app") do
|
14
|
-
raises(VMC::UserError) do |e|
|
15
|
-
e.message.should == "Unknown app 'unknown-app'"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require File.expand_path("../../helpers", __FILE__)
|
2
|
-
|
3
|
-
describe "App#apps" do
|
4
|
-
it "lists app names" do
|
5
|
-
with_random_apps do |apps|
|
6
|
-
running(:apps) do
|
7
|
-
does("Getting applications in #{client.current_space.name}")
|
8
|
-
|
9
|
-
apps.sort_by(&:name).each do |a|
|
10
|
-
outputs(a.name)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it "filters by name with --name" do
|
17
|
-
with_random_apps do |apps|
|
18
|
-
name = sample(apps).name
|
19
|
-
|
20
|
-
running(:apps, :name => name) do
|
21
|
-
does("Getting applications in #{client.current_space.name}")
|
22
|
-
|
23
|
-
apps.sort_by(&:name).each do |a|
|
24
|
-
if a.name == name
|
25
|
-
outputs(a.name)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
it "filters by runtime with --runtime" do
|
33
|
-
with_random_apps do |apps|
|
34
|
-
runtime = sample(apps).runtime
|
35
|
-
|
36
|
-
running(:apps, :runtime => runtime.name) do
|
37
|
-
does("Getting applications in #{client.current_space.name}")
|
38
|
-
|
39
|
-
apps.sort_by(&:name).each do |a|
|
40
|
-
if a.runtime =~ /#{runtime}/
|
41
|
-
outputs(a.name)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it "filters by framework with --framework" do
|
49
|
-
with_random_apps do |apps|
|
50
|
-
framework = sample(apps).framework
|
51
|
-
|
52
|
-
running(:apps, :framework => framework.name) do
|
53
|
-
does("Getting applications in #{client.current_space.name}")
|
54
|
-
|
55
|
-
apps.sort_by(&:name).each do |a|
|
56
|
-
if a.framework == framework
|
57
|
-
outputs(a.name)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
it "can be told which space with --space" do
|
65
|
-
with_new_space do |space|
|
66
|
-
with_random_apps do |other_apps|
|
67
|
-
with_random_apps(space) do |apps|
|
68
|
-
running(:apps, :space => space) do
|
69
|
-
does("Getting applications in #{space.name}")
|
70
|
-
|
71
|
-
apps.sort_by(&:name).each do |a|
|
72
|
-
outputs(a.name)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|