envirobly 0.3.2 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/envirobly/api.rb +15 -8
- data/lib/envirobly/cli/main.rb +7 -1
- data/lib/envirobly/deployment.rb +15 -5
- data/lib/envirobly/git/commit.rb +3 -3
- data/lib/envirobly/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a692c3ec890efdcb6ddf861e0503f3b64fe7266bcd460e4744aec19ab559fbcd
|
4
|
+
data.tar.gz: b65bf97e5d0e776035785b28566075818c2dd6db27a99c857a6300b1a4b7e9c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21b037970cc3dd974cb5f6660ff33fc846973565794b2601a7a64c1057c00fd320f673345428434184e9b17fbd3dc62a71d1c4495d0c32df5707921337d2c5ad
|
7
|
+
data.tar.gz: 86cf8cfce266fd410e669e05c29c0b28d297cba701fb2c991a759f45e0eb5b3ce61033f44d83f77269e0bc80feaae918172f587fa5546439804ec04b09e7f2cc
|
data/lib/envirobly/api.rb
CHANGED
@@ -38,22 +38,29 @@ class Envirobly::Api
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
def get_as_json(url, headers: {})
|
42
|
+
request(url, type: Net::HTTP::Get, headers:)
|
43
|
+
end
|
44
|
+
|
45
|
+
def post_as_json(url, params: {}, headers: {})
|
46
|
+
request(url, type: Net::HTTP::Post, headers:) do |request|
|
47
|
+
request.body = params.to_json
|
44
48
|
end
|
49
|
+
end
|
45
50
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
51
|
+
def put_as_json(url, params: {}, headers: {})
|
52
|
+
request(url, type: Net::HTTP::Put, headers:) do |request|
|
53
|
+
request.body = params.to_json
|
50
54
|
end
|
55
|
+
end
|
51
56
|
|
57
|
+
private
|
52
58
|
def api_v1_deployments_url
|
53
59
|
URI::HTTPS.build(host: HOST, path: "/api/v1/deployments")
|
54
60
|
end
|
55
61
|
|
56
|
-
def request(
|
62
|
+
def request(url, type:, headers: {})
|
63
|
+
uri = URI(url)
|
57
64
|
http = Net::HTTP.new uri.host, uri.port
|
58
65
|
http.use_ssl = true
|
59
66
|
http.open_timeout = 10
|
data/lib/envirobly/cli/main.rb
CHANGED
@@ -12,7 +12,13 @@ class Envirobly::Cli::Main < Envirobly::Base
|
|
12
12
|
end
|
13
13
|
|
14
14
|
desc "set_access_token TOKEN", "Save and use an access token generated at Envirobly"
|
15
|
-
def set_access_token
|
15
|
+
def set_access_token
|
16
|
+
token = ask("Access Token:", echo: false).strip
|
17
|
+
if token == ""
|
18
|
+
$stderr.puts "Token can't be empty."
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
|
16
22
|
Envirobly::AccessToken.new(token).save
|
17
23
|
end
|
18
24
|
|
data/lib/envirobly/deployment.rb
CHANGED
@@ -39,18 +39,21 @@ class Envirobly::Deployment
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
api = Envirobly::Api.new
|
43
|
-
response = api.create_deployment params
|
44
|
-
|
42
|
+
@api = Envirobly::Api.new
|
43
|
+
response = @api.create_deployment params
|
44
|
+
@url = response.object.fetch("url")
|
45
|
+
response = @api.get_deployment_with_delay_and_retry @url
|
45
46
|
@credentials = Envirobly::Aws::Credentials.new response.object.fetch("credentials")
|
46
47
|
@bucket = response.object.fetch("bucket")
|
47
48
|
|
48
49
|
if archive_commit_and_upload
|
49
|
-
$stderr.puts "Build context
|
50
|
+
$stderr.puts "Build context uploaded."
|
50
51
|
else
|
51
52
|
$stderr.puts "Error exporting build context. Aborting."
|
52
53
|
exit 1
|
53
54
|
end
|
55
|
+
|
56
|
+
# TODO: Output URL to watch the deployment progress
|
54
57
|
end
|
55
58
|
|
56
59
|
private
|
@@ -60,6 +63,13 @@ class Envirobly::Deployment
|
|
60
63
|
|
61
64
|
def archive_commit_and_upload
|
62
65
|
`git archive --format=tar.gz #{@commit.ref} | #{@credentials.as_inline_env_vars} aws s3 cp - #{archive_uri}`
|
63
|
-
$?.success
|
66
|
+
$?.success?.tap do |result|
|
67
|
+
params = {
|
68
|
+
deployment: {
|
69
|
+
build_context_available: result
|
70
|
+
}
|
71
|
+
}
|
72
|
+
@api.put_as_json @url, params: params
|
73
|
+
end
|
64
74
|
end
|
65
75
|
end
|
data/lib/envirobly/git/commit.rb
CHANGED
@@ -6,15 +6,15 @@ class Envirobly::Git::Commit
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def exists?
|
9
|
-
`git cat-file -t #{@ref}`.
|
9
|
+
`git cat-file -t #{@ref}`.strip == "commit"
|
10
10
|
end
|
11
11
|
|
12
12
|
def ref
|
13
|
-
@normalized_ref ||= `git rev-parse #{@ref}`.
|
13
|
+
@normalized_ref ||= `git rev-parse #{@ref}`.strip
|
14
14
|
end
|
15
15
|
|
16
16
|
def message
|
17
|
-
`git log #{@ref} -n1 --pretty=%B`.
|
17
|
+
`git log #{@ref} -n1 --pretty=%B`.strip
|
18
18
|
end
|
19
19
|
|
20
20
|
def time
|
data/lib/envirobly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envirobly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Starsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|