cf_script 0.0.1.beta.1 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +18 -0
- data/README.md +182 -34
- data/Rakefile +0 -13
- data/lib/cf_script/command/base.rb +1 -1
- data/lib/cf_script/command/cf/apps/app.rb +1 -1
- data/lib/cf_script/command/cf/apps/apps.rb +5 -3
- data/lib/cf_script/command/cf/apps/delete.rb +25 -0
- data/lib/cf_script/command/cf/apps/env.rb +4 -2
- data/lib/cf_script/command/cf/apps/push.rb +7 -2
- data/lib/cf_script/command/cf/apps/rename.rb +20 -0
- data/lib/cf_script/command/cf/apps/restage.rb +1 -1
- data/lib/cf_script/command/cf/apps/restart.rb +1 -1
- data/lib/cf_script/command/cf/apps/set_env.rb +1 -1
- data/lib/cf_script/command/cf/apps/start.rb +1 -1
- data/lib/cf_script/command/cf/apps/stop.rb +3 -2
- data/lib/cf_script/command/cf/apps/unset_env.rb +1 -1
- data/lib/cf_script/command/cf/apps.rb +5 -1
- data/lib/cf_script/command/cf/general/api.rb +1 -1
- data/lib/cf_script/command/cf/general/auth.rb +1 -1
- data/lib/cf_script/command/cf/general/login.rb +1 -1
- data/lib/cf_script/command/cf/general/logout.rb +1 -1
- data/lib/cf_script/command/cf/general/target.rb +1 -1
- data/lib/cf_script/command/cf/routes/check_route.rb +1 -1
- data/lib/cf_script/command/cf/routes/create_route.rb +1 -1
- data/lib/cf_script/command/cf/routes/delete_route.rb +5 -2
- data/lib/cf_script/command/cf/routes/map_route.rb +1 -1
- data/lib/cf_script/command/cf/routes/routes.rb +1 -1
- data/lib/cf_script/command/cf/routes/unmap_route.rb +1 -1
- data/lib/cf_script/command/cf/spaces/space.rb +1 -1
- data/lib/cf_script/command/cf/spaces/spaces.rb +1 -1
- data/lib/cf_script/command/runner.rb +1 -15
- data/lib/cf_script/config.rb +3 -1
- data/lib/cf_script/executor/recorder.rb +3 -1
- data/lib/cf_script/executor/simple.rb +22 -9
- data/lib/cf_script/executor.rb +0 -1
- data/lib/cf_script/object/api_endpoint.rb +1 -1
- data/lib/cf_script/object/app_info.rb +1 -1
- data/lib/cf_script/object/app_list.rb +21 -5
- data/lib/cf_script/object/attribute.rb +1 -1
- data/lib/cf_script/object/attribute_list.rb +1 -1
- data/lib/cf_script/object/instance_status.rb +1 -1
- data/lib/cf_script/object/route_info.rb +1 -1
- data/lib/cf_script/object/space.rb +1 -1
- data/lib/cf_script/object/target.rb +1 -1
- data/lib/cf_script/object.rb +0 -11
- data/lib/cf_script/output/buffer.rb +1 -1
- data/lib/cf_script/scope/app/routes.rb +1 -1
- data/lib/cf_script/scope/app.rb +0 -26
- data/lib/cf_script/scope/target.rb +7 -1
- data/lib/cf_script/ui.rb +2 -6
- data/lib/cf_script/version.rb +1 -1
- data/lib/cf_script.rb +0 -2
- data/test/fixtures/commands/apps/delete/good.yml +8 -0
- data/test/fixtures/commands/apps/delete/not_exist.yml +9 -0
- data/test/fixtures/commands/apps/env/{empty.yml → empty_vars.yml} +0 -0
- data/test/fixtures/commands/apps/rename/good.yml +8 -0
- data/test/fixtures/commands/apps/rename/not_found.yml +8 -0
- data/test/fixtures/commands/{apps/set_env → common}/empty.yml +0 -0
- data/test/lib/cf_script/command/cf/apps/app_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/apps_test.rb +12 -3
- data/test/lib/cf_script/command/cf/apps/delete_test.rb +51 -0
- data/test/lib/cf_script/command/cf/apps/env_test.rb +12 -2
- data/test/lib/cf_script/command/cf/apps/push_test.rb +14 -0
- data/test/lib/cf_script/command/cf/apps/rename_test.rb +35 -0
- data/test/lib/cf_script/command/cf/apps/restage_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/restart_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/start_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/stop_test.rb +2 -2
- data/test/lib/cf_script/command/cf/general/login_test.rb +9 -10
- data/test/lib/cf_script/command/cf/routes/create_route_test.rb +12 -0
- data/test/lib/cf_script/command/cf/routes/delete_route_test.rb +18 -0
- data/test/lib/cf_script/command/cf/routes/map_route_test.rb +12 -0
- data/test/lib/cf_script/command/cf/routes/routes_test.rb +8 -0
- data/test/lib/cf_script/command/cf/routes/unmap_route_test.rb +12 -0
- data/test/lib/cf_script/object/app_info_test.rb +4 -4
- data/test/lib/cf_script/object/app_list_test.rb +68 -2
- data/test/lib/cf_script/output/buffer_test.rb +9 -9
- data/test/lib/cf_script/output/parser/section_test.rb +4 -2
- data/test/lib/cf_script/output/tests_test.rb +24 -24
- data/test/lib/cf_script/output_test.rb +23 -18
- data/test/lib/cf_script/scope/app/env_test.rb +58 -0
- data/test/lib/cf_script/scope/app/routes_test.rb +56 -0
- data/test/lib/cf_script/scope/app/state_test.rb +30 -0
- data/test/lib/cf_script/scope/script_test.rb +3 -2
- data/test/lib/cf_script/scope/target_test.rb +38 -23
- data/test/lib/cf_script/scope_test.rb +10 -6
- data/test/lib/cf_script/ui_test.rb +133 -0
- data/test/lib/cf_script_test.rb +14 -8
- data/test/support/assertions.rb +25 -0
- data/test/support/helpers/fixture_executor.rb +1 -1
- data/test/support/helpers/mock_execution.rb +29 -7
- metadata +23 -14
- data/lib/cf_script/callbacks.rb +0 -43
- data/lib/cf_script/executor/non_blocking.rb +0 -107
- data/lib/cf_script/object/app_spec.rb +0 -55
- data/test/fixtures/commands/apps/unset_env/empty.yml +0 -5
- data/test/fixtures/commands/general/auth/empty.yml +0 -5
- data/test/fixtures/commands/general/target/empty.yml +0 -5
- data/test/fixtures/commands/spaces/space/empty.yml +0 -5
- data/test/fixtures/commands/spaces/spaces/empty.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b3fcbadbf41b6e1480c5762c3f7552b438b4a15
|
4
|
+
data.tar.gz: 5674005bd8d20ad77fecadf0b0480226e955bbee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ea902b29a98636d2bd71e7dad70b58aa35cdfd133f461ff93121c54afa2592fe2dc70a3d82f1fd1b858cbdfa11449ca7fd40d076fa9cdc4df29d22c9fda156
|
7
|
+
data.tar.gz: b82c13b445f07e7b92c9882404c9185d9931e25fb0c375eb0838d0cc62519a78f45db737b0c6b72e7376c92e974e919731875477f4c9c746901c16c7ed843076
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
branches:
|
4
|
+
only:
|
5
|
+
- master
|
6
|
+
|
7
|
+
before_script:
|
8
|
+
- wget http://go-cli.s3-website-us-east-1.amazonaws.com/releases/latest/cf-linux-amd64.tgz -O /tmp/cf-linux-amd64.tgz
|
9
|
+
- tar -xvf /tmp/cf-linux-amd64.tgz
|
10
|
+
- export PATH=$PATH:$PWD/
|
11
|
+
|
12
|
+
rvm:
|
13
|
+
- '2.0.0'
|
14
|
+
- '2.1.8'
|
15
|
+
- '2.2.4'
|
16
|
+
- '2.3.0'
|
17
|
+
|
18
|
+
script: 'bundle exec rake test'
|
data/README.md
CHANGED
@@ -1,23 +1,38 @@
|
|
1
1
|
# CfScript
|
2
|
+
[![Gem Version](https://img.shields.io/gem/v/cf_script.svg)](https://rubygems.org/gems/cf_script) [![Build Status](https://secure.travis-ci.org/ammar/cf_script.png?branch=master)](http://travis-ci.org/ammar/cf_script)
|
2
3
|
|
3
|
-
CfScript is a DSL for scripting
|
4
|
+
CfScript is a DSL for scripting the Cloud Foundry CLI, with a focus
|
5
|
+
on application deployment and management. _[See Supported Commands](#supported-commands)_
|
4
6
|
|
5
7
|
```ruby
|
8
|
+
# example.rb
|
6
9
|
require 'cf_script'
|
7
10
|
|
8
|
-
cf space:
|
11
|
+
cf space: :development do
|
9
12
|
workers = apps ending_with: 'worker'
|
10
13
|
|
11
14
|
workers.each do |worker|
|
12
15
|
app worker do
|
16
|
+
show :state, :memory, :instances
|
17
|
+
|
18
|
+
stop if started?
|
19
|
+
|
20
|
+
progress 'Setting ENV variable...'
|
13
21
|
set_env 'SOME_NAME', 'SOME_VALUE'
|
14
22
|
|
15
|
-
|
23
|
+
progress "Restaging #{name} in #{current_space}..."
|
24
|
+
restage
|
16
25
|
end
|
17
26
|
end
|
18
27
|
end
|
19
28
|
```
|
20
29
|
|
30
|
+
To see the cf commands that get executed, run with TRACE=1.
|
31
|
+
```
|
32
|
+
TRACE=1 ruby example.rb
|
33
|
+
```
|
34
|
+
|
35
|
+
---
|
21
36
|
## Requirements
|
22
37
|
|
23
38
|
* `ruby` >= 2.0
|
@@ -28,48 +43,161 @@ end
|
|
28
43
|
|
29
44
|
Install the gem with:
|
30
45
|
|
31
|
-
|
46
|
+
```gem install cf_script --pre```
|
32
47
|
|
33
48
|
Or, add it to your project's `Gemfile`:
|
34
49
|
|
35
|
-
```gem 'cf_script', '0.1.
|
50
|
+
```gem 'cf_script', '0.0.1.beta.1'```
|
36
51
|
|
37
52
|
---
|
53
|
+
## Execution Scopes
|
54
|
+
|
55
|
+
There are three execution scopes/blocks; `cf`, `space`, and `app`:
|
56
|
+
|
57
|
+
### The `cf` Block Scope
|
58
|
+
The `cf` scope is the top-level scope, it includes evertything between the
|
59
|
+
`do/end` following a call to `cf`. The scope saves the current target on
|
60
|
+
entry and restores it on exit.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
# cf target => staging
|
64
|
+
|
65
|
+
cf space: :development do
|
66
|
+
# cf target => development
|
67
|
+
end
|
68
|
+
|
69
|
+
# cf target => staging
|
70
|
+
```
|
71
|
+
|
72
|
+
The `cf` block accepts the following options:
|
73
|
+
|
74
|
+
- `api`: Sets the API endpoint _(optional)_
|
75
|
+
- `org`: Sets the target organization _(optional)_
|
76
|
+
- `username`/`password`: Credentials to use for logging in. _(optional)_
|
77
|
+
- `space`: Sets the target space _(optional)_
|
78
|
+
|
79
|
+
_**Note**: To save the current target the `cf` block will execute `cf target`
|
80
|
+
on entry, and if it changed within the block, it wil execute `cf target SPACE`
|
81
|
+
on exit to restore it._
|
38
82
|
|
83
|
+
|
84
|
+
### The `space` Block Scope
|
85
|
+
The `space` scope is a sub-scope and can only appear within a `cf` block. It
|
86
|
+
also saves the current target on entry and restores, if changed, it on exit.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
# before cf block, target => staging
|
90
|
+
|
91
|
+
cf space: :development do
|
92
|
+
# inside cf block, target => development
|
93
|
+
|
94
|
+
space :production do
|
95
|
+
# inside space block, target => production
|
96
|
+
end
|
97
|
+
|
98
|
+
# still inside cf block, target => development
|
99
|
+
end
|
100
|
+
|
101
|
+
# after cf block, target => staging
|
102
|
+
```
|
103
|
+
|
104
|
+
### The `app` Block Scope
|
105
|
+
The `app` scope can appear within a `cf` or `space` blocks. Within the block
|
106
|
+
the selected app is the target of commands, this means that commands that take
|
107
|
+
an application name as their first argument can be called without it.
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
cf do
|
111
|
+
app :api do
|
112
|
+
env.each do |name, value|
|
113
|
+
unset_env name
|
114
|
+
end
|
115
|
+
|
116
|
+
started? ? restart : start
|
117
|
+
end
|
118
|
+
end
|
119
|
+
```
|
120
|
+
|
121
|
+
The `app` method accepts a string or an AppInfo object as a name argument.
|
122
|
+
|
123
|
+
## Command Methods
|
124
|
+
|
125
|
+
### The `apps` Method
|
126
|
+
The `apps` method mirrors the `cf apps` command. When called without a block,
|
127
|
+
it returns an AppList object that acts as an array of AppInfo objects, each
|
128
|
+
of which contains the information in each row output by `cf apps`.
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
cf do
|
132
|
+
# Get the list of AppInfo objects
|
133
|
+
space_apps = apps
|
134
|
+
|
135
|
+
# Iterate over the AppInfo objects
|
136
|
+
apps.each do |app_info|
|
137
|
+
# ...
|
138
|
+
end
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
142
|
+
When the `apps` method is called with a block, it excutes the block within the
|
143
|
+
context of each app.
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
cf do
|
147
|
+
apps do
|
148
|
+
started? ? restart : start
|
149
|
+
end
|
150
|
+
end
|
151
|
+
```
|
152
|
+
|
153
|
+
This is equivalent to:
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
cf do
|
157
|
+
apps.each do |app_info|
|
158
|
+
app app_info do
|
159
|
+
started? ? restart : start
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
```
|
164
|
+
|
165
|
+
---
|
39
166
|
## Supported Commands
|
40
167
|
|
41
168
|
| Commands | CLI command | ⋯ |
|
42
|
-
|
43
|
-
| **General**
|
44
|
-
|  
|
45
|
-
|  
|
46
|
-
|  
|
47
|
-
|  
|
48
|
-
|  
|
49
|
-
| **Applications**
|
50
|
-
|  
|
51
|
-
|  
|
52
|
-
|  
|
53
|
-
|  
|
54
|
-
|  
|
55
|
-
|  
|
56
|
-
|  
|
57
|
-
|  
|
58
|
-
|  
|
59
|
-
|  
|
60
|
-
|
|
61
|
-
|  
|
62
|
-
|
|
63
|
-
|  
|
64
|
-
|  
|
65
|
-
|  
|
66
|
-
|  
|
67
|
-
|
|
68
|
-
|  
|
69
|
-
|
|
169
|
+
|:--------------------------------------|:--------------------------------------------------------|:--------:|
|
170
|
+
| _**General**_ | | |
|
171
|
+
|   api | `cf api URL` | ✓ |
|
172
|
+
|   auth | `cf auth USER PASSWORD` | ✓ |
|
173
|
+
|   login | `cf login -u USER -p PASSWORD [OPTIONS]` | ✓ |
|
174
|
+
|   logout | `cf logout` | ✓ |
|
175
|
+
|   target | `cf target [-s SPACE -o ORG]` | ✓ |
|
176
|
+
| _**Applications**_ | | |
|
177
|
+
|   apps | `cf apps` | ✓ |
|
178
|
+
|   app | `cf app APP_NAME` | ✓ |
|
179
|
+
|   start | `cf start APP_NAME` | ✓ |
|
180
|
+
|   stop | `cf stop APP_NAME` | ✓ |
|
181
|
+
|   restart | `cf restart APP_NAME` | ✓ |
|
182
|
+
|   push | `cf push APP_NAME [OPTIONS]` | ✓ |
|
183
|
+
|   restage | `cf restage APP_NAME` | ✓ |
|
184
|
+
|   rename | `cf rename APP_NAME NEW_APP_NAME` | ✓ |
|
185
|
+
|   delete | `cf delete APP_NAME [-f -r]` | ✓ |
|
186
|
+
|   env | `cf env APP_NAME` | ✓ |
|
187
|
+
|   set-env | `cf set-env APP_NAME VAR_NAME VAR_VALUE` | ✓ |
|
188
|
+
|   unset-env | `cf unset-env APP_NAME VAR_NAME` | ✓ |
|
189
|
+
| _**Routes**_ | | |
|
190
|
+
|   routes | `cf routes` | ✓ |
|
191
|
+
|   check-route | `cf check-route HOST DOMAIN` | ✓ |
|
192
|
+
|   create-route | `cf create-route SPACE DOMAIN [-n HOSTNAME]` | ✓ |
|
193
|
+
|   map-route | `cf map-route APP_NAME DOMAIN [-n HOSTNAME]` | ✓ |
|
194
|
+
|   unmap-route | `cf unmap-route APP_NAME DOMAIN [-n HOSTNAME]` | ✓ |
|
195
|
+
|   delete-route | `cf delete-route DOMAIN [-n HOSTNAME] [-f]` | ✓ |
|
196
|
+
| _**Spaces**_ | | |
|
197
|
+
|   spaces | `cf spaces` | ✓ |
|
198
|
+
|   space | `cf space SPACE` | ✓ |
|
70
199
|
|
71
200
|
---
|
72
|
-
|
73
201
|
## Building
|
74
202
|
The project uses the standard rubygems package tasks, so:
|
75
203
|
|
@@ -82,3 +210,23 @@ To install the gem from the cloned project, run:
|
|
82
210
|
```
|
83
211
|
rake install
|
84
212
|
```
|
213
|
+
|
214
|
+
---
|
215
|
+
## Known Problems/Limitations
|
216
|
+
|
217
|
+
* Obviously everything depends on the output of `cf`, so if that changes
|
218
|
+
things will break. This is not unique to cf_script, but it is something
|
219
|
+
worth noting. The centralized parsing of `cf`'s output should reduce
|
220
|
+
the impact of change on scripts, but there is no guarantee.
|
221
|
+
|
222
|
+
* The fixtures were collected manually and they might become a pain to
|
223
|
+
manage. Will investigate creating a tool/script that automates their
|
224
|
+
collection from `cf`.
|
225
|
+
|
226
|
+
* I18N, n'existe pas, mais, it's not impossible. If implemented, it should
|
227
|
+
be based on the latest [translation files from the `cf` repository](https://github.com/cloudfoundry/cli/tree/master/cf/i18n/resources),
|
228
|
+
and the process of pulling the files automated. In the meantime, might
|
229
|
+
explicity add LANG to the ENV variables passed to `cf`.
|
230
|
+
|
231
|
+
* Windows? No clues. Probably not without some changes.
|
232
|
+
|
data/Rakefile
CHANGED
@@ -18,16 +18,3 @@ Rake::TestTask.new('test') do |t|
|
|
18
18
|
t.libs << "test"
|
19
19
|
t.test_files = FileList['test/**/*.rb']
|
20
20
|
end
|
21
|
-
|
22
|
-
namespace :test do
|
23
|
-
%w{commands runner parser}.each do |component|
|
24
|
-
Rake::TestTask.new(component) do |t|
|
25
|
-
if t.respond_to?(:description)
|
26
|
-
t.description = "Run all #{component} unit tests under the test/#{component} directory"
|
27
|
-
end
|
28
|
-
|
29
|
-
t.libs << "test"
|
30
|
-
t.test_files = ["test/#{component}/**/*.rb"]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -25,7 +25,7 @@ module CfScript::Command
|
|
25
25
|
raise "run called in base command class"
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def good_run?(output, options = {})
|
29
29
|
options[:check_status] = options.key?(:check_status) ? options[:check_status] : true
|
30
30
|
options[:check_failed] = options.key?(:check_failed) ? options[:check_failed] : true
|
31
31
|
|
@@ -6,7 +6,7 @@ module CfScript::Command
|
|
6
6
|
|
7
7
|
def run(app_name, options = {}, &block)
|
8
8
|
run_cf self, app_name do |output|
|
9
|
-
return nil unless
|
9
|
+
return nil unless good_run?(output)
|
10
10
|
|
11
11
|
if app_info = build_app_info(app_name, output)
|
12
12
|
block_given? ? yield(app_info) : app_info
|
@@ -17,8 +17,10 @@ module CfScript::Command
|
|
17
17
|
|
18
18
|
def run(options = {}, &block)
|
19
19
|
run_cf self do |output|
|
20
|
-
|
21
|
-
|
20
|
+
blank_list = CfScript::AppList.new
|
21
|
+
|
22
|
+
return blank_list unless good_run?(output)
|
23
|
+
return blank_list if output.contains? NO_APPS_FOUND
|
22
24
|
|
23
25
|
if rows = output.table(APPS_TABLE)
|
24
26
|
list = build_app_list(rows)
|
@@ -26,7 +28,7 @@ module CfScript::Command
|
|
26
28
|
block_given? ? yield(list) : list
|
27
29
|
else
|
28
30
|
error 'rows is nil'
|
29
|
-
return
|
31
|
+
return blank_list
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module CfScript::Command
|
2
|
+
class Apps::DeleteCommand < CfScript::Command::Base
|
3
|
+
def initialize
|
4
|
+
super(:apps, :delete)
|
5
|
+
end
|
6
|
+
|
7
|
+
def run(app_name, force = false, delete_routes = false, &block)
|
8
|
+
options = { flags: [] }
|
9
|
+
|
10
|
+
options[:flags] << :f if force
|
11
|
+
options[:flags] << :r if delete_routes
|
12
|
+
|
13
|
+
run_cf self, app_name, options do |output|
|
14
|
+
return false unless good_run?(output)
|
15
|
+
|
16
|
+
if output.ok?
|
17
|
+
block_given? ? yield(true) : true
|
18
|
+
else
|
19
|
+
error "failed to delete app"
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -6,12 +6,14 @@ module CfScript::Command
|
|
6
6
|
|
7
7
|
def run(app_name, &block)
|
8
8
|
run_cf self, app_name do |output|
|
9
|
-
return {} unless
|
9
|
+
return {} unless good_run?(output)
|
10
10
|
|
11
11
|
if vars = output.section_attributes('User-Provided')
|
12
12
|
block_given? ? yield(vars.to_h) : vars.to_h
|
13
|
+
elsif output.contains?('No user-defined env variables have been set')
|
14
|
+
return {}
|
13
15
|
else
|
14
|
-
error '
|
16
|
+
error 'could not get environment variables'
|
15
17
|
return {}
|
16
18
|
end
|
17
19
|
end
|
@@ -22,9 +22,14 @@ module CfScript::Command
|
|
22
22
|
|
23
23
|
def run(app_name, options = {}, &block)
|
24
24
|
run_cf self, app_name, translate_options(options.dup) do |output|
|
25
|
-
return unless
|
25
|
+
return unless good_run?(output, check_failed: false)
|
26
26
|
|
27
|
-
|
27
|
+
no_start = options.key?(:flags) &&
|
28
|
+
options[:flags].include?(:no_start)
|
29
|
+
|
30
|
+
if no_start && output.ok?
|
31
|
+
return true
|
32
|
+
elsif app = build_app_info(app_name, output)
|
28
33
|
block_given? ? yield(app) : app
|
29
34
|
else
|
30
35
|
error "app is nil"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CfScript::Command
|
2
|
+
class Apps::RenameCommand < CfScript::Command::Base
|
3
|
+
def initialize
|
4
|
+
super(:apps, :rename)
|
5
|
+
end
|
6
|
+
|
7
|
+
def run(old_name, new_name, &block)
|
8
|
+
run_cf self, old_name, new_name do |output|
|
9
|
+
return false unless good_run?(output, check_failed: false)
|
10
|
+
|
11
|
+
if output.ok?
|
12
|
+
block_given? ? yield(true) : true
|
13
|
+
else
|
14
|
+
error "failed to rename app"
|
15
|
+
return false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,12 +6,13 @@ module CfScript::Command
|
|
6
6
|
|
7
7
|
def run(app_name, &block)
|
8
8
|
run_cf self, app_name do |output|
|
9
|
-
return false unless
|
9
|
+
return false unless good_run?(output, check_failed: false)
|
10
10
|
|
11
11
|
if output.ok?
|
12
12
|
block_given? ? yield(true) : true
|
13
13
|
else
|
14
|
-
error "failed to stop"
|
14
|
+
error "failed to stop app"
|
15
|
+
return false
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -17,7 +17,7 @@ module CfScript::Command
|
|
17
17
|
'Showing health and status for app'
|
18
18
|
)
|
19
19
|
|
20
|
-
|
20
|
+
unless attributes.empty?
|
21
21
|
app = CfScript::AppInfo.new(app_name, attributes)
|
22
22
|
|
23
23
|
if rows = output.table(INSTANCE_STATUS_TABLE)
|
@@ -40,6 +40,8 @@ require 'cf_script/command/cf/apps/restage'
|
|
40
40
|
require 'cf_script/command/cf/apps/env'
|
41
41
|
require 'cf_script/command/cf/apps/set_env'
|
42
42
|
require 'cf_script/command/cf/apps/unset_env'
|
43
|
+
require 'cf_script/command/cf/apps/rename'
|
44
|
+
require 'cf_script/command/cf/apps/delete'
|
43
45
|
|
44
46
|
module CfScript::Command::Apps
|
45
47
|
CfScript::Command.register AppsCommand
|
@@ -52,4 +54,6 @@ module CfScript::Command::Apps
|
|
52
54
|
CfScript::Command.register EnvCommand
|
53
55
|
CfScript::Command.register SetEnvCommand
|
54
56
|
CfScript::Command.register UnsetEnvCommand
|
57
|
+
CfScript::Command.register RenameCommand
|
58
|
+
CfScript::Command.register DeleteCommand
|
55
59
|
end
|
@@ -6,7 +6,7 @@ module CfScript::Command::General
|
|
6
6
|
|
7
7
|
def run(username, password, &block)
|
8
8
|
run_cf self, username, password do |output|
|
9
|
-
unless
|
9
|
+
unless good_run?(output, check_failed: false)
|
10
10
|
if output.credentials_rejected?
|
11
11
|
error 'Credentials were rejected'
|
12
12
|
else
|
@@ -11,7 +11,7 @@ module CfScript::Command
|
|
11
11
|
space = args.first && args.first.key?(:s) ? args.first[:s] : ''
|
12
12
|
|
13
13
|
run_cf self, *args do |output|
|
14
|
-
return nil unless
|
14
|
+
return nil unless good_run?(output, check_failed: false)
|
15
15
|
|
16
16
|
# TODO: check org not found too
|
17
17
|
|
@@ -8,7 +8,7 @@ module CfScript::Command
|
|
8
8
|
options = host ? { n: host } : {}
|
9
9
|
|
10
10
|
run_cf self, space, domain, options do |output|
|
11
|
-
return false unless
|
11
|
+
return false unless good_run?(output)
|
12
12
|
|
13
13
|
if exists = output.contains?(/^OK$/)
|
14
14
|
block_given? ? yield(exists) : exists
|
@@ -5,10 +5,13 @@ module CfScript::Command
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def run(domain, host = nil, force = true, &block)
|
8
|
-
options =
|
8
|
+
options = {}
|
9
|
+
|
10
|
+
options[:n] = host if host
|
11
|
+
options[:flags] = [:f] if force
|
9
12
|
|
10
13
|
run_cf self, domain, options do |output|
|
11
|
-
return false unless
|
14
|
+
return false unless good_run?(output)
|
12
15
|
|
13
16
|
if deleted = output.ok?
|
14
17
|
block_given? ? yield(deleted) : deleted
|