corl 0.5.6 → 0.5.7
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/.gitignore +10 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -0
- data/README.rdoc +125 -517
- data/Rakefile +57 -0
- data/VERSION +1 -1
- data/bootstrap/os/ubuntu/00_base.sh +10 -7
- data/bootstrap/os/ubuntu/05_ruby.sh +4 -4
- data/corl.gemspec +32 -5
- data/info/AUTOMATION.rdoc +5 -0
- data/info/INSTALLATION.rdoc +163 -0
- data/info/PACKAGING.rdoc +171 -0
- data/info/PLUGINS.rdoc +57 -0
- data/info/TODO.rdoc +27 -0
- data/lib/CORL/configuration/file.rb +2 -2
- data/lib/CORL/machine/docker.rb +327 -0
- data/lib/CORL/machine/vagrant.rb +142 -107
- data/lib/CORL/node/docker.rb +269 -0
- data/lib/CORL/node/vagrant.rb +23 -0
- data/lib/CORL/provisioner/puppetnode.rb +52 -27
- data/lib/core/facade.rb +36 -34
- data/lib/core/mixin/builder.rb +44 -44
- data/lib/core/mixin/machine/ssh.rb +34 -34
- data/lib/core/mod/vagrant.rb +32 -0
- data/lib/core/plugin/cloud_action.rb +1 -1
- data/lib/core/plugin/machine.rb +85 -85
- data/lib/core/plugin/network.rb +23 -9
- data/lib/core/plugin/node.rb +10 -7
- data/lib/core/plugin/provisioner.rb +3 -3
- data/lib/core/vagrant/action.rb +15 -13
- data/lib/core/vagrant/actions/include_overrides.rb +17 -0
- data/lib/core/vagrant/actions/init_keys.rb +9 -5
- data/lib/core/vagrant/commands/launcher.rb +1 -1
- data/lib/core/vagrant/config.rb +343 -143
- data/lib/core/vagrant/plugins.rb +14 -14
- data/lib/corl.rb +3 -7
- data/lib/nucleon/action/node/provision.rb +15 -4
- data/lib/nucleon/action/node/seed.rb +2 -2
- data/lib/nucleon/extension/vagrant.rb +30 -0
- data/locales/en.yml +5 -0
- data/rdoc/site/0.5.7/README.rdoc +595 -0
- data/rdoc/site/0.5.7/info/AUTOMATION.rdoc +382 -0
- data/rdoc/site/0.5.7/info/INSTALLATION.rdoc +543 -0
- data/rdoc/site/0.5.7/info/PACKAGES.rdoc +556 -0
- data/rdoc/site/0.5.7/info/PACKAGING.rdoc +563 -0
- data/rdoc/site/0.5.7/info/PLUGINS.rdoc +534 -0
- data/rdoc/site/0.5.7/info/TODO.rdoc +412 -0
- data/tmp/README.rdoc +217 -0
- data/tmp/info/AUTOMATION.rdoc +6 -0
- data/tmp/info/INSTALLATION.rdoc +158 -0
- data/tmp/info/PACKAGES.rdoc +177 -0
- data/tmp/info/PACKAGING.rdoc +184 -0
- data/tmp/info/PLUGINS.rdoc +129 -0
- data/tmp/info/README.rdoc +217 -0
- data/tmp/info/TODO.rdoc +36 -0
- metadata +41 -3
- data/TODO.rdoc +0 -12
data/README.rdoc
CHANGED
@@ -1,592 +1,200 @@
|
|
1
|
-
|
1
|
+
= CORL - Coral Orchestration and Research Library
|
2
2
|
|
3
|
-
[Nucleon](https://github.com/coralnexus/nucleon) plugin library and framework for building, synchronizing, and executing
|
4
|
-
distributed actions and agents across heterogenous networks.
|
5
3
|
|
6
|
-
[
|
4
|
+
{Nucleon}[https://github.com/coralnexus/nucleon] plugin library and framework
|
5
|
+
for building, synchronizing, and executing distributed actions and agents
|
6
|
+
across heterogeneous networks of machines.
|
7
7
|
|
8
8
|
|
9
|
+
== Origin and philosophy (aka: Why is this project being developed?)
|
9
10
|
|
10
11
|
|
12
|
+
This project began with the need to automate the management of our own
|
13
|
+
infrastructure architecture starting in mid 2012. In early 2013 the initial
|
14
|
+
work towards this goal was merged into two projects; Nucleon (general plugin
|
15
|
+
management framework and execution environment), and CORL (this project).
|
11
16
|
|
17
|
+
We believe in the future, as machines become more connected and integrated,
|
18
|
+
there will be profound need for frameworks that allow for the creation of semi
|
19
|
+
or fully autonomous cyber entities that evolve across the cloud. These software
|
20
|
+
entities will have varying capabilities and objectives but all will be capable
|
21
|
+
of managing their machines, communicating with others in their network, and
|
22
|
+
reproducing when neccessary. We want to help further a new era of smart
|
23
|
+
infrastructure by providing an open source framework for developing such
|
24
|
+
entities and their requisite environments.
|
12
25
|
|
26
|
+
Treating machines as autonomous software entities that can self manage allows
|
27
|
+
for the agile and adaptive evolution of the computer systems we rely on to make
|
28
|
+
our lives easier. Management dashboards and user controls are great but the
|
29
|
+
future of the web belongs to the machines acting in our interests. CORL is
|
30
|
+
being developed to help bring the machines to life (in a manner of speaking).
|
13
31
|
|
14
32
|
|
33
|
+
== State of the project
|
15
34
|
|
16
35
|
|
36
|
+
CORL, and its parent {Nucleon}[https://github.com/coralnexus/nucleon]
|
37
|
+
are still in alpha development and not yet ready for production unless you know
|
38
|
+
how to develop with it and fix bugs. We use it for our infrastructure
|
39
|
+
architecture internally, but there are kinks we still have to work out to meet
|
40
|
+
the full set of intended architectual objectives. We are currently finalizing
|
41
|
+
the acquarium, next comes the fish.
|
17
42
|
|
43
|
+
If you are a tinkerer and are passionate about machine managed systems or
|
44
|
+
organically inspired software systems we invite your contributions in whatever
|
45
|
+
form you wish to provide. Contact Adrian Webb ( adrian.webb@coralnexus.com )
|
46
|
+
with questions or feedback or just post an issue.
|
18
47
|
|
48
|
+
<b>Note that all development and testing has been on Ubuntu (12.04/14.04) so
|
49
|
+
far.</b>
|
19
50
|
|
51
|
+
To review tasks needing completion before first production release, {see the TODO}[link:info/TODO.rdoc].
|
20
52
|
|
53
|
+
To get an overview of what plugins are currently provided, go {here}[link:info/PLUGINS.rdoc].
|
21
54
|
|
22
|
-
![Logo][logo]
|
23
|
-
[logo]: http://cl.ly/image/3Y013H0A2z3z/gundam-ruby.png
|
24
55
|
|
25
|
-
|
26
|
-
[major version][semver].
|
56
|
+
== CORL architecture
|
27
57
|
|
28
|
-
## Philosophy
|
29
58
|
|
30
|
-
|
31
|
-
written][wrappers]. Octokit.rb wraps the [GitHub API][github-api] in a flat API
|
32
|
-
client that follows Ruby conventions and requires little knowledge of REST.
|
33
|
-
Most methods have positional arguments for required input and an options hash
|
34
|
-
for optional parameters, headers, or other options:
|
59
|
+
CORL is a <b>programming framework</b> and <b>execution environment</b> intended for:
|
35
60
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
61
|
+
1. Management of reusable high availability platforms across cloud providers
|
62
|
+
|
63
|
+
2. Distributed programming or script execution across dynamically managed nodes
|
64
|
+
|
65
|
+
3. Decentralized networking and provisioning of heterogeneous machines
|
66
|
+
|
67
|
+
4. Cloud based evolutionary multi-agent simulations and processing
|
40
68
|
|
41
69
|
|
42
|
-
|
43
|
-
[github-api]: http://developer.github.com
|
70
|
+
=== Key design requirements:
|
44
71
|
|
45
|
-
## Quick start
|
46
72
|
|
47
|
-
|
73
|
+
* Lightweight programming framework for executing actions and managing agents
|
74
|
+
across dynamically evolving networks of nodes
|
75
|
+
* Pluggable data driven integration capabilities
|
76
|
+
* Portable actions and packages that can be searched and aggregated from across
|
77
|
+
the system
|
78
|
+
* Network projects that connect nodes, architecture, and resources as
|
79
|
+
decentralized revision controlled projects, not centralized hosted databases
|
80
|
+
* CLI action interface
|
81
|
+
* REST action host (not implemented yet)
|
48
82
|
|
49
|
-
gem install octokit
|
50
83
|
|
51
|
-
|
84
|
+
=== Things CORL is NOT meant to be:
|
52
85
|
|
53
|
-
gem "octokit", "~> 3.0"
|
54
86
|
|
55
|
-
|
87
|
+
* A dashboard or UI driven application (we are focused solely on machines)
|
88
|
+
* A continuously running agent or hosted application
|
89
|
+
(we need to minimize system resource usage)
|
90
|
+
* A bloated platform that requires a multi-system platform or dedicated
|
91
|
+
servers to operate
|
92
|
+
* A virtualization system (although it uses them)
|
56
93
|
|
57
|
-
|
58
|
-
configuration) or as client instance methods.
|
94
|
+
Care to {walk through the CORL architecture on Prezi}[https://prezi.com/enwlxtfhdqoq/corl]?
|
59
95
|
|
60
|
-
```ruby
|
61
|
-
# Provide authentication credentials
|
62
|
-
Octokit.configure do |c|
|
63
|
-
c.login = 'defunkt'
|
64
|
-
c.password = 'c0d3b4ssssss!'
|
65
|
-
end
|
66
96
|
|
67
|
-
|
68
|
-
Octokit.user
|
69
|
-
```
|
70
|
-
or
|
97
|
+
== CORL focus areas
|
71
98
|
|
72
|
-
```ruby
|
73
|
-
# Provide authentication credentials
|
74
|
-
client = Octokit::Client.new(:login => 'defunkt', :password => 'c0d3b4ssssss!')
|
75
|
-
# Fetch the current user
|
76
|
-
client.user
|
77
|
-
```
|
78
99
|
|
79
|
-
|
100
|
+
Our ultimate goal is the scalable application of our resources, time, and
|
101
|
+
workflows, while allowing for evolutionary and adaptive growth of our IT
|
102
|
+
infrastructure.
|
80
103
|
|
81
|
-
|
104
|
+
{<img src="https://raw.githubusercontent.com/coralnexus/corl/0.5/images/purpose.png" align="right">}[link:README.rdoc]
|
82
105
|
|
83
|
-
|
84
|
-
|
106
|
+
<b>Packaging</b> serves as a foundation for an automated architecture by
|
107
|
+
providing reusable configuration managed images that can be easily launched
|
108
|
+
across local and remote virtual machine and container providers. Our goal with
|
109
|
+
packaging is to turn machines into programmable data objects which can be easily
|
110
|
+
automated through diverse software systems.
|
85
111
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
# => "GitHub"
|
95
|
-
user.rels[:gists].href
|
96
|
-
# => "https://api.github.com/users/jbarnette/gists"
|
97
|
-
```
|
112
|
+
<b>Automation</b> builds on packaged data and systems, and allows for reusable
|
113
|
+
development of flexible integrated workflows. Automation capabilities depend
|
114
|
+
on the degree to which machine inspection and management has been abstracted
|
115
|
+
from the various configuration files, system services, and operating system
|
116
|
+
nuances. CORL tries to bridge technologies that abstract the relevant data
|
117
|
+
from the machine and various applications so we can more easily monitor and
|
118
|
+
automate. Two modes of automation are possible; actions (fire and forget), and
|
119
|
+
agents (managed services that utilize actions).
|
98
120
|
|
99
|
-
|
100
|
-
|
121
|
+
<b>Scaling</b> of infrastructure resources and workflows becomes easier when we
|
122
|
+
have a flexible automation system that can work with machines as data, and
|
123
|
+
deeply integrate with the software, services, and workflows we already employ.
|
101
124
|
|
102
|
-
### Accessing HTTP responses
|
103
125
|
|
104
|
-
|
105
|
-
need access to the raw HTTP response headers. You can access the last HTTP
|
106
|
-
response with `Client#last_response`:
|
126
|
+
=== Packaging system
|
107
127
|
|
108
|
-
```ruby
|
109
|
-
user = Octokit.user 'andrewpthorp'
|
110
|
-
response = Octokit.last_response
|
111
|
-
etag = response.headers[:etag]
|
112
|
-
```
|
113
128
|
|
114
|
-
|
129
|
+
To build adaptive infrastructure we treat each machine as a programmable data
|
130
|
+
model that is connected to other machines in a shared network (data pool).
|
131
|
+
This also helps create an entirely hands off administration process that is easy
|
132
|
+
to query and modify through remote action execution.
|
115
133
|
|
116
|
-
|
117
|
-
API][auth]:
|
134
|
+
https://raw.githubusercontent.com/coralnexus/corl/0.5/images/packaging-overview.png
|
118
135
|
|
119
|
-
|
136
|
+
To read more on the CORL packaging system, {see the packaging overview}[link:info/PACKAGING.rdoc].
|
120
137
|
|
121
|
-
Using your GitHub username and password is the easiest way to get started
|
122
|
-
making authenticated requests:
|
123
138
|
|
124
|
-
|
125
|
-
client = Octokit::Client.new \
|
126
|
-
:login => 'defunkt',
|
127
|
-
:password => 'c0d3b4ssssss!'
|
139
|
+
=== Automation system
|
128
140
|
|
129
|
-
user = client.user
|
130
|
-
user.login
|
131
|
-
# => "defunkt"
|
132
|
-
```
|
133
|
-
While Basic Authentication allows you to get started quickly, OAuth access
|
134
|
-
tokens are the preferred way to authenticate on behalf of users.
|
135
141
|
|
136
|
-
|
142
|
+
The ability to create, reuse, and extend integrated development and
|
143
|
+
administration workflows across standardized plugin interfaces gives us the
|
144
|
+
ability to focus on the task at hand while allowing for the creation of
|
145
|
+
different interface implementations when needed.
|
137
146
|
|
138
|
-
[OAuth access tokens][oauth] provide two main benefits over using your username
|
139
|
-
and password:
|
140
147
|
|
141
|
-
|
142
|
-
that token without having to change your password everywhere.
|
143
|
-
* **Limited access**. Access tokens have [access scopes][] which allow for more
|
144
|
-
granular access to API resources. For instance, you can grant a third party
|
145
|
-
access to your gists but not your private repositories.
|
148
|
+
https://raw.githubusercontent.com/coralnexus/corl/0.5/images/automation-overview.png
|
146
149
|
|
147
|
-
To use an access token with the Octokit client, pass your token in the
|
148
|
-
`:access_token` options parameter in lieu of your username and password:
|
149
150
|
|
150
|
-
|
151
|
-
client = Octokit::Client.new(:access_token => "<your 40 char token>")
|
151
|
+
== CORL installation and setup
|
152
152
|
|
153
|
-
|
154
|
-
|
155
|
-
# => "defunkt"
|
156
|
-
```
|
157
|
-
|
158
|
-
You can [create access tokens through your GitHub Account Settings](https://help.github.com/articles/creating-an-access-token-for-command-line-use)
|
159
|
-
or with a basic authenticated Octokit client:
|
160
|
-
|
161
|
-
```ruby
|
162
|
-
client = Octokit::Client.new \
|
163
|
-
:login => 'defunkt',
|
164
|
-
:password => 'c0d3b4ssssss!'
|
153
|
+
CORL is designed so it requires few dependencies outside of the Ruby language
|
154
|
+
and some useful Gems.
|
165
155
|
|
166
|
-
|
167
|
-
|
168
|
-
```
|
156
|
+
See the {installation instructions}[link:info/INSTALLATION.rdoc] for information on requirements and getting
|
157
|
+
CORL installed on your machines.
|
169
158
|
|
170
|
-
### Two-Factor Authentication
|
171
159
|
|
172
|
-
[Two-Factor Authentication](https://help.github.com/articles/about-two-factor-authentication) brings added security to the account by requiring more information to login.
|
173
160
|
|
174
|
-
|
161
|
+
== Ruby Versions
|
175
162
|
|
176
|
-
```ruby
|
177
|
-
client = Octokit::Client.new \
|
178
|
-
:login => 'defunkt',
|
179
|
-
:password => 'c0d3b4ssssss!'
|
180
163
|
|
181
|
-
|
182
|
-
```
|
164
|
+
This library has been developed with and should support MRI Ruby versions:
|
183
165
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
:login => 'defunkt',
|
189
|
-
:password => 'c0d3b4ssssss!'
|
190
|
-
|
191
|
-
client.create_authorization(:scopes => ["user"], :note => "Name of token",
|
192
|
-
:headers => { "X-GitHub-OTP" => "<your 2FA token>" })
|
193
|
-
# => <your new oauth token>
|
194
|
-
```
|
195
|
-
|
196
|
-
### Using a .netrc file
|
197
|
-
|
198
|
-
Octokit supports reading credentials from a netrc file (defaulting to
|
199
|
-
`~/.netrc`). Given these lines in your netrc:
|
200
|
-
|
201
|
-
```
|
202
|
-
machine api.github.com
|
203
|
-
login defunkt
|
204
|
-
password c0d3b4ssssss!
|
205
|
-
```
|
206
|
-
You can now create a client with those credentials:
|
207
|
-
|
208
|
-
```ruby
|
209
|
-
client = Octokit::Client.new(:netrc => true)
|
210
|
-
client.login
|
211
|
-
# => "defunkt"
|
212
|
-
```
|
213
|
-
But _I want to use OAuth_ you say. Since the GitHub API supports using an OAuth
|
214
|
-
token as a Basic password, you totally can:
|
215
|
-
|
216
|
-
```
|
217
|
-
machine api.github.com
|
218
|
-
login defunkt
|
219
|
-
password <your 40 char token>
|
220
|
-
```
|
221
|
-
|
222
|
-
**Note:** Support for netrc requires adding the [netrc gem][] to your Gemfile
|
223
|
-
or `.gemspec`.
|
224
|
-
|
225
|
-
### Application authentication
|
226
|
-
|
227
|
-
Octokit also supports application-only authentication [using OAuth application client
|
228
|
-
credentials][app-creds]. Using application credentials will result in making
|
229
|
-
anonymous API calls on behalf of an application in order to take advantage of
|
230
|
-
the higher rate limit.
|
231
|
-
|
232
|
-
```ruby
|
233
|
-
client = Octokit::Client.new \
|
234
|
-
:client_id => "<your 20 char id>",
|
235
|
-
:client_secret => "<your 40 char secret>"
|
236
|
-
|
237
|
-
user = client.user 'defunkt'
|
238
|
-
```
|
239
|
-
|
240
|
-
[auth]: http://developer.github.com/v3/#authentication
|
241
|
-
[oauth]: http://developer.github.com/v3/oauth/
|
242
|
-
[access scopes]: http://developer.github.com/v3/oauth/#scopes
|
243
|
-
[app-creds]: http://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
|
244
|
-
|
245
|
-
## Pagination
|
246
|
-
|
247
|
-
Many GitHub API resources are [paginated][]. While you may be tempted to start
|
248
|
-
adding `:page` parameters to your calls, the API returns links to the next,
|
249
|
-
previous, and last pages for you in the `Link` response header as [Hypermedia
|
250
|
-
link relations](#hypermedia-agent).
|
251
|
-
|
252
|
-
```ruby
|
253
|
-
issues = Octokit.issues 'rails/rails', :per_page => 100
|
254
|
-
issues.concat Octokit.last_response.rels[:next].get.data
|
255
|
-
```
|
256
|
-
|
257
|
-
### Auto pagination
|
258
|
-
|
259
|
-
For smallish resource lists, Octokit provides auto pagination. When this is
|
260
|
-
enabled, calls for paginated resources will fetch and concatenate the results
|
261
|
-
from every page into a single array:
|
262
|
-
|
263
|
-
```ruby
|
264
|
-
Octokit.auto_paginate = true
|
265
|
-
issues = Octokit.issues 'rails/rails'
|
266
|
-
issues.length
|
267
|
-
|
268
|
-
# => 702
|
269
|
-
```
|
270
|
-
|
271
|
-
**Note:** While Octokit auto pagination will set the page size to the maximum
|
272
|
-
`100`, and seek to not overstep your rate limit, you probably want to use a
|
273
|
-
custom pattern for traversing large lists.
|
274
|
-
|
275
|
-
[paginated]: http://developer.github.com/v3/#pagination
|
276
|
-
|
277
|
-
## Configuration and defaults
|
278
|
-
|
279
|
-
While `Octokit::Client` accepts a range of options when creating a new client
|
280
|
-
instance, Octokit's configuration API allows you to set your configuration
|
281
|
-
options at the module level. This is particularly handy if you're creating a
|
282
|
-
number of client instances based on some shared defaults.
|
283
|
-
|
284
|
-
### Configuring module defaults
|
285
|
-
|
286
|
-
Every writable attribute in {Octokit::Configurable} can be set one at a time:
|
287
|
-
|
288
|
-
```ruby
|
289
|
-
Octokit.api_endpoint = 'http://api.github.dev'
|
290
|
-
Octokit.web_endpoint = 'http://github.dev'
|
291
|
-
```
|
292
|
-
|
293
|
-
or in batch:
|
294
|
-
|
295
|
-
```ruby
|
296
|
-
Octokit.configure do |c|
|
297
|
-
c.api_endpoint = 'http://api.github.dev'
|
298
|
-
c.web_endpoint = 'http://github.dev'
|
299
|
-
end
|
300
|
-
```
|
301
|
-
|
302
|
-
### Using ENV variables
|
303
|
-
|
304
|
-
Default configuration values are specified in {Octokit::Default}. Many
|
305
|
-
attributes will look for a default value from the ENV before returning
|
306
|
-
Octokit's default.
|
307
|
-
|
308
|
-
```ruby
|
309
|
-
# Given $OCTOKIT_API_ENDPOINT is "http://api.github.dev"
|
310
|
-
Octokit.api_endpoint
|
311
|
-
|
312
|
-
# => "http://api.github.dev"
|
313
|
-
```
|
314
|
-
|
315
|
-
Deprecation warnings and API endpoints in development preview warnings are
|
316
|
-
printed to STDOUT by default, these can be disabled by setting the ENV
|
317
|
-
`OCTOKIT_SILENT=true`.
|
318
|
-
|
319
|
-
## Hypermedia agent
|
320
|
-
|
321
|
-
Starting in version 2.0, Octokit is [hypermedia][]-enabled. Under the hood,
|
322
|
-
{Octokit::Client} uses [Sawyer][], a hypermedia client built on [Faraday][].
|
323
|
-
|
324
|
-
### Hypermedia in Octokit
|
325
|
-
|
326
|
-
Resources returned by Octokit methods contain not only data but hypermedia
|
327
|
-
link relations:
|
328
|
-
|
329
|
-
```ruby
|
330
|
-
user = Octokit.user 'technoweenie'
|
331
|
-
|
332
|
-
# Get the repos rel, returned from the API
|
333
|
-
# as repos_url in the resource
|
334
|
-
user.rels[:repos].href
|
335
|
-
# => "https://api.github.com/users/technoweenie/repos"
|
336
|
-
|
337
|
-
repos = user.rels[:repos].get.data
|
338
|
-
repos.last.name
|
339
|
-
# => "faraday-zeromq"
|
340
|
-
```
|
341
|
-
|
342
|
-
When processing API responses, all `*_url` attributes are culled in to the link
|
343
|
-
relations collection. Any `url` attribute becomes `.rels[:self]`.
|
344
|
-
|
345
|
-
### URI templates
|
346
|
-
|
347
|
-
You might notice many link relations have variable placeholders. Octokit
|
348
|
-
supports [URI Templates][uri-templates] for parameterized URI expansion:
|
349
|
-
|
350
|
-
```ruby
|
351
|
-
repo = Octokit.repo 'pengwynn/pingwynn'
|
352
|
-
rel = repo.rels[:issues]
|
353
|
-
# => #<Sawyer::Relation: issues: get https://api.github.com/repos/pengwynn/pingwynn/issues{/number}>
|
354
|
-
|
355
|
-
# Get a page of issues
|
356
|
-
rel.get.data
|
357
|
-
|
358
|
-
# Get issue #2
|
359
|
-
rel.get(:uri => {:number => 2}).data
|
360
|
-
```
|
361
|
-
|
362
|
-
### The Full Hypermedia Experience™
|
363
|
-
|
364
|
-
If you want to use Octokit as a pure hypermedia API client, you can start at
|
365
|
-
the API root and follow link relations from there:
|
366
|
-
|
367
|
-
```ruby
|
368
|
-
root = Octokit.root
|
369
|
-
root.rels[:repository].get :uri => {:owner => "octokit", :repo => "octokit.rb" }
|
370
|
-
```
|
371
|
-
|
372
|
-
Octokit 3.0 aims to be hypermedia-driven, removing the internal URL
|
373
|
-
construction currently used throughout the client.
|
374
|
-
|
375
|
-
[hypermedia]: http://en.wikipedia.org/wiki/Hypermedia
|
376
|
-
[Sawyer]: https://github.com/lostisland/sawyer
|
377
|
-
[Faraday]: https://github.com/lostisland/faraday
|
378
|
-
[uri-templates]: http://tools.ietf.org/html/rfc6570
|
379
|
-
|
380
|
-
## Upgrading guide
|
381
|
-
|
382
|
-
Version 3.0 includes a couple breaking changes when upgrading from v2.x.x:
|
383
|
-
|
384
|
-
The [default media type][default-media-type] is now `v3` instead of `beta`. If
|
385
|
-
you need to request the older media type, you can set the default media type
|
386
|
-
for the client:
|
387
|
-
|
388
|
-
```ruby
|
389
|
-
Octokit.default_media_type = "application/vnd.github.beta+json"
|
390
|
-
```
|
391
|
-
or per-request
|
392
|
-
|
393
|
-
```ruby
|
394
|
-
Octokit.emails(:accept => "application/vnd.github.beta+json")
|
395
|
-
```
|
396
|
-
|
397
|
-
The long-deprecated `Octokit::Client#create_download` method has been removed.
|
398
|
-
|
399
|
-
[default-media-type]: https://developer.github.com/changes/2014-01-07-upcoming-change-to-default-media-type/
|
400
|
-
|
401
|
-
### Upgrading from 1.x.x
|
402
|
-
|
403
|
-
Version 2.0 includes a completely rewritten `Client` factory that now memoizes
|
404
|
-
client instances based on unique configuration options. Breaking changes also
|
405
|
-
include:
|
406
|
-
|
407
|
-
* `:oauth_token` is now `:access_token`
|
408
|
-
* `:auto_traversal` is now `:auto_paginate`
|
409
|
-
* `Hashie::Mash` has been removed. Responses now return a `Sawyer::Resource`
|
410
|
-
object. This new type behaves mostly like a Ruby `Hash`, but does not fully
|
411
|
-
support the `Hashie::Mash` API.
|
412
|
-
* Two new client error types are raised where appropriate:
|
413
|
-
`Octokit::TooManyRequests` and `Octokit::TooManyLoginAttempts`
|
414
|
-
* The `search_*` methods from v1.x are now found at `legacy_search_*`
|
415
|
-
* Support for netrc requires including the [netrc gem][] in your Gemfile or
|
416
|
-
gemspec.
|
417
|
-
* DateTime fields are now proper `DateTime` objects. Previous versions outputted DateTime fields as 'String' objects.
|
418
|
-
|
419
|
-
[netrc gem]: https://rubygems.org/gems/netrc
|
420
|
-
|
421
|
-
|
422
|
-
## Advanced usage
|
423
|
-
|
424
|
-
Since Octokit employs [Faraday][faraday] under the hood, some behavior can be
|
425
|
-
extended via middleware.
|
426
|
-
|
427
|
-
### Debugging
|
428
|
-
|
429
|
-
Often, it helps to know what Octokit is doing under the hood. You can add a
|
430
|
-
logger to the middleware that enables you to peek into the underlying HTTP
|
431
|
-
traffic:
|
432
|
-
|
433
|
-
```ruby
|
434
|
-
stack = Faraday::RackBuilder.new do |builder|
|
435
|
-
builder.response :logger
|
436
|
-
builder.use Octokit::Response::RaiseError
|
437
|
-
builder.adapter Faraday.default_adapter
|
438
|
-
end
|
439
|
-
Octokit.middleware = stack
|
440
|
-
Octokit.user 'pengwynn'
|
441
|
-
```
|
442
|
-
```
|
443
|
-
I, [2013-08-22T15:54:38.583300 #88227] INFO -- : get https://api.github.com/users/pengwynn
|
444
|
-
D, [2013-08-22T15:54:38.583401 #88227] DEBUG -- request: Accept: "application/vnd.github.beta+json"
|
445
|
-
User-Agent: "Octokit Ruby Gem 2.0.0.rc4"
|
446
|
-
I, [2013-08-22T15:54:38.843313 #88227] INFO -- Status: 200
|
447
|
-
D, [2013-08-22T15:54:38.843459 #88227] DEBUG -- response: server: "GitHub.com"
|
448
|
-
date: "Thu, 22 Aug 2013 20:54:40 GMT"
|
449
|
-
content-type: "application/json; charset=utf-8"
|
450
|
-
transfer-encoding: "chunked"
|
451
|
-
connection: "close"
|
452
|
-
status: "200 OK"
|
453
|
-
x-ratelimit-limit: "60"
|
454
|
-
x-ratelimit-remaining: "39"
|
455
|
-
x-ratelimit-reset: "1377205443"
|
456
|
-
...
|
457
|
-
```
|
458
|
-
|
459
|
-
See the [Faraday README][faraday] for more middleware magic.
|
460
|
-
|
461
|
-
### Caching
|
462
|
-
|
463
|
-
If you want to boost performance, stretch your API rate limit, or avoid paying
|
464
|
-
the hypermedia tax, you can use [Faraday Http Cache][cache].
|
465
|
-
|
466
|
-
Add the gem to your Gemfile
|
467
|
-
|
468
|
-
gem 'faraday-http-cache'
|
469
|
-
|
470
|
-
Next, construct your own Faraday middleware:
|
471
|
-
|
472
|
-
```ruby
|
473
|
-
stack = Faraday::RackBuilder.new do |builder|
|
474
|
-
builder.use Faraday::HttpCache
|
475
|
-
builder.use Octokit::Response::RaiseError
|
476
|
-
builder.adapter Faraday.default_adapter
|
477
|
-
end
|
478
|
-
Octokit.middleware = stack
|
479
|
-
```
|
480
|
-
|
481
|
-
Once configured, the middleware will store responses in cache based on ETag
|
482
|
-
fingerprint and serve those back up for future `304` responses for the same
|
483
|
-
resource. See the [project README][cache] for advanced usage.
|
484
|
-
|
485
|
-
|
486
|
-
[cache]: https://github.com/plataformatec/faraday-http-cache
|
487
|
-
[faraday]: https://github.com/lostisland/faraday
|
488
|
-
|
489
|
-
## Hacking on Octokit.rb
|
490
|
-
|
491
|
-
If you want to hack on Octokit locally, we try to make [bootstrapping the
|
492
|
-
project][bootstrapping] as painless as possible. To start hacking, clone and run:
|
493
|
-
|
494
|
-
script/bootstrap
|
495
|
-
|
496
|
-
This will install project dependencies and get you up and running. If you want
|
497
|
-
to run a Ruby console to poke on Octokit, you can crank one up with:
|
498
|
-
|
499
|
-
script/console
|
500
|
-
|
501
|
-
Using the scripts in `./scripts` instead of `bundle exec rspec`, `bundle
|
502
|
-
console`, etc. ensures your dependencies are up-to-date.
|
503
|
-
|
504
|
-
### Running and writing new tests
|
505
|
-
|
506
|
-
Octokit uses [VCR][] for recording and playing back API fixtures during test
|
507
|
-
runs. These cassettes (fixtures) are part of the Git project in the `spec/cassettes`
|
508
|
-
folder. If you're not recording new cassettes you can run the specs with existing
|
509
|
-
cassettes with:
|
510
|
-
|
511
|
-
script/test
|
512
|
-
|
513
|
-
Octokit uses environmental variables for storing credentials used in testing.
|
514
|
-
If you are testing an API endpoint that doesn't require authentication, you
|
515
|
-
can get away without any additional configuration. For the most part, tests
|
516
|
-
use an authenticated client, using a token stored in `ENV['OCTOKIT_TEST_GITHUB_TOKEN']`.
|
517
|
-
There are several different authenticating method's used across the api.
|
518
|
-
Here is the full list of configurable environmental variables for testing
|
519
|
-
Octokit:
|
520
|
-
|
521
|
-
ENV Variable | Description |
|
522
|
-
:-------------------|:-----------------|
|
523
|
-
`OCTOKIT_TEST_GITHUB_LOGIN`| GitHub login name (preferably one created specifically for testing against).
|
524
|
-
`OCTOKIT_TEST_GITHUB_PASSWORD`| Password for the test GitHub login.
|
525
|
-
`OCTOKIT_TEST_GITHUB_TOKEN` | [Personal Access Token](https://github.com/blog/1509-personal-api-tokens) for the test GitHub login.
|
526
|
-
`OCTOKIT_TEST_GITHUB_CLIENT_ID` | Test OAuth application client id.
|
527
|
-
`OCTOKIT_TEST_GITHUB_CLIENT_SECRET` | Test OAuth application client secret.
|
528
|
-
`OCTOKIT_TEST_GITHUB_REPOSITORY` | Test repository to perform destructive actions against, this should not be set to any repository of importance. **Automatically created by the test suite if nonexistent** Default: `api-sandbox`
|
529
|
-
`OCTOKIT_TEST_GITHUB_ORGANIZATION` | Test organization.
|
530
|
-
|
531
|
-
Since we periodically refresh our cassettes, please keep some points in mind
|
532
|
-
when writing new specs.
|
533
|
-
|
534
|
-
* **Specs should be idempotent**. The HTTP calls made during a spec should be
|
535
|
-
able to be run over and over. This means deleting a known resource prior to
|
536
|
-
creating it if the name has to be unique.
|
537
|
-
* **Specs should be able to be run in random order.** If a spec depends on
|
538
|
-
another resource as a fixture, make sure that's created in the scope of the
|
539
|
-
spec and not depend on a previous spec to create the data needed.
|
540
|
-
* **Do not depend on authenticated user info.** Instead of asserting
|
541
|
-
actual values in resources, try to assert the existence of a key or that a
|
542
|
-
response is an Array. We're testing the client, not the API.
|
543
|
-
|
544
|
-
[bootstrapping]: http://wynnnetherland.com/linked/2013012801/bootstrapping-consistency
|
545
|
-
[VCR]: https://github.com/vcr/vcr
|
546
|
-
|
547
|
-
## Supported Ruby Versions
|
548
|
-
|
549
|
-
This library aims to support and is [tested against][travis] the following Ruby
|
550
|
-
implementations:
|
551
|
-
|
552
|
-
* Ruby 1.9.2
|
553
|
-
* Ruby 1.9.3
|
554
|
-
* Ruby 2.0.0
|
555
|
-
* Ruby 2.1.0
|
166
|
+
* <b>Ruby 1.9.2</b>
|
167
|
+
* <b>Ruby 1.9.3</b>
|
168
|
+
* <b>Ruby 2.0.0</b>
|
169
|
+
* <b>Ruby 2.1.0</b>
|
556
170
|
|
557
171
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
558
172
|
|
559
173
|
This library may inadvertently work (or seem to work) on other Ruby
|
560
174
|
implementations, but support will only be provided for the versions listed
|
561
|
-
above.
|
175
|
+
above. *Rubinius* is being tested and will ultimately be supported.
|
176
|
+
|
177
|
+
This library currently does not work on *JRuby* due to CORL gem dependencies,
|
178
|
+
such as Rugged, that provide C Ruby extensions (which JRuby does not support).
|
179
|
+
|
180
|
+
We have developed this so far pretty much entirely on Ubuntu but the core
|
181
|
+
framework should work with other Linux distributions. There are known issues
|
182
|
+
with Windows when executed through Vagrant and Cygwin.
|
562
183
|
|
563
|
-
If you would like this library to support another Ruby version, you may
|
564
|
-
volunteer to be a maintainer. Being a maintainer entails making sure all tests
|
565
|
-
run and pass on that implementation. When something breaks on your
|
566
|
-
implementation, you will be responsible for providing patches in a timely
|
567
|
-
fashion. If critical issues for a particular implementation exist at the time
|
568
|
-
of a major release, support for that Ruby version may be dropped.
|
569
184
|
|
570
|
-
|
185
|
+
== Versioning
|
571
186
|
|
572
|
-
## Versioning
|
573
187
|
|
574
|
-
This
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
introduced with new major versions. As a result of this policy, you can (and
|
580
|
-
should) specify a dependency on this gem using the [Pessimistic Version
|
581
|
-
Constraint][pvc] with two digits of precision. For example:
|
188
|
+
This framework should be considered unstable and likely to break as remaining
|
189
|
+
bugs and unit testing are completed going forward. When we reach version 1.0.0
|
190
|
+
full {semantic versioning}[http://semver.org] will be ahered to. Until then
|
191
|
+
the minor version specifies a major architectural change, and patch versions
|
192
|
+
could fix bugs and revise features that could break backward compatibility.
|
582
193
|
|
583
|
-
spec.add_dependency 'octokit', '~> 3.0'
|
584
194
|
|
585
|
-
|
586
|
-
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
195
|
+
== License
|
587
196
|
|
588
|
-
## License
|
589
197
|
|
590
198
|
Licensed under Apache License 2.0. See LICENSE.txt for further details.
|
591
199
|
|
592
|
-
Copyright © 2013-
|
200
|
+
Copyright © 2013-2015 Adrian Webb ( mailto:adrian.webb@coraltech.net ) <b>Coral Technology Group LLC</b>
|