lamby 2.5.3 → 2.6.0

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
  SHA256:
3
- metadata.gz: 1e7a5dca080f6ad01223f4fb9de1284240d8c3512b0a7790d97bcd4461103ca8
4
- data.tar.gz: 2341bada28a7832cd0035ab03bfbe18b69451864d8e1917c93a64710513708ec
3
+ metadata.gz: 5d9a016b7bcfeb2c05897068c0f4bae484e1769331da8687e1caf743a7acd55a
4
+ data.tar.gz: 0cf5b19f4db83a839aaa64e7f498395803c926cb1088f00779dc02a504211268
5
5
  SHA512:
6
- metadata.gz: 8d9396e54730b3bf3c414d141845a71897b92ffa26a336fd7ca68cc0a8c4c1f6b56e22aadbb008d8838670dbb34878ad7a73087aa528c5edca0947e484774e72
7
- data.tar.gz: 19bf131edee90db7a82b3d6b98cb302639c3cb8d150f595e5c2e2e3258b8bd4ae96b2a2855dccfb8c188634576e10a4bbfae0fffe7e3c2bcae12c12684ded2b9
6
+ metadata.gz: b4ec3d030577596053e61a85c9e3d64917e06caab8b7119a6fcf3bba4d4ba787804e8ebdfa0c175b1925b61ef25c9026eca5989c93c61637b2db89fdaca4f74c
7
+ data.tar.gz: cc7ea0e3b008d694e144f19abdc373b623c80f1df7c8369dee997e0ca3b1ddea98cfb78ecb9836418653d02670604a2d548f38d371d9ac6f80aaf70b088749ba
data/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
 
4
4
  See this http://keepachangelog.com link for information on how we want this documented formatted.
5
5
 
6
+ ## v2.6.0
7
+
8
+ #### Fixed
9
+
10
+ * Support multiple Set-Cookie headers for all rest types.
11
+
6
12
  ## v2.5.3
7
13
 
8
14
  #### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lamby (2.5.3)
4
+ lamby (2.6.0)
5
5
  rack
6
6
 
7
7
  GEM
data/lib/lamby/handler.rb CHANGED
@@ -31,6 +31,13 @@ module Lamby
31
31
  @headers
32
32
  end
33
33
 
34
+ def set_cookies
35
+ return @set_cookies if defined?(@set_cookies)
36
+ @set_cookies = if @headers && @headers['Set-Cookie']
37
+ @headers.delete('Set-Cookie').split("\n")
38
+ end
39
+ end
40
+
34
41
  def body
35
42
  @rbody ||= ''.tap do |rbody|
36
43
  @body.each { |part| rbody << part }
@@ -40,6 +47,7 @@ module Lamby
40
47
  def call
41
48
  return self if @called
42
49
  @status, @headers, @body = call_app
50
+ set_cookies
43
51
  @called = true
44
52
  self
45
53
  end
@@ -11,7 +11,10 @@ module Lamby
11
11
 
12
12
  def response(handler)
13
13
  hhdrs = handler.headers
14
- multivalue_headers = hhdrs.transform_values { |v| Array[v].compact.flatten } if multi_value?
14
+ if multi_value?
15
+ multivalue_headers = hhdrs.transform_values { |v| Array[v].compact.flatten }
16
+ multivalue_headers['Set-Cookie'] = handler.set_cookies if handler.set_cookies
17
+ end
15
18
  status_description = "#{handler.status} #{::Rack::Utils::HTTP_STATUS_CODES[handler.status]}"
16
19
  base64_encode = hhdrs['Content-Transfer-Encoding'] == 'binary' || hhdrs['X-Lamby-Base64'] == '1'
17
20
  body = Base64.strict_encode64(handler.body) if base64_encode
@@ -6,6 +6,15 @@ module Lamby
6
6
  { isBase64Encoded: true, body: handler.body64 }
7
7
  else
8
8
  super
9
+ end.tap do |r|
10
+ if cookies = handler.set_cookies
11
+ if payload_version_one?
12
+ r[:multiValueHeaders] ||= {}
13
+ r[:multiValueHeaders]['Set-Cookie'] = cookies
14
+ else
15
+ r[:cookies] = cookies
16
+ end
17
+ end
9
18
  end
10
19
  end
11
20
 
@@ -79,6 +88,9 @@ module Lamby
79
88
  'HTTP/1.1'
80
89
  end
81
90
 
91
+ def payload_version_one?
92
+ event['version'] == '1.0'
93
+ end
82
94
 
83
95
  end
84
96
  end
@@ -6,6 +6,11 @@ module Lamby
6
6
  { isBase64Encoded: true, body: handler.body64 }
7
7
  else
8
8
  super
9
+ end.tap do |r|
10
+ if cookies = handler.set_cookies
11
+ r[:multiValueHeaders] ||= {}
12
+ r[:multiValueHeaders]['Set-Cookie'] = cookies
13
+ end
9
14
  end
10
15
  end
11
16
 
@@ -1,14 +1,24 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
+ export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
4
5
  export RAILS_ENV=${RAILS_ENV:="production"}
5
6
  export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
6
- export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
7
+ export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
7
8
 
8
9
  # https://github.com/aws/aws-sam-cli/issues/2447
9
10
  export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
10
- export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/myorg/APPNAMEHERE"
11
+ export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}"
11
12
 
13
+ echo '== Creating ECR repository =='
14
+ echo 'You can safely ignore any RepositoryAlreadyExistsException errors...'
15
+ aws ecr create-repository \
16
+ --repository-name "$DEPLOYMENT_NAME" \
17
+ --image-tag-mutability MUTABLE \
18
+ --image-scanning-configuration scanOnPush=true \
19
+ --region "$AWS_DEFAULT_REGION" || true
20
+
21
+ # Build our application code into a deployment folder
12
22
  ./bin/_build
13
23
 
14
24
  export VPCID=${VPCID:=$(
@@ -37,13 +47,13 @@ sam package \
37
47
  --output-template-file ./.aws-sam/build/packaged.yaml \
38
48
  --image-repository "$IMAGE_REPOSITORY" \
39
49
  --s3-bucket "${CLOUDFORMATION_BUCKET}" \
40
- --s3-prefix "APPNAMEHERE-${RAILS_ENV}"
50
+ --s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
41
51
 
42
52
  echo "== SAM deploy..."
43
53
  sam deploy \
44
54
  --region "$AWS_DEFAULT_REGION" \
45
55
  --template-file ./.aws-sam/build/packaged.yaml \
46
- --stack-name "APPNAMEHERE-${RAILS_ENV}" \
56
+ --stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
47
57
  --image-repository "$IMAGE_REPOSITORY" \
48
58
  --capabilities "CAPABILITY_IAM" \
49
59
  --parameter-overrides \
@@ -3,6 +3,10 @@ set -e
3
3
 
4
4
  export RAILS_ENV=${RAILS_ENV:=production}
5
5
 
6
+ if [[ "$OSTYPE" == *"darwin"* ]]; then
7
+ export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
8
+ fi
9
+
6
10
  docker-compose run \
7
11
  -e CLOUDFORMATION_BUCKET \
8
12
  cicd \
@@ -1,14 +1,24 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
+ export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
4
5
  export RAILS_ENV=${RAILS_ENV:="production"}
5
6
  export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
6
- export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
7
+ export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
7
8
 
8
9
  # https://github.com/aws/aws-sam-cli/issues/2447
9
10
  export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
10
- export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/myorg/APPNAMEHERE"
11
+ export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}"
11
12
 
13
+ echo '== Creating ECR repository =='
14
+ echo 'You can safely ignore any RepositoryAlreadyExistsException errors...'
15
+ aws ecr create-repository \
16
+ --repository-name "$DEPLOYMENT_NAME" \
17
+ --image-tag-mutability MUTABLE \
18
+ --image-scanning-configuration scanOnPush=true \
19
+ --region "$AWS_DEFAULT_REGION" || true
20
+
21
+ # Build our application code into a deployment folder
12
22
  ./bin/_build
13
23
 
14
24
  sam build \
@@ -22,13 +32,13 @@ sam package \
22
32
  --output-template-file ./.aws-sam/build/packaged.yaml \
23
33
  --image-repository "$IMAGE_REPOSITORY" \
24
34
  --s3-bucket "${CLOUDFORMATION_BUCKET}" \
25
- --s3-prefix "APPNAMEHERE-${RAILS_ENV}"
35
+ --s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
26
36
 
27
37
  echo "== SAM deploy..."
28
38
  sam deploy \
29
39
  --region "$AWS_DEFAULT_REGION" \
30
40
  --template-file ./.aws-sam/build/packaged.yaml \
31
- --stack-name "APPNAMEHERE-${RAILS_ENV}" \
41
+ --stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
32
42
  --image-repository "$IMAGE_REPOSITORY" \
33
43
  --capabilities "CAPABILITY_IAM" \
34
44
  --parameter-overrides \
@@ -3,6 +3,10 @@ set -e
3
3
 
4
4
  export RAILS_ENV=${RAILS_ENV:=production}
5
5
 
6
+ if [[ "$OSTYPE" == *"darwin"* ]]; then
7
+ export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
8
+ fi
9
+
6
10
  docker-compose run \
7
11
  -e CLOUDFORMATION_BUCKET \
8
12
  cicd \
@@ -1,14 +1,24 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
+ export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
4
5
  export RAILS_ENV=${RAILS_ENV:="production"}
5
6
  export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
6
- export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
7
+ export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
7
8
 
8
9
  # https://github.com/aws/aws-sam-cli/issues/2447
9
10
  export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
10
- export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/myorg/APPNAMEHERE"
11
+ export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}"
11
12
 
13
+ echo '== Creating ECR repository =='
14
+ echo 'You can safely ignore any RepositoryAlreadyExistsException errors...'
15
+ aws ecr create-repository \
16
+ --repository-name "$DEPLOYMENT_NAME" \
17
+ --image-tag-mutability MUTABLE \
18
+ --image-scanning-configuration scanOnPush=true \
19
+ --region "$AWS_DEFAULT_REGION" || true
20
+
21
+ # Build our application code into a deployment folder
12
22
  ./bin/_build
13
23
 
14
24
  sam build \
@@ -22,13 +32,13 @@ sam package \
22
32
  --output-template-file ./.aws-sam/build/packaged.yaml \
23
33
  --image-repository "$IMAGE_REPOSITORY" \
24
34
  --s3-bucket "${CLOUDFORMATION_BUCKET}" \
25
- --s3-prefix "APPNAMEHERE-${RAILS_ENV}"
35
+ --s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
26
36
 
27
37
  echo "== SAM deploy..."
28
38
  sam deploy \
29
39
  --region "$AWS_DEFAULT_REGION" \
30
40
  --template-file ./.aws-sam/build/packaged.yaml \
31
- --stack-name "APPNAMEHERE-${RAILS_ENV}" \
41
+ --stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
32
42
  --image-repository "$IMAGE_REPOSITORY" \
33
43
  --capabilities "CAPABILITY_IAM" \
34
44
  --parameter-overrides \
@@ -3,6 +3,10 @@ set -e
3
3
 
4
4
  export RAILS_ENV=${RAILS_ENV:=production}
5
5
 
6
+ if [[ "$OSTYPE" == *"darwin"* ]]; then
7
+ export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
8
+ fi
9
+
6
10
  docker-compose run \
7
11
  -e CLOUDFORMATION_BUCKET \
8
12
  cicd \
data/lib/lamby/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lamby
2
- VERSION = '2.5.3'
2
+ VERSION = '2.6.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lamby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.3
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-30 00:00:00.000000000 Z
11
+ date: 2021-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack