faastruby 0.3.2 → 0.3.3
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 +4 -0
- data/example/handler.rb +1 -1
- data/example/spec/handler_spec.rb +2 -2
- data/lib/faastruby/cli/commands/function/deploy_to.rb +21 -1
- data/lib/faastruby/cli/commands/workspace/create.rb +3 -3
- data/lib/faastruby/cli/credentials.rb +9 -2
- 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: 335fa3ccc2c149a7f7c8f1551bf9e19d20d6195a81020557d252d580e157785c
|
4
|
+
data.tar.gz: ec71694b2713127f156d6424c71594559da5a44f80b434a5a2dc9b87cfbaa8b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d28851b29694062dcb7a4a04b35e290629a6f759dda9c244cdc44bef0eea177a37bc2f946042855f9fdd3bd1faa072e3c51d0b6bf9f391ad409fa6392b6dbc6
|
7
|
+
data.tar.gz: 758524d34c9a46aaf105ff92dd0618de98574e44fd0fad5543764b1e4a74b773659aafe8f601d45dd1400c51472556aa67a642f13bb353ade244746e68496e6e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.3.3 - Dec 21 2018
|
4
|
+
- `deploy-to` will try to create the workspace if it doesn't exist.
|
5
|
+
- Changed template to add a carriage return.
|
6
|
+
|
3
7
|
## 0.3.2 - Dec 15 2018
|
4
8
|
- Better output for tests
|
5
9
|
- `bundle check && bundle install` runs before building a package to make sure Gemfile.lock is updated.
|
data/example/handler.rb
CHANGED
@@ -21,5 +21,5 @@ def handler event
|
|
21
21
|
# The 'Content-Type' header is automatically set when you use 'render'.
|
22
22
|
# You can set custom headers using a hash with string keys. Example:
|
23
23
|
# render text: 'It Works!', headers: {'TransactionId' => 23928}
|
24
|
-
render text: "Hello, #{data['name'] || 'World'}
|
24
|
+
render text: "Hello, #{data['name'] || 'World'}!\n"
|
25
25
|
end
|
@@ -10,11 +10,11 @@ describe 'handler(event)' do
|
|
10
10
|
end
|
11
11
|
it 'should add the name to the response string' do
|
12
12
|
body = handler(event).call.body
|
13
|
-
expect(body).to be ==
|
13
|
+
expect(body).to be == "Hello, Ruby!\n"
|
14
14
|
end
|
15
15
|
it 'should say Hello, World! when name is not present' do
|
16
16
|
event = SpecHelper::Event.new(body: nil)
|
17
17
|
body = handler(event).call.body
|
18
|
-
expect(body).to be ==
|
18
|
+
expect(body).to be == "Hello, World!\n"
|
19
19
|
end
|
20
20
|
end
|
@@ -10,10 +10,11 @@ module FaaStRuby
|
|
10
10
|
load_yaml
|
11
11
|
@function_name = @yaml_config['name']
|
12
12
|
@abort_when_tests_fail = @yaml_config['abort_deploy_when_tests_fail']
|
13
|
-
|
13
|
+
load_credentials(exit_on_error: false)
|
14
14
|
end
|
15
15
|
|
16
16
|
def run
|
17
|
+
create_or_use_workspace
|
17
18
|
FaaStRuby::CLI.error('Please fix the problems above and try again') unless bundle_install
|
18
19
|
tests_passed = run_tests
|
19
20
|
FaaStRuby::CLI.error("Deploy aborted because tests failed and you have 'abort_deploy_when_tests_fail: true' in 'faastruby.yml'") unless tests_passed || !@abort_when_tests_fail
|
@@ -26,6 +27,7 @@ module FaaStRuby
|
|
26
27
|
FaaStRuby::CLI.error(workspace.errors)
|
27
28
|
end
|
28
29
|
spinner.stop('Done!')
|
30
|
+
puts "Endpoint: #{FaaStRuby.api_host}/#{@workspace_name}/#{@function_name}"
|
29
31
|
exit 0
|
30
32
|
end
|
31
33
|
|
@@ -39,6 +41,24 @@ module FaaStRuby
|
|
39
41
|
|
40
42
|
private
|
41
43
|
|
44
|
+
def load_credentials(exit_on_error:)
|
45
|
+
@has_credentials = FaaStRuby::Credentials.load_for(@workspace_name, exit_on_error: exit_on_error)
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_or_use_workspace
|
49
|
+
unless @has_credentials
|
50
|
+
puts "Attemping to create workspace '#{@workspace_name}'"
|
51
|
+
cmd = FaaStRuby::Command::Workspace::Create.new([@workspace_name])
|
52
|
+
cmd.run(create_directory: false, exit_on_error: false)
|
53
|
+
load_credentials(exit_on_error: true)
|
54
|
+
# Give a little bit of time after creating the workspace
|
55
|
+
# for consistency. This is temporary until the API gets patched.
|
56
|
+
spinner = spin("Waiting for the new workspace to be ready...")
|
57
|
+
sleep 2
|
58
|
+
spinner.stop("Done!")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
42
62
|
def bundle_install
|
43
63
|
puts '[build] Verifying dependencies'
|
44
64
|
return true unless File.file?('Gemfile')
|
@@ -12,11 +12,11 @@ module FaaStRuby
|
|
12
12
|
@options['credentials_file'] ||= FaaStRuby.credentials_file
|
13
13
|
end
|
14
14
|
|
15
|
-
def run
|
15
|
+
def run(create_directory: true, exit_on_error: true)
|
16
16
|
spinner = spin("Requesting credentials...")
|
17
17
|
workspace = FaaStRuby::Workspace.create(name: @workspace_name, email: @options['email'])
|
18
18
|
spinner.stop("Done!")
|
19
|
-
FaaStRuby::CLI.error(workspace.errors) if workspace.errors.any?
|
19
|
+
FaaStRuby::CLI.error(workspace.errors) if workspace.errors.any? && exit_on_error
|
20
20
|
if @options['stdout']
|
21
21
|
puts "IMPORTANT: Please store the credentials below in a safe place. If you lose them you will not be able to manage your workspace.".yellow
|
22
22
|
puts "API_KEY: #{workspace.credentials['api_key']}"
|
@@ -26,7 +26,7 @@ module FaaStRuby
|
|
26
26
|
FaaStRuby::Credentials.add(@workspace_name, workspace.credentials, @options['credentials_file'])
|
27
27
|
end
|
28
28
|
puts "Workspace '#{@workspace_name}' created"
|
29
|
-
create_dir
|
29
|
+
create_dir if create_directory && !dir_exists?
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.help
|
@@ -34,13 +34,20 @@ 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 = FaaStRuby.credentials_file)
|
37
|
+
def self.load_for(workspace_name, cred_file = FaaStRuby.credentials_file, exit_on_error: true)
|
38
38
|
credentials = load_from_env(workspace_name) || load_credentials_file(cred_file)
|
39
|
-
|
39
|
+
error_msg = "Could not find credentials for '#{workspace_name}' in '#{cred_file}'"
|
40
|
+
if exit_on_error && !credentials[workspace_name]
|
41
|
+
FaaStRuby::CLI.error(error_msg)
|
42
|
+
elsif !credentials[workspace_name]
|
43
|
+
puts error_msg
|
44
|
+
return false
|
45
|
+
end
|
40
46
|
FaaStRuby.configure do |config|
|
41
47
|
config.api_key = credentials[workspace_name]['api_key']
|
42
48
|
config.api_secret = credentials[workspace_name]['api_secret']
|
43
49
|
end
|
50
|
+
return true
|
44
51
|
end
|
45
52
|
|
46
53
|
def self.load_from_env(workspace_name)
|
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.3.
|
4
|
+
version: 0.3.3
|
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-12-
|
11
|
+
date: 2018-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|