cogy 0.4.0 → 0.5.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/CHANGELOG.md +10 -0
- data/README.md +44 -29
- data/lib/cogy/capistrano/cogy.rake +2 -2
- data/lib/cogy/version.rb +1 -1
- data/lib/cogy.rb +11 -0
- data/lib/generators/cogy/templates/cogy_config.rb +1 -0
- data/test/dummy/config/initializers/cogy.rb +1 -0
- data/test/dummy/log/test.log +3276 -0
- data/test/integration/inventory_test.rb +2 -3
- metadata +3 -4
- data/lib/tasks/cogy_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8aa6c2ef3205ba369337329ccb410e7e04721f8
|
4
|
+
data.tar.gz: 8ee9376fa3a2b06846fdd32f5807753824639efc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 163f6aaf64c9d1c5e596371d81980d537122bb930a04674d8dca06a5c4411aa59a9be42e260275724899e8d39f8d9b428789edb4cd0564c217b373c17eb11694
|
7
|
+
data.tar.gz: cf617969c35eb9c9abc90f7d2534f79c76671ae9f3cf239e45452e0e74e271ae8661906e0bb680afe8d4ea46d1dd67524ade46d38209deb29fd4c03c9c95322e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.5.0 (2017-01-25)
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- The `COGY_BACKEND` env. variable is now shipped from Cogy, so you don't have
|
10
|
+
to set it in the Relays anymore ([#37](https://github.com/skroutz/cogy/issues/37)).
|
11
|
+
This has the side-effect of `Cogy.cogy_endpoint` configuration being *required*
|
12
|
+
if you use the Capistrano tasks, since they use it instead of the old,
|
13
|
+
Capistrano-specific setting.
|
14
|
+
|
5
15
|
## 0.4.0 (2016-12-05)
|
6
16
|
|
7
17
|
This release requires the [cogy-bundle](https://github.com/skroutz/cogy-bundle)
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/skroutz/cogy)
|
4
4
|
[](https://badge.fury.io/rb/cogy)
|
5
|
-
[](http://inch-ci.org/github/skroutz/cogy)
|
6
5
|
|
7
6
|
Cogy integrates [Cog](https://operable.io/) with Rails
|
8
7
|
in a way that writing & deploying commands from your application is a breeze.
|
@@ -13,13 +12,13 @@ Refer to the [Changelog](CHANGELOG.md) to see what's changed between releases.
|
|
13
12
|
|
14
13
|
## Features
|
15
14
|
|
16
|
-
-
|
17
|
-
-
|
15
|
+
- Define commands from your Rails app (see [_Usage_](#usage))
|
16
|
+
- Bundle config is generated automatically
|
18
17
|
- Commands are installed _automatically_ when you deploy (see [_Deployment_](#deployment))
|
19
|
-
-
|
20
|
-
- Customizable error
|
18
|
+
- Supports JSON responses and Cog Templates (see [_Returning JSON to COG_](#returning-json-to-cog))
|
19
|
+
- Customizable error template (see [_Error template_](#error-template))
|
21
20
|
|
22
|
-
...and more on the way!
|
21
|
+
...and [more on the way](https://github.com/skroutz/cogy/issues?q=is%3Aopen+is%3Aissue+label%3Afeature)!
|
23
22
|
|
24
23
|
## Why
|
25
24
|
|
@@ -73,7 +72,7 @@ Take a look at the relevant [diagrams](diagrams/) for a detailed illustration.
|
|
73
72
|
|
74
73
|
## Requirements
|
75
74
|
|
76
|
-
* [cogy bundle v0.
|
75
|
+
* [cogy bundle v0.4.0+](https://github.com/skroutz/cogy-bundle)
|
77
76
|
* Ruby 2.1+
|
78
77
|
* Rails 4.2 (support for Rails 5 is on the way)
|
79
78
|
|
@@ -189,7 +188,7 @@ Info on how Cog handles JSON can be found in the [official documentation](https:
|
|
189
188
|
|
190
189
|
### Templates
|
191
190
|
|
192
|
-
Templates are defined in their own files under `templates/` inside any of
|
191
|
+
[Templates](https://cog-book.operable.io/#_templates) are defined in their own files under `templates/` inside any of
|
193
192
|
the [command load paths](#Configuration). For example:
|
194
193
|
|
195
194
|
```
|
@@ -272,6 +271,10 @@ Cogy.configure do |config|
|
|
272
271
|
|
273
272
|
# The path in the Relay where the cogy command executable is located.
|
274
273
|
cogy_executable: "/cogcmd/cogy"
|
274
|
+
|
275
|
+
# The endpoint where Cogy is reachable at. This depends on where you've
|
276
|
+
# mounted the Cogy engine at.
|
277
|
+
cogy_endpoint: "http://www.example.com/cogy"
|
275
278
|
}
|
276
279
|
|
277
280
|
# Paths in your application where the files that define the commands live in.
|
@@ -350,33 +353,26 @@ is the following:
|
|
350
353
|
It can be overriden in the application by creating a view in
|
351
354
|
`app/views/cogy/error.text.erb`.
|
352
355
|
|
353
|
-
##
|
356
|
+
## Testing commands
|
354
357
|
|
355
|
-
|
356
|
-
|
357
|
-
that will perform the installation, which will be called when you deploy your
|
358
|
-
app.
|
359
|
-
|
360
|
-
The trigger will look this:
|
358
|
+
We don't yet provide means to write tests for the commands, but you can easily
|
359
|
+
test them by executing a request to your development server:
|
361
360
|
|
362
361
|
```shell
|
363
|
-
$
|
364
|
-
Name ID Enabled Pipeline
|
365
|
-
ReleaseUrlTrigger d10df83b-a737-4fc4-8d9b-bf9627412d0a true cogy:install --url $body.url > chat://#general
|
362
|
+
$ curl -XPOST --data "COG_ARGV_0=foo" http://localhost:3000/cogy/foo
|
366
363
|
```
|
367
364
|
|
368
|
-
|
369
|
-
|
370
|
-
(ie. http://your-app.com/cogy/inventory).
|
365
|
+
In the request body you may pass the complete or any part of the
|
366
|
+
[Cog environment](https://cog-book.operable.io/#_command_environment_variables) you need.
|
371
367
|
|
372
|
-
|
373
|
-
|
368
|
+
This is essentially what the [cogy executable](https://github.com/skroutz/cogy-bundle)
|
369
|
+
also does.
|
374
370
|
|
375
371
|
## Deployment
|
376
372
|
|
377
|
-
Cogy provides integration with Capistrano 2
|
373
|
+
Cogy provides integration with Capistrano 2 & 3.
|
378
374
|
|
379
|
-
There is
|
375
|
+
There is just one task, `cogy:notify_cog`, which executes the
|
380
376
|
[installation Trigger](#installation-trigger).
|
381
377
|
|
382
378
|
The task should run
|
@@ -386,10 +382,9 @@ example, it should run after the built-in `deploy:restart` task.
|
|
386
382
|
|
387
383
|
The following options need to be set:
|
388
384
|
|
385
|
+
* `Cogy.cogy_endpoint`: See [*Configuration*](#Configuration).
|
389
386
|
* `cogy_release_trigger_url`: This is the URL of the Cog Trigger that will
|
390
387
|
install the newly deployed bundle (ie. `!cogy:install`).
|
391
|
-
* `cogy_endpoint`: Where the Cogy Engine is mounted at.
|
392
|
-
For example `http://myapp.com/cogy`.
|
393
388
|
|
394
389
|
You can also configure the timeout value for the request to the Trigger by
|
395
390
|
setting the `cogy_trigger_timeout` option (default: 7).
|
@@ -405,7 +400,6 @@ Add the following in `config/deploy.rb`:
|
|
405
400
|
require "cogy/capistrano"
|
406
401
|
|
407
402
|
set :cogy_release_trigger_url, "<TRIGGER-INVOCATION-URL>"
|
408
|
-
set :cogy_endpoint, "<COGY-MOUNT-POINT>"
|
409
403
|
|
410
404
|
after "deploy:restart", "cogy:notify_cog"
|
411
405
|
```
|
@@ -424,11 +418,32 @@ Then configure the task and hook it:
|
|
424
418
|
# in config/deploy.rb
|
425
419
|
|
426
420
|
set :cogy_release_trigger_url, "<TRIGGER-INVOCATION-URL>"
|
427
|
-
set :cogy_endpoint, "<COGY-MOUNT-POINT>"
|
428
421
|
|
429
422
|
after "<app-restart-task>", "cogy:notify_cog"
|
430
423
|
```
|
431
424
|
|
425
|
+
### Installation Trigger
|
426
|
+
|
427
|
+
In order to automate the process of installing the new bundle versions
|
428
|
+
(eg. after a new command is added), you must create a [Cog Trigger](https://cog-book.operable.io/#_developing_a_trigger)
|
429
|
+
that will perform the installation, which will be called when you deploy your
|
430
|
+
app.
|
431
|
+
|
432
|
+
The trigger will look this:
|
433
|
+
|
434
|
+
```shell
|
435
|
+
$ cogctl triggers
|
436
|
+
Name ID Enabled Pipeline
|
437
|
+
ReleaseUrlTrigger d10df83b-a737-4fc4-8d9b-bf9627412d0a true cogy:install --url $body.url > chat://#general
|
438
|
+
```
|
439
|
+
|
440
|
+
It essentially uses the [cogy bundle](https://github.com/skroutz/cogy-bundle)
|
441
|
+
and installs the bundle config which is served by your application
|
442
|
+
(ie. http://your-app.com/cogy/inventory).
|
443
|
+
|
444
|
+
See [_Deployment_](#deployment) on information about how this trigger is
|
445
|
+
invoked.
|
446
|
+
|
432
447
|
## Development
|
433
448
|
|
434
449
|
Running the tests and RuboCop:
|
@@ -6,11 +6,11 @@ namespace :cogy do
|
|
6
6
|
require "json"
|
7
7
|
|
8
8
|
trigger_url = fetch(:cogy_release_trigger_url)
|
9
|
-
cogy_endpoint =
|
9
|
+
cogy_endpoint = Cogy.cogy_endpoint
|
10
10
|
|
11
11
|
begin
|
12
12
|
raise ":cogy_release_trigger_url must be set" if trigger_url.nil?
|
13
|
-
raise "
|
13
|
+
raise "Cogy.cogy_endpoint must be set" if cogy_endpoint.nil?
|
14
14
|
|
15
15
|
Timeout.timeout(fetch(:cogy_trigger_timeout) || 7) do
|
16
16
|
url = URI(trigger_url)
|
data/lib/cogy/version.rb
CHANGED
data/lib/cogy.rb
CHANGED
@@ -45,6 +45,11 @@ module Cogy
|
|
45
45
|
@@command_load_paths = ["cogy"]
|
46
46
|
mattr_accessor :command_load_paths
|
47
47
|
|
48
|
+
# The endpoint where the Cogy engine is reachable at.
|
49
|
+
# For example "http://www.example.com/cogy"
|
50
|
+
@@cogy_endpoint = nil
|
51
|
+
mattr_accessor :cogy_endpoint
|
52
|
+
|
48
53
|
# Initializes a new {Command} and registers it. All the options passed are
|
49
54
|
# used when generating the bundle config in {Cogy.bundle_config}.
|
50
55
|
#
|
@@ -129,6 +134,12 @@ module Cogy
|
|
129
134
|
if cmd.examples
|
130
135
|
config["commands"][name]["examples"] = cmd.examples
|
131
136
|
end
|
137
|
+
|
138
|
+
if Cogy.cogy_endpoint
|
139
|
+
config["commands"][name]["env_vars"] = {
|
140
|
+
"COGY_BACKEND" => Cogy.cogy_endpoint
|
141
|
+
}
|
142
|
+
end
|
132
143
|
end
|
133
144
|
|
134
145
|
config["templates"] = templates if !templates.empty?
|