faastruby 0.2.3 → 0.2.5
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 +7 -2
- data/Gemfile.lock +2 -2
- data/README.md +2 -2
- data/exe/faastruby +5 -1
- data/lib/faastruby/api.rb +3 -3
- data/lib/faastruby/base.rb +28 -3
- data/lib/faastruby/cli.rb +6 -2
- data/lib/faastruby/cli/commands.rb +1 -1
- data/lib/faastruby/cli/commands/credentials/add.rb +1 -1
- data/lib/faastruby/cli/commands/credentials/list.rb +1 -1
- data/lib/faastruby/cli/commands/function/run.rb +1 -1
- data/lib/faastruby/cli/commands/workspace/create.rb +2 -2
- data/lib/faastruby/cli/commands/workspace/destroy.rb +2 -2
- data/lib/faastruby/cli/commands/workspace/list.rb +2 -2
- data/lib/faastruby/cli/credentials.rb +3 -3
- data/lib/faastruby/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: 6923262dc376ee5d45aecf773ab79effc56ac3c41be86f32e543a088d4482301
|
4
|
+
data.tar.gz: f5fdbb23a2b0b40392d520ef46adb0849949d622145f2fc0e4f05b822acb24d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32b98888ae961eade9329627bafb2ddfd834966b6a0676316735a2619d06faa5942c1c5016c0e395315d70e6ca211ed7a0d481b4b009805f37ec5f857bf3495f
|
7
|
+
data.tar.gz: 8fbda1fd86bb74e58fb34f7a22789b28f78061174fbb5ff769dd3a64c3a15fc20fac89d48d7c5d707b14add1116c9634624be7688f3e605ec2c0594acb37beae
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 0.2.
|
3
|
+
## 0.2.5 - Nov 18 2018
|
4
|
+
- Support for multiple regions with `faastruby --region [REGION] ...`
|
5
|
+
|
6
|
+
## 0.2.4 - Skipped
|
7
|
+
|
8
|
+
## 0.2.3 - Oct 20 2018
|
4
9
|
- Added #status_code to Workspace class to hold the API response code after a request
|
5
10
|
- Added refresh_credentials endpoint
|
6
11
|
- Fix the request headers
|
@@ -25,4 +30,4 @@ Run `faastruby help` for usage details.
|
|
25
30
|
- Functions can have tests and they can be configured to run before each deploy, aborting if a failure happens.
|
26
31
|
- Added option to print or save the workspace credentials into a different file upon creation, instead of saving it to ~/.faastruby
|
27
32
|
- Read a different credentials file via FAASTRUBY_CREDENTIALS environment variable.
|
28
|
-
- Read credentials via environment variables: FAASTRUBY_API_KEY and FAASTRUBY_API_SECRET.
|
33
|
+
- Read credentials via environment variables: FAASTRUBY_API_KEY and FAASTRUBY_API_SECRET.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
faastruby (0.2.
|
4
|
+
faastruby (0.2.4)
|
5
5
|
colorize (~> 0.8)
|
6
6
|
oj (~> 3.6)
|
7
7
|
rest-client (~> 2.0)
|
@@ -29,7 +29,7 @@ GEM
|
|
29
29
|
mime-types-data (3.2018.0812)
|
30
30
|
necromancer (0.4.0)
|
31
31
|
netrc (0.11.0)
|
32
|
-
oj (3.
|
32
|
+
oj (3.7.0)
|
33
33
|
pastel (0.7.2)
|
34
34
|
equatable (~> 0.5.0)
|
35
35
|
tty-color (~> 0.4.0)
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
CLI tool for managing workspaces and functions hosted at [FaaStRuby](https://faastruby.io).
|
7
7
|
|
8
8
|
## What is FaaStRuby?
|
9
|
-
|
9
|
+
FaaStRuby is a serverless platform built for Ruby developers.
|
10
10
|
|
11
11
|
* [Tutorial](https://faastruby.io/tutorial.html)
|
12
12
|
|
@@ -58,4 +58,4 @@ Build lots of functions and share them with fellow Ruby devs!
|
|
58
58
|
|
59
59
|
## FaaStRuby + Hyperstack = fullstack Ruby apps!
|
60
60
|
|
61
|
-
Do you think JavaScript is your only option for the front-end? Think again. [Hyperstack](https://hyperstack.org) is a Ruby DSL, compiled by Opal, bundled by Webpack, powered by React.
|
61
|
+
Do you think JavaScript is your only option for the front-end? Think again. [Hyperstack](https://hyperstack.org) is a Ruby DSL, compiled by Opal, bundled by Webpack, powered by React.
|
data/exe/faastruby
CHANGED
data/lib/faastruby/api.rb
CHANGED
@@ -5,7 +5,7 @@ module FaaStRuby
|
|
5
5
|
@@api_version = 'v2'
|
6
6
|
attr_reader :api_url, :credentials, :headers
|
7
7
|
def initialize
|
8
|
-
@api_url = "#{
|
8
|
+
@api_url = "#{FaaStRuby.api_host}/#{@@api_version}"
|
9
9
|
@credentials = {'API-KEY' => FaaStRuby.api_key, 'API-SECRET' => FaaStRuby.api_secret}
|
10
10
|
@headers = {content_type: 'application/json', accept: 'application/json'}.merge(@credentials)
|
11
11
|
@struct = Struct.new(:response, :body, :errors, :code)
|
@@ -57,7 +57,7 @@ module FaaStRuby
|
|
57
57
|
# end
|
58
58
|
|
59
59
|
def run(function_name:, workspace_name:, payload:, method:, headers: {}, time: false, query: nil)
|
60
|
-
url = "#{
|
60
|
+
url = "#{FaaStRuby.api_host}/#{workspace_name}/#{function_name}#{query}"
|
61
61
|
headers['Benchmark'] = true if time
|
62
62
|
if method == 'get'
|
63
63
|
RestClient.public_send(method, url, headers){|response, request, result| response }
|
@@ -95,4 +95,4 @@ module FaaStRuby
|
|
95
95
|
@struct.new(nil, nil, errors, code)
|
96
96
|
end
|
97
97
|
end
|
98
|
-
end
|
98
|
+
end
|
data/lib/faastruby/base.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module FaaStRuby
|
2
|
-
|
3
|
-
|
2
|
+
ROOT_DOMAIN = ENV['FAASTRUBY_ROOT_DOMAIN'] || 'faastruby.io'
|
3
|
+
DEFAULT_REGION = 'tor1'
|
4
|
+
REGIONS = [
|
5
|
+
'tor1',
|
6
|
+
'sfo2'
|
7
|
+
]
|
4
8
|
class << self
|
5
9
|
attr_accessor :configuration
|
6
10
|
end
|
@@ -22,6 +26,27 @@ module FaaStRuby
|
|
22
26
|
{api_key: api_key, api_secret: api_secret}
|
23
27
|
end
|
24
28
|
|
29
|
+
def self.region
|
30
|
+
ENV['FAASTRUBY_REGION'] ||= DEFAULT_REGION
|
31
|
+
raise "No such region: #{ENV['FAASTRUBY_REGION']}" unless FaaStRuby::REGIONS.include?(ENV['FAASTRUBY_REGION'])
|
32
|
+
ENV['FAASTRUBY_REGION']
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.api_host
|
36
|
+
ENV['FAASTRUBY_HOST'] || "https://api.#{region}.#{ROOT_DOMAIN}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.credentials_file
|
40
|
+
return File.expand_path(ENV['FAASTRUBY_CREDENTIALS']) if ENV['FAASTRUBY_CREDENTIALS']
|
41
|
+
if region == DEFAULT_REGION && File.file?(File.expand_path('~/.faastruby'))
|
42
|
+
return File.expand_path('~/.faastruby')
|
43
|
+
elsif region == DEFAULT_REGION
|
44
|
+
return File.expand_path("~/.faastruby.#{region}")
|
45
|
+
else
|
46
|
+
return File.expand_path("~/.faastruby.#{region}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
25
50
|
class Configuration
|
26
51
|
attr_accessor :api_key, :api_secret
|
27
52
|
end
|
@@ -50,4 +75,4 @@ module FaaStRuby
|
|
50
75
|
end
|
51
76
|
end
|
52
77
|
end
|
53
|
-
end
|
78
|
+
end
|
data/lib/faastruby/cli.rb
CHANGED
@@ -8,9 +8,7 @@ require 'faastruby/cli/package'
|
|
8
8
|
|
9
9
|
module FaaStRuby
|
10
10
|
FAASTRUBY_YAML = 'faastruby.yml'
|
11
|
-
FAASTRUBY_CREDENTIALS = File.expand_path(ENV['FAASTRUBY_CREDENTIALS'] || '~/.faastruby')
|
12
11
|
SPINNER_FORMAT = :spin_2
|
13
|
-
|
14
12
|
class CLI
|
15
13
|
def self.error(message, color: :red)
|
16
14
|
message.each {|m| STDERR.puts m.colorize(color)} if message.is_a?(Array)
|
@@ -24,6 +22,7 @@ module FaaStRuby
|
|
24
22
|
return
|
25
23
|
end
|
26
24
|
check_version
|
25
|
+
check_region
|
27
26
|
error("Unknown command: #{command}") unless FaaStRuby::Command::COMMANDS.has_key?(command)
|
28
27
|
FaaStRuby::Command::COMMANDS[command].new(args).run
|
29
28
|
end
|
@@ -38,5 +37,10 @@ module FaaStRuby
|
|
38
37
|
], color: nil)
|
39
38
|
end
|
40
39
|
end
|
40
|
+
|
41
|
+
def self.check_region
|
42
|
+
ENV['FAASTRUBY_REGION'] ||= DEFAULT_REGION
|
43
|
+
error(["No such region: #{ENV['FAASTRUBY_REGION']}".red, "Valid regions are: #{FaaStRuby::REGIONS.join(' | ')}"], color: nil) unless FaaStRuby::REGIONS.include?(ENV['FAASTRUBY_REGION'])
|
44
|
+
end
|
41
45
|
end
|
42
46
|
end
|
@@ -7,7 +7,7 @@ module FaaStRuby
|
|
7
7
|
@workspace_name = @args.shift
|
8
8
|
FaaStRuby::CLI.error(['Missing argument: WORKSPACE_NAME'.red, usage], color: nil) if @workspace_name.nil? || @workspace_name =~ /^-.*/
|
9
9
|
parse_options
|
10
|
-
@options['credentials_file'] ||=
|
10
|
+
@options['credentials_file'] ||= FaaStRuby.credentials_file
|
11
11
|
@missing_args = []
|
12
12
|
FaaStRuby::CLI.error(@missing_args, color: nil) if missing_args.any?
|
13
13
|
end
|
@@ -26,7 +26,7 @@ module FaaStRuby
|
|
26
26
|
command << "-X #{@options['method'].upcase}" if @options['method']
|
27
27
|
@options['headers']&.each {|h,v| command << "-H '#{h}: #{v}'"}
|
28
28
|
command << "-d '#{@options['body']}'" if @options['body']
|
29
|
-
command << "'#{
|
29
|
+
command << "'#{FaaStRuby.api_host}/#{@options['workspace_name']}/#{@function_name}#{@options['query']}'"
|
30
30
|
puts command.join(" ")
|
31
31
|
end
|
32
32
|
|
@@ -8,7 +8,7 @@ module FaaStRuby
|
|
8
8
|
FaaStRuby::CLI.error(@missing_args, color: nil) if missing_args.any?
|
9
9
|
@workspace_name = @args.shift
|
10
10
|
parse_options
|
11
|
-
@options['credentials_file'] ||=
|
11
|
+
@options['credentials_file'] ||= FaaStRuby.credentials_file
|
12
12
|
end
|
13
13
|
|
14
14
|
def run
|
@@ -67,4 +67,4 @@ module FaaStRuby
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
|
-
end
|
70
|
+
end
|
@@ -9,7 +9,7 @@ module FaaStRuby
|
|
9
9
|
@workspace_name = @args.shift
|
10
10
|
parse_options
|
11
11
|
FaaStRuby::Credentials.load_for(@workspace_name)
|
12
|
-
@options['credentials_file'] ||=
|
12
|
+
@options['credentials_file'] ||= FaaStRuby.credentials_file
|
13
13
|
end
|
14
14
|
|
15
15
|
def run
|
@@ -63,4 +63,4 @@ module FaaStRuby
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
66
|
-
end
|
66
|
+
end
|
@@ -19,7 +19,7 @@ module FaaStRuby
|
|
19
19
|
def print_functions_table(functions)
|
20
20
|
no_functions unless functions.any?
|
21
21
|
rows = functions.map do |function_name|
|
22
|
-
[function_name, "#{
|
22
|
+
[function_name, "#{FaaStRuby.api_host}/#{@workspace_name}/#{function_name}"]
|
23
23
|
end
|
24
24
|
table = TTY::Table.new(['FUNCTION','ENDPOINT'], rows)
|
25
25
|
puts table.render(:basic)
|
@@ -51,4 +51,4 @@ module FaaStRuby
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
-
end
|
54
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module FaaStRuby
|
2
2
|
class Credentials # TODO: change it to YAML?
|
3
|
-
def self.load_credentials_file(credentials_file =
|
3
|
+
def self.load_credentials_file(credentials_file = FaaStRuby.credentials_file)
|
4
4
|
if File.file?(credentials_file)
|
5
5
|
creds = Oj.load(File.read(credentials_file))
|
6
6
|
return creds if creds.is_a?(Hash)
|
@@ -34,7 +34,7 @@ module FaaStRuby
|
|
34
34
|
puts "#{symbol} f #{credentials_file}".colorize(color)
|
35
35
|
end
|
36
36
|
|
37
|
-
def self.load_for(workspace_name, cred_file =
|
37
|
+
def self.load_for(workspace_name, cred_file = FaaStRuby.credentials_file)
|
38
38
|
credentials = load_from_env(workspace_name) || load_credentials_file(cred_file)
|
39
39
|
FaaStRuby::CLI.error("Could not find credentials for '#{workspace_name}' in '#{cred_file}'") unless credentials.has_key?(workspace_name)
|
40
40
|
FaaStRuby.configure do |config|
|
@@ -49,4 +49,4 @@ module FaaStRuby
|
|
49
49
|
{workspace_name => {'api_key' => ENV['FAASTRUBY_API_KEY'], 'api_secret' => ENV['FAASTRUBY_API_SECRET']}}
|
50
50
|
end
|
51
51
|
end
|
52
|
-
end
|
52
|
+
end
|
data/lib/faastruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faastruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Arruda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|