faastruby 0.2.0 → 0.2.1
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 +9 -4
- data/Gemfile.lock +6 -6
- data/README.md +41 -20
- data/lib/faastruby/cli.rb +1 -1
- data/lib/faastruby/cli/commands.rb +3 -0
- data/lib/faastruby/cli/commands/credentials.rb +11 -0
- data/lib/faastruby/cli/commands/credentials/add.rb +58 -0
- data/lib/faastruby/cli/commands/credentials/list.rb +54 -0
- data/lib/faastruby/cli/commands/workspace/create.rb +3 -3
- data/lib/faastruby/cli/credentials.rb +9 -7
- data/lib/faastruby/version.rb +1 -1
- data/lib/faastruby/workspace.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f94b2b6822fa6d477e75642336d2d67c1f7c3f7596e87fa03e9119e43637836
|
4
|
+
data.tar.gz: 49986876b8202867c2e5e388656e517232e2bf2132c3acab624f1021541f4d10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bb18dedc52a1dedb1c379ed4cf318367e44f8e175a0ebe02b74f3ac7ca3e6d3829ff65cf49113beaa8a122e78cb2c3ce12f6c9de64e0afa8782e2d7a943cb94
|
7
|
+
data.tar.gz: 567d11e675800ae13e529aacb05011f207158673b7cc25874bfa93bdbae3cd1363c45ab3279280b3855eae417517da3392a7b7bff6776fba757bb1b8fdb96b63
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.1 - Oct 16 2018
|
4
|
+
- New command: `add-credentials` - add credentials to a credentials file
|
5
|
+
- New command: `list-credentials` - list current credentials in a credentials file
|
6
|
+
Run `faastruby help` for usage details.
|
7
|
+
|
3
8
|
## 0.2.0 - Oct 12 2018
|
4
|
-
- Full rewrite of the gem. All command line parameters have changed. Please see the documentation.
|
5
|
-
- No more git
|
6
|
-
- Functions are packaged
|
9
|
+
- Full rewrite of the gem. All command line parameters have changed. Please see the [documentation](https://faastruby.io/tutorial.html).
|
10
|
+
- No more git repositories.
|
11
|
+
- Functions are packaged, deployed and managed individually.
|
7
12
|
- Functions have a YAML configuration file.
|
8
|
-
- Functions can have tests and they can be configured to run before each deploy, aborting
|
13
|
+
- Functions can have tests and they can be configured to run before each deploy, aborting if a failure happens.
|
9
14
|
- Added option to print or save the workspace credentials into a different file upon creation, instead of saving it to ~/.faastruby
|
10
15
|
- Read a different credentials file via FAASTRUBY_CREDENTIALS environment variable.
|
11
16
|
- Read credentials via environment variables: FAASTRUBY_API_KEY and FAASTRUBY_API_SECRET.
|
data/Gemfile.lock
CHANGED
@@ -2,12 +2,12 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
faastruby (0.2.0)
|
5
|
-
colorize
|
6
|
-
oj
|
7
|
-
rest-client
|
8
|
-
rubyzip
|
9
|
-
tty-spinner
|
10
|
-
tty-table
|
5
|
+
colorize (~> 0.8)
|
6
|
+
oj (~> 3.6)
|
7
|
+
rest-client (~> 2.0)
|
8
|
+
rubyzip (~> 1.2)
|
9
|
+
tty-spinner (~> 0.8)
|
10
|
+
tty-table (~> 0.10)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
data/README.md
CHANGED
@@ -1,39 +1,60 @@
|
|
1
|
-
|
1
|
+
[](https://badge.fury.io/rb/faastruby)
|
2
2
|
|
3
|
-
|
3
|
+
# faastruby-cli
|
4
4
|
|
5
|
-
|
5
|
+
CLI tool for managing workspaces and functions hosted at [FaaStRuby](https://faastruby.io).
|
6
6
|
|
7
|
-
##
|
7
|
+
## What is FaaStRuby?
|
8
|
+
Fast, lightweight and scalable serverless platform built for Ruby developers.
|
8
9
|
|
9
|
-
|
10
|
+
* [Tutorial](https://faastruby.io/tutorial.html)
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
## Try it
|
13
|
+
|
14
|
+
1. Install the gem:
|
15
|
+
|
16
|
+
```
|
17
|
+
$ gem install faastruby
|
13
18
|
```
|
14
19
|
|
15
|
-
|
20
|
+
2. Create a workspace to deploy your functions. The workspace name must be unique (like a username).
|
16
21
|
|
17
|
-
|
22
|
+
```
|
23
|
+
$ faastruby create-workspace awesome-prod
|
24
|
+
```
|
18
25
|
|
19
|
-
|
26
|
+
3. Create a function and deploy it to your workspace:
|
20
27
|
|
21
|
-
|
28
|
+
```
|
29
|
+
$ faastruby new my-first-function
|
30
|
+
$ cd my-first-function
|
31
|
+
$ faastruby deploy-to awesome-prod
|
32
|
+
◐ Running tests... Passed!
|
33
|
+
...
|
22
34
|
|
23
|
-
|
35
|
+
Finished in 0.00563 seconds (files took 0.15076 seconds to load)
|
36
|
+
3 examples, 0 failures
|
24
37
|
|
25
|
-
|
38
|
+
◐ Building package... Done!
|
39
|
+
◐ Deploying to workspace 'awesome-prod'... Done!
|
40
|
+
```
|
26
41
|
|
27
|
-
|
42
|
+
4. Run it:
|
28
43
|
|
29
|
-
|
44
|
+
```
|
45
|
+
$ faastruby run awesome-prod --json '{"name":"Ruby"}'
|
46
|
+
Hello, Ruby!
|
47
|
+
```
|
30
48
|
|
31
|
-
|
49
|
+
You can also generate a CURL command:
|
32
50
|
|
33
|
-
|
51
|
+
```
|
52
|
+
$ faastruby run awesome-prod --json '{"name":"Ruby"}' --header 'My-Header: value' --query 'foo=bar' --query 'baz=fox' --curl
|
53
|
+
curl -X POST -H 'Content-Type: application/json' -H 'My-Header: value' -d '{"name":"Ruby"}' 'https://api.faastruby.io/awesome-prod/my-first-function?foo=bar&baz=fox'
|
54
|
+
```
|
34
55
|
|
35
|
-
|
56
|
+
Build lots of functions and share them with fellow Ruby devs!
|
36
57
|
|
37
|
-
##
|
58
|
+
## FaaStRuby + Hyperstack = fullstack Ruby apps!
|
38
59
|
|
39
|
-
|
60
|
+
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/lib/faastruby/cli.rb
CHANGED
@@ -35,6 +35,7 @@ end
|
|
35
35
|
require 'faastruby/cli/credentials'
|
36
36
|
require 'faastruby/cli/commands/function'
|
37
37
|
require 'faastruby/cli/commands/workspace'
|
38
|
+
require 'faastruby/cli/commands/credentials'
|
38
39
|
require 'faastruby/cli/commands/help'
|
39
40
|
require 'faastruby/cli/commands/version'
|
40
41
|
|
@@ -52,6 +53,8 @@ module FaaStRuby
|
|
52
53
|
'list-workspace' => FaaStRuby::Command::Workspace::List,
|
53
54
|
'test' => FaaStRuby::Command::Function::Test,
|
54
55
|
'run' => FaaStRuby::Command::Function::Run,
|
56
|
+
'add-credentials' => FaaStRuby::Command::Credentials::Add,
|
57
|
+
'list-credentials' => FaaStRuby::Command::Credentials::List,
|
55
58
|
'help' => FaaStRuby::Command::Help,
|
56
59
|
'-h' => FaaStRuby::Command::Help,
|
57
60
|
'--help' => FaaStRuby::Command::Help,
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module FaaStRuby
|
2
|
+
module Command
|
3
|
+
module Credentials
|
4
|
+
class Add < CredentialsBaseCommand
|
5
|
+
def initialize(args)
|
6
|
+
@args = args
|
7
|
+
@workspace_name = @args.shift
|
8
|
+
FaaStRuby::CLI.error(['Missing argument: WORKSPACE_NAME'.red, usage], color: nil) if @workspace_name.nil? || @workspace_name =~ /^-.*/
|
9
|
+
parse_options
|
10
|
+
@options['credentials_file'] ||= FAASTRUBY_CREDENTIALS
|
11
|
+
@missing_args = []
|
12
|
+
FaaStRuby::CLI.error(@missing_args, color: nil) if missing_args.any?
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
new_credentials = {'api_key' => @options['api_key'], 'api_secret' => @options['api_secret']}
|
17
|
+
FaaStRuby::Credentials.add(@workspace_name, new_credentials, @options['credentials_file'])
|
18
|
+
puts "Credentials file updated."
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.help
|
22
|
+
"add-credentials".blue + " WORKSPACE_NAME -k API_KEY -s API_SECRET [-c CREDENTIALS_FILE]"
|
23
|
+
end
|
24
|
+
|
25
|
+
def usage
|
26
|
+
"Usage: faastruby #{self.class.help}"
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def missing_args
|
32
|
+
@missing_args << "Missing argument: API_KEY".red unless @options['api_key']
|
33
|
+
@missing_args << "Missing argument: API_SECRET".red unless @options['api_secret']
|
34
|
+
@missing_args << "Missing argument: CREDENTIALS_FILE".red unless @options['credentials_file']
|
35
|
+
@missing_args << usage if @missing_args.any?
|
36
|
+
@missing_args
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_options
|
40
|
+
@options = {}
|
41
|
+
while @args.any?
|
42
|
+
option = @args.shift
|
43
|
+
case option
|
44
|
+
when '-k', '--api-key'
|
45
|
+
@options['api_key'] = @args.shift
|
46
|
+
when '-c', '--credentials-file'
|
47
|
+
@options['credentials_file'] = @args.shift
|
48
|
+
when '-s', '--api-secret'
|
49
|
+
@options['api_secret'] = @args.shift
|
50
|
+
else
|
51
|
+
FaaStRuby::CLI.error(["Unknown argument: #{option}".red, usage], color: nil)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module FaaStRuby
|
2
|
+
module Command
|
3
|
+
module Credentials
|
4
|
+
class List < CredentialsBaseCommand
|
5
|
+
def initialize(args)
|
6
|
+
@args = args
|
7
|
+
parse_options
|
8
|
+
@options['credentials_file'] ||= FAASTRUBY_CREDENTIALS
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
FaaStRuby::CLI.error("The file '#{@options['credentials_file']}' does not exist.") unless File.file?(@options['credentials_file'])
|
13
|
+
rows = []
|
14
|
+
credentials = FaaStRuby::Credentials.load_credentials_file(@options['credentials_file'])
|
15
|
+
FaaStRuby::CLI.error("The credentials file '#{@options['credentials_file']}' is empty.") unless credentials.any?
|
16
|
+
credentials.each do |workspace, credentials|
|
17
|
+
rows << [workspace, credentials['api_key'], credentials['api_secret']]
|
18
|
+
end
|
19
|
+
table = TTY::Table.new(['Workspace','API_KEY', 'API_SECRET'], rows)
|
20
|
+
puts table.render(:basic)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.help
|
24
|
+
"list-credentials".blue + " [-c CREDENTIALS_FILE]"
|
25
|
+
end
|
26
|
+
|
27
|
+
def usage
|
28
|
+
"Usage: faastruby #{self.class.help}"
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def missing_args
|
34
|
+
@missing_args << "Missing argument: CREDENTIALS_FILE".red unless @options['credentials_file']
|
35
|
+
@missing_args << usage if @missing_args.any?
|
36
|
+
@missing_args
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_options
|
40
|
+
@options = {}
|
41
|
+
while @args.any?
|
42
|
+
option = @args.shift
|
43
|
+
case option
|
44
|
+
when '-c', '--credentials-file'
|
45
|
+
@options['credentials_file'] = @args.shift
|
46
|
+
else
|
47
|
+
FaaStRuby::CLI.error(["Unknown argument: #{option}".red, usage], color: nil)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -28,7 +28,7 @@ module FaaStRuby
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.help
|
31
|
-
"create-workspace".blue + " WORKSPACE_NAME [--stdout|-
|
31
|
+
"create-workspace".blue + " WORKSPACE_NAME [--stdout|-c, --credentials-file CREDENTIALS_FILE] [-e, --email YOUR_EMAIL_ADDRESS]"
|
32
32
|
end
|
33
33
|
|
34
34
|
def usage
|
@@ -40,7 +40,7 @@ module FaaStRuby
|
|
40
40
|
def missing_args
|
41
41
|
if @args.empty?
|
42
42
|
@missing_args << "Missing argument: WORKSPACE_NAME".red
|
43
|
-
@missing_args <<
|
43
|
+
@missing_args << usage
|
44
44
|
end
|
45
45
|
FaaStRuby::CLI.error(["'#{@args.first}' is not a valid workspace name.".red, usage], color: nil) if @args.first =~ /^-.*/
|
46
46
|
@missing_args
|
@@ -55,7 +55,7 @@ module FaaStRuby
|
|
55
55
|
# @options['credentials_file'] = @args.shift
|
56
56
|
when '--stdout'
|
57
57
|
@options['stdout'] = true
|
58
|
-
when '-
|
58
|
+
when '-c', '--credentials-file'
|
59
59
|
@options['credentials_file'] = @args.shift
|
60
60
|
when '-e', '--email'
|
61
61
|
@options['email'] = @args.shift
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module FaaStRuby
|
2
2
|
class Credentials # TODO: change it to YAML?
|
3
|
-
def self.load_credentials_file
|
4
|
-
if File.file?(
|
5
|
-
Oj.load(File.read(
|
3
|
+
def self.load_credentials_file(credentials_file = FAASTRUBY_CREDENTIALS)
|
4
|
+
if File.file?(credentials_file)
|
5
|
+
creds = Oj.load(File.read(credentials_file))
|
6
|
+
return creds if creds.is_a?(Hash)
|
7
|
+
return {}
|
6
8
|
else
|
7
9
|
{}
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.add(workspace_name, new_credentials, credentials_file)
|
12
|
-
credentials = load_credentials_file
|
14
|
+
credentials = load_credentials_file(credentials_file)
|
13
15
|
credentials.merge!({workspace_name => new_credentials})
|
14
16
|
save_file(credentials, credentials_file)
|
15
17
|
end
|
@@ -32,9 +34,9 @@ module FaaStRuby
|
|
32
34
|
puts "#{symbol} f #{credentials_file}".colorize(color)
|
33
35
|
end
|
34
36
|
|
35
|
-
def self.load_for(workspace_name)
|
36
|
-
credentials = load_from_env(workspace_name) || load_credentials_file
|
37
|
-
FaaStRuby::CLI.error("Could not find credentials for '#{workspace_name}' in '#{
|
37
|
+
def self.load_for(workspace_name, cred_file = FAASTRUBY_CREDENTIALS)
|
38
|
+
credentials = load_from_env(workspace_name) || load_credentials_file(cred_file)
|
39
|
+
FaaStRuby::CLI.error("Could not find credentials for '#{workspace_name}' in '#{cred_file}'") unless credentials.has_key?(workspace_name)
|
38
40
|
FaaStRuby.configure do |config|
|
39
41
|
config.api_key = credentials[workspace_name]['api_key']
|
40
42
|
config.api_secret = credentials[workspace_name]['api_secret']
|
data/lib/faastruby/version.rb
CHANGED
data/lib/faastruby/workspace.rb
CHANGED
@@ -13,7 +13,7 @@ module FaaStRuby
|
|
13
13
|
case response.code
|
14
14
|
when 422
|
15
15
|
workspace.errors += ['(422) Unprocessable Entity', response.body]
|
16
|
-
when 200
|
16
|
+
when 200, 201
|
17
17
|
workspace.credentials = response.body['credentials']
|
18
18
|
else
|
19
19
|
workspace.errors << "(#{response.code}) Error"
|
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.1
|
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-10-
|
11
|
+
date: 2018-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -156,6 +156,9 @@ files:
|
|
156
156
|
- lib/faastruby/base.rb
|
157
157
|
- lib/faastruby/cli.rb
|
158
158
|
- lib/faastruby/cli/commands.rb
|
159
|
+
- lib/faastruby/cli/commands/credentials.rb
|
160
|
+
- lib/faastruby/cli/commands/credentials/add.rb
|
161
|
+
- lib/faastruby/cli/commands/credentials/list.rb
|
159
162
|
- lib/faastruby/cli/commands/function.rb
|
160
163
|
- lib/faastruby/cli/commands/function/build.rb
|
161
164
|
- lib/faastruby/cli/commands/function/deploy.rb
|