shipyrd 0.3.0 → 0.4.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/README.md +18 -2
- data/lib/shipyrd/application.rb +8 -0
- data/lib/shipyrd/client.rb +13 -5
- data/lib/shipyrd/destination.rb +13 -2
- data/lib/shipyrd/version.rb +1 -1
- data/lib/shipyrd.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dc0bb426be7ecacd00120bec18763758c25ba65c278a112711d73eb69d3bd39f
|
|
4
|
+
data.tar.gz: f7d5c5b0e4846f22758144f69f55a6c03a43d6be5e486c4fc527f23a4e349c12
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6dbf745685a47fe00cce8607c29d42743a781302ad83ee3189d2526bac143cd194752a6c64162aa22e3e39cf75b2b43d5a2ee76fe22cde9db51966b82716ab10
|
|
7
|
+
data.tar.gz: '086241e6aa74db9f3e44b2d98a334db318eaa252c6e160576b410e5299c6377f0956d6d315fc0bd7d756efd1119fa11e40b66add48444e4cccadfea2a836201a'
|
data/README.md
CHANGED
|
@@ -95,6 +95,22 @@ rescuing the general error still catches them. `Shipyrd::Client#request` is the
|
|
|
95
95
|
same request for any other API endpoint. The helpers delegate to
|
|
96
96
|
`Shipyrd::Destination`, which you can also use directly.
|
|
97
97
|
|
|
98
|
+
## Applications and destinations
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
client.applications
|
|
102
|
+
# => [{"slug" => "shipyrd-web", "organization" => {"id", "name"}, "destination_states" => [...]}, ...]
|
|
103
|
+
client.applications(organization_id: 7)
|
|
104
|
+
|
|
105
|
+
client.destination("production", application: "shipyrd-web")
|
|
106
|
+
# => {"name", "locked", "locked_by", "locked_at", "branch", "on_deck_url", "latest_deploy" => {...}, ...}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`applications` lists every application in your organizations, or in one with
|
|
110
|
+
`organization_id`, each with its destinations' lock state and latest deploy.
|
|
111
|
+
`destination` takes the same arguments as `lock_destination` and raises the same
|
|
112
|
+
`Shipyrd::Destination::NotFound` and `AmbiguousApplication`.
|
|
113
|
+
|
|
98
114
|
## Who a token belongs to
|
|
99
115
|
|
|
100
116
|
```ruby
|
|
@@ -119,10 +135,10 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/shipyr
|
|
|
119
135
|
|
|
120
136
|
## Releasing a new version
|
|
121
137
|
|
|
122
|
-
The `bin/release` command will bump the version in the version.rb file, tag it,
|
|
138
|
+
The `bin/release` command will bump the version in the version.rb file, tag it, push it up to GitHub and RubyGems, and create the GitHub release for the tag with notes generated from the merged pull requests. It needs the `gh` CLI, signed in.
|
|
123
139
|
|
|
124
140
|
```
|
|
125
|
-
bin/release 0.
|
|
141
|
+
bin/release 0.3.1
|
|
126
142
|
```
|
|
127
143
|
|
|
128
144
|
## Code of Conduct
|
data/lib/shipyrd/client.rb
CHANGED
|
@@ -141,18 +141,26 @@ class Shipyrd::Client
|
|
|
141
141
|
Shipyrd::User.me(client: self)
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
+
def applications(organization_id: nil)
|
|
145
|
+
Shipyrd::Application.all(client: self, organization_id: organization_id)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def destination(name, application:, organization_id: nil)
|
|
149
|
+
destination_for(name, application, organization_id).get
|
|
150
|
+
end
|
|
151
|
+
|
|
144
152
|
# Locks a destination as the token's user. name nil or "" is the destination
|
|
145
153
|
# with a blank name; application is the slug or id; organization_id is only
|
|
146
154
|
# needed when the slug is in several of the user's organizations. Returns the
|
|
147
155
|
# destination's state, and raises Shipyrd::Destination::LockHeld if someone
|
|
148
156
|
# else holds it. See Shipyrd::Destination#lock.
|
|
149
157
|
def lock_destination(name, application:, organization_id: nil)
|
|
150
|
-
|
|
158
|
+
destination_for(name, application, organization_id).lock
|
|
151
159
|
end
|
|
152
160
|
|
|
153
161
|
# Unlocks a destination, whoever holds the lock. See Shipyrd::Destination#unlock.
|
|
154
162
|
def unlock_destination(name, application:, organization_id: nil)
|
|
155
|
-
|
|
163
|
+
destination_for(name, application, organization_id).unlock
|
|
156
164
|
end
|
|
157
165
|
|
|
158
166
|
# Sends one request to the Shipyrd API as the holder of api_key, always over
|
|
@@ -217,7 +225,7 @@ class Shipyrd::Client
|
|
|
217
225
|
|
|
218
226
|
private
|
|
219
227
|
|
|
220
|
-
def
|
|
228
|
+
def destination_for(name, application, organization_id)
|
|
221
229
|
Shipyrd::Destination.new(application: application, name: name, organization_id: organization_id, client: self)
|
|
222
230
|
end
|
|
223
231
|
|
|
@@ -245,9 +253,9 @@ class Shipyrd::Client
|
|
|
245
253
|
|
|
246
254
|
case status
|
|
247
255
|
when 200..299
|
|
248
|
-
return body if body.is_a?(Hash)
|
|
256
|
+
return body if body.is_a?(Hash) || body.is_a?(Array)
|
|
249
257
|
|
|
250
|
-
raise UnexpectedResponse.new("Shipyrd responded #{status} without
|
|
258
|
+
raise UnexpectedResponse.new("Shipyrd responded #{status} without JSON", status: status)
|
|
251
259
|
when 401 then raise Unauthorized.new(status: status, body: body)
|
|
252
260
|
when 404 then raise NotFound.new(status: status, body: body)
|
|
253
261
|
when 409 then raise Conflict.new(status: status, body: body)
|
data/lib/shipyrd/destination.rb
CHANGED
|
@@ -44,6 +44,10 @@ class Shipyrd::Destination
|
|
|
44
44
|
@client = client
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
def get
|
|
48
|
+
translating_errors { client.request(:get, destination_path, query: query) }
|
|
49
|
+
end
|
|
50
|
+
|
|
47
51
|
# Locks the destination as the client's user, so nobody else can deploy it.
|
|
48
52
|
# Returns the destination's state as a Hash. Your own lock again is a no-op;
|
|
49
53
|
# someone else's raises LockHeld.
|
|
@@ -60,10 +64,17 @@ class Shipyrd::Destination
|
|
|
60
64
|
private
|
|
61
65
|
|
|
62
66
|
def change_lock(method, action)
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
translating_errors { client.request(method, "#{destination_path}/#{action}", query: query) }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def query
|
|
71
|
+
organization_id ? {organization_id: organization_id} : {}
|
|
72
|
+
end
|
|
73
|
+
|
|
65
74
|
# Told apart by what the body carries: a held lock says who holds it, an
|
|
66
75
|
# ambiguous slug lists the organizations.
|
|
76
|
+
def translating_errors
|
|
77
|
+
yield
|
|
67
78
|
rescue Shipyrd::Client::Conflict => e
|
|
68
79
|
raise LockHeld.new(status: e.status, body: e.body) if e.body.key?("locked_by")
|
|
69
80
|
|
data/lib/shipyrd/version.rb
CHANGED
data/lib/shipyrd.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shipyrd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Hammond
|
|
@@ -24,6 +24,7 @@ files:
|
|
|
24
24
|
- README.md
|
|
25
25
|
- Rakefile
|
|
26
26
|
- lib/shipyrd.rb
|
|
27
|
+
- lib/shipyrd/application.rb
|
|
27
28
|
- lib/shipyrd/client.rb
|
|
28
29
|
- lib/shipyrd/configuration.rb
|
|
29
30
|
- lib/shipyrd/destination.rb
|