jarbs 0.5.3 → 0.5.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9341d906bb5a7ed7e80b4216c73cd21ebf7b5ec2
4
- data.tar.gz: f04b43e11edd1e748769cc6972fbf03e8c6aa99b
3
+ metadata.gz: 80c0ed1b1f5fd38489ea989503475ffdd1758219
4
+ data.tar.gz: bc04c29c3bc74f163189be69feaa9b5ad4e64dac
5
5
  SHA512:
6
- metadata.gz: 976383ac721a3f5c83f53338cdc5885613b86176526135913f74b5f40cff50c41c743d3a18d108d85d82159a5b2e61a3198b4781d954ffbe4757b8e936974870
7
- data.tar.gz: 529778eb06aa4036e8157a67c69c757c6555a86b6c2a1f79d97581862575abf813156ecba9d6c53b48e05253245bebecea7d93446fd714e14676e88a7dbf0997
6
+ metadata.gz: b3f8059131403aac6efe3b5fc31e45d1a8b7a97886cc649480e4b131d38303d30b26566a2ef3fc8b0b2431b5e1288b5067db59b53712f9bb195ae2c91e84f522
7
+ data.tar.gz: 4b5b269192663041025ac69be82d7010622404912a6a3dc53e9b154ffc4639aaf8096646bbddcfa3a9cab44fde34d9f570589edae28d523aa642f9c757497b6f
data/lib/jarbs.rb CHANGED
@@ -31,8 +31,11 @@ module Jarbs
31
31
  program :version, Jarbs::VERSION
32
32
  program :description, 'Lambda Tooling'
33
33
 
34
- global_option('-e', '--env ENV', String, 'Set deployment environment [Default to dev]')
34
+ global_option('-e', '--env [dev]', String, 'Set deployment environment')
35
35
  global_option('-d', '--debug', 'Enable debug mode') { $debug = true }
36
+ global_option('-p', '--profile [default]', String, 'AWS credential profile to use') do |profile|
37
+ @config.set('aws.profile', profile)
38
+ end
36
39
 
37
40
  command :new do |c|
38
41
  c.syntax = 'jarbs new [options] name'
@@ -40,7 +43,7 @@ module Jarbs
40
43
  c.option "-f", "--force", "Force overwrite of existing function definition"
41
44
  c.action do |args, options|
42
45
  name = args.shift || abort("Must provide a lambda name")
43
- options.default GLOBAL_DEFAULTS
46
+ options.default global_defaults
44
47
 
45
48
  lambda = Lambda.new(name, options)
46
49
 
@@ -58,7 +61,7 @@ module Jarbs
58
61
  c.option "--role [STRING]", String, "IAM role for Lambda execution"
59
62
  c.action do |args, options|
60
63
  name = args.shift || abort('Name argument required')
61
- options.default GLOBAL_DEFAULTS
64
+ options.default global_defaults
62
65
 
63
66
  lambda = Lambda.new(name, options)
64
67
 
@@ -73,7 +76,7 @@ module Jarbs
73
76
  c.summary = "Delete a lambda function"
74
77
  c.action do |args, options|
75
78
  abort('Name argument required') if args.empty?
76
- options.default GLOBAL_DEFAULTS
79
+ options.default global_defaults
77
80
 
78
81
  begin
79
82
  args.each do |fn|
@@ -105,6 +108,14 @@ module Jarbs
105
108
 
106
109
  private
107
110
 
111
+ def profile
112
+ @config.get('aws.profile') { 'default' }
113
+ end
114
+
115
+ def global_defaults
116
+ GLOBAL_DEFAULTS.merge profile: profile
117
+ end
118
+
108
119
  def project_exists?(name, remove: false)
109
120
  if Dir.exists? name
110
121
  if remove
@@ -11,9 +11,9 @@ module Jarbs
11
11
  password: password('Password (not saved): ')
12
12
  end
13
13
 
14
- def generate_token
14
+ def generate_token(name)
15
15
  resp = @client.create_authorization scopes: ['public_repo'],
16
- note: 'Jarbs error reporting',
16
+ note: "Jarbs error reporting for #{name}",
17
17
  headers: { 'X-GitHub-OTP' => ask('GitHub two-factor token: ') }
18
18
 
19
19
  @config.set('github.token', resp.token)
data/lib/jarbs/lambda.rb CHANGED
@@ -18,7 +18,9 @@ module Jarbs
18
18
  @options = options
19
19
 
20
20
  @function = FunctionDefinition.new(name, @options.env)
21
- @client = Aws::Lambda::Client.new region: default_region
21
+
22
+ credentials = Aws::SharedCredentials.new(profile_name: @options.profile)
23
+ @client = Aws::Lambda::Client.new region: default_region, credentials: credentials
22
24
  end
23
25
 
24
26
  def generate
@@ -44,7 +44,7 @@ module Jarbs
44
44
  agree("Would you like to log jarbs crashes to GitHub automatically (y/n)? ")
45
45
  end
46
46
 
47
- GithubAuth.new(config).generate_token if autolog
47
+ GithubAuth.new(config).generate_token(@name) if autolog
48
48
  end
49
49
  end
50
50
  end
data/lib/jarbs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jarbs
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jarbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke van der Hoeven