Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Kong/lua-resty-aws
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: api7/lua-resty-aws
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 8 commits
  • 15 files changed
  • 3 contributors

Commits on Aug 9, 2024

  1. Copy the full SHA
    1138d1c View commit details
  2. Copy the full SHA
    80c423b View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    82f6f62 View commit details
  4. feat: release v2.0.0 (#4)

    bzp2010 committed Aug 9, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c34387f View commit details

Commits on Aug 10, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a7ccc3b View commit details
  2. feat: release v2.0.1 (#6)

    bzp2010 authored Aug 10, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2137beb View commit details

Commits on Aug 30, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6522b67 View commit details
  2. Copy the full SHA
    5afbf4a View commit details
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release

on:
push:
branches: [main]

jobs:
release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.event.head_commit.message, 'feat: release v')"
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Lua
uses: leafo/gh-actions-lua@v8

- name: Install Luarocks
uses: leafo/gh-actions-luarocks@v4

- name: Extract release name
id: release_env
shell: bash
env:
MESSAGE: ${{ github.event.head_commit.message }}
run: |
title="${MESSAGE}"
re="^feat: release v*(\S+)"
if [[ $title =~ $re ]]; then
v=v${BASH_REMATCH[1]}
echo "##[set-output name=version;]${v}"
echo "##[set-output name=version_withou_v;]${BASH_REMATCH[1]}"
else
echo "commit format is not correct"
exit 1
fi
- name: Check dot version
shell: bash
run: |
if [ "${{ steps.release_env.outputs.version_withou_v }}" != "$(cat .version)" ]; then
echo "VERSION '${{ steps.release_env.outputs.version_withou_v }}' does not match the dot version file '$(cat .version)'"
exit 1
fi
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.release_env.outputs.version_withou_v }}
release_name: ${{ steps.release_env.outputs.version }}
draft: false
prerelease: false

- name: Upload to luarocks
env:
VERSION: ${{ steps.release_env.outputs.version_withou_v }}
APIKEY: ${{ secrets.LUAROCKS_TOKEN }}
run: make upload
24 changes: 7 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Test

on: [push, pull_request]

env:
LIBEXPAT_DOWNLOAD_URL: https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.gz
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:

@@ -16,6 +17,8 @@ jobs:
openresty_version:
- 1.17.8.2
- 1.19.9.1
- 1.21.4.3
- 1.25.3.2

runs-on: ubuntu-latest
container:
@@ -30,18 +33,6 @@ jobs:
apk add --no-cache curl perl bash wget git perl-dev libarchive-tools nodejs jq
ln -s /usr/bin/bsdtar /usr/bin/tar
- name: Build libexpat
if: matrix.openresty_version == '1.17.8.2'
run: |
mkdir -p /tmp/expat
curl -Ls $LIBEXPAT_DOWNLOAD_URL | tar -xz --strip-components=1 -f - -C /tmp/expat
cd /tmp/expat && ./configure && make && make install
- name: Install libexpat from package manager
if: matrix.openresty_version == '1.19.9.1'
run: |
apk add --no-cache expat-dev
- name: Cache
uses: actions/cache@v2
with:
@@ -52,7 +43,6 @@ jobs:
- name: Install Busted
run: |
/usr/local/openresty/luajit/bin/luarocks install busted
/usr/local/openresty/luajit/bin/luarocks install luatz
/usr/local/openresty/luajit/bin/luarocks install luasocket
- uses: actions/checkout@v2
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.2
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -34,15 +34,16 @@ $(target_rock):
[ -n "$$VERSION" ] || { echo VERSION not set; exit 1; }
-@rm -rf /tmp/random_dir_2cs4f0tghRT
mkdir /tmp/random_dir_2cs4f0tghRT
cd /tmp/random_dir_2cs4f0tghRT; git clone https://github.com/kong/lua-resty-aws.git
cd /tmp/random_dir_2cs4f0tghRT; git clone https://github.com/api7/lua-resty-aws.git
cd /tmp/random_dir_2cs4f0tghRT/lua-resty-aws; if [ ! "${VERSION}" = "dev" ]; then git checkout ${VERSION}; fi
cd /tmp/random_dir_2cs4f0tghRT/lua-resty-aws; make dev
cd /tmp/random_dir_2cs4f0tghRT; zip -r lua-resty-aws-${VERSION}-1.src.rock lua-resty-aws
cd /tmp/random_dir_2cs4f0tghRT; cat lua-resty-aws/lua-resty-aws-dev-1.rockspec | sed "s/package_version = \"dev\"/package_version = \"${VERSION}\"/" > lua-resty-aws-${VERSION}-1.rockspec
cd /tmp/random_dir_2cs4f0tghRT; zip -r lua-resty-aws-${VERSION}-1.src.rock lua-resty-aws-${VERSION}-1.rockspec
mv /tmp/random_dir_2cs4f0tghRT/lua-resty-aws-${VERSION}-1.src.rock ./
-@rm lua-resty-aws-${VERSION}-1.rockspec
mv /tmp/random_dir_2cs4f0tghRT/lua-resty-aws-${VERSION}-1.rockspec ./
cd /tmp/random_dir_2cs4f0tghRT; cat lua-resty-aws/api7-lua-resty-aws-dev-1.rockspec | sed "s/package_version = \"dev\"/package_version = \"${VERSION}\"/" > api7-lua-resty-aws-${VERSION}-1.rockspec
cd /tmp/random_dir_2cs4f0tghRT; zip -r lua-resty-aws-${VERSION}-1.src.rock api7-lua-resty-aws-${VERSION}-1.rockspec
mv /tmp/random_dir_2cs4f0tghRT/lua-resty-aws-${VERSION}-1.src.rock ./api7-lua-resty-aws-${VERSION}-1.src.rock
-@rm api7-lua-resty-aws-${VERSION}-1.rockspec
mv /tmp/random_dir_2cs4f0tghRT/api7-lua-resty-aws-${VERSION}-1.rockspec ./api7-lua-resty-aws-${VERSION}-1.rockspec


pack: $(target_rock)

47 changes: 37 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -84,26 +84,19 @@ different from `false` (which is the default).

Installation is easiest using LuaRocks:

luarocks install lua-resty-aws
luarocks install api7-lua-resty-aws

To install from the git repo:

git clone https://github.com/Kong/lua-resty-aws.git
git clone https://github.com/api7/lua-resty-aws.git
cd lua-resty-aws
make install

### Troubleshooting

MacOS has a known issue that the libexpat header file 'expat_config.h' is missing. If you run into that issue, install libexpat manually (eg. `brew install expat`). And then include the libexpat location when installing;
luarocks install lua-resty-aws EXPAT_DIR=/path/to/expat

Details: https://github.com/lunarmodules/luaexpat/issues/32

---

## Development

To update the SDK version being used edit the version tag in [`update_api_files.sh`](https://github.com/Kong/lua-resty-aws/blob/main/update_api_files.sh)
To update the SDK version being used edit the version tag in [`update_api_files.sh`](https://github.com/api7/lua-resty-aws/blob/main/update_api_files.sh)
and then run:

make dev
@@ -156,8 +149,42 @@ Author: Thijs Schreijer

License: [Apache 2.0](https://github.com/Kong/lua-resty-aws/blob/main/LICENSE)

## Copyright and license (Modified parts)

Copyright: (c) 2024 API7.ai.

Author: Zeping Bai [@bzp2010](https://github.com/bzp2010)

License: [Apache 2.0](https://github.com/api7/lua-resty-aws/blob/main/LICENSE)

---

## API7 Fork History

Versioning is strictly based on [Semantic Versioning](https://semver.org/), version from 2.0.0.

We may refactor parts of the codebase or add new features, and some of the upstream changes will be synchronized to the fork.

We set up an automated release workflow:

1. Modify the .version file
1. Modify changelog
1. Submit a PR with the name `feat: release vX.Y.Z`
1. Merge PR with the commit name `feat: release vX.Y.Z`

### 2.0.1 (10-Aug-2024)

- fix: add luatz as dependency
[5](https://github.com/api7/lua-resty-aws/pull/5)

### 2.0.0 (09-Aug-2024)

- feat: remove XML dependency to simplify installation
[1](https://github.com/api7/lua-resty-aws/pull/1)

- ci: add an automated release workflow
[2](https://github.com/api7/lua-resty-aws/pull/2)

## History

Versioning is strictly based on [Semantic Versioning](https://semver.org/)
12 changes: 6 additions & 6 deletions lua-resty-aws-dev-1.rockspec.template
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
local package_name = "lua-resty-aws"
local package_name = "api7-lua-resty-aws"
local package_version = "dev"
local rockspec_revision = "1"
local github_account_name = "Kong"
local github_repo_name = package_name
local github_account_name = "api7"
local github_repo_name = "lua-resty-aws"
local git_checkout = package_version == "dev" and "main" or package_version

package = package_name
version = package_version .. "-" .. rockspec_revision

source = {
url = "git://github.com/"..github_account_name.."/"..github_repo_name..".git",
branch = git_checkout
tag = git_checkout
}

description = {
@@ -19,15 +19,15 @@ description = {
AWS SDK generated from the same data as the AWS JavaScript SDK.
]],
license = "Apache 2.0",
homepage = "https://"..github_account_name..".github.io/"..github_repo_name.."/topics/README.md.html"
homepage = "https://github.com/"..github_account_name.."/"..github_repo_name
}

dependencies = {
"penlight ~> 1",
"lua-resty-http >= 0.16",
"lua-resty-luasocket ~> 1",
"lua-resty-openssl >= 0.8.17",
"luaexpat >= 1.5.1",
"luatz = 0.4-1",
}

build = {
88 changes: 4 additions & 84 deletions spec/02-requests/02-build_request_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local cjson = require "cjson"
local pl_stringx = require "pl.stringx"

describe("operations protocol", function()

@@ -37,10 +36,6 @@ describe("operations protocol", function()
},
input = {
type = "structure",
locationName = "mainXmlElement", -- only for rest-xml protocol
xmlNamespace = { -- only for rest-xml protocol
uri = "cool-name-space"
},
required = {
"RoleArn",
"RoleSessionName"
@@ -206,6 +201,7 @@ describe("operations protocol", function()
local request = build_request(operation, config, params)
assert.same({
headers = {
["Accept"] = 'application/json',
["X-Sooper-Secret"] = "towel",
["X-Amz-Target"] = "sts.AssumeRole",
["Host"] = "sts.amazonaws.com",
@@ -239,6 +235,7 @@ describe("operations protocol", function()

assert.same({
headers = {
["Accept"] = 'application/json',
["X-Sooper-Secret"] = "towel",
["Content-Length"] = 172,
["Content-Type"] = "application/x-amz-json-1.0",
@@ -279,6 +276,7 @@ describe("operations protocol", function()

assert.same({
headers = {
["Accept"] = 'application/json',
["X-Sooper-Secret"] = "towel",
["Content-Length"] = 172,
["Content-Type"] = "application/x-amz-json-1.0",
@@ -314,6 +312,7 @@ describe("operations protocol", function()

assert.same({
headers = {
["Accept"] = 'application/json',
["Content-Length"] = 4,
["X-Amz-Target"] = "s3.PutObject",
["Host"] = "s3.amazonaws.com",
@@ -328,85 +327,6 @@ describe("operations protocol", function()
end)


it("rest-xml: querystring, uri, header and body params", function()

config.protocol = "rest-xml"

local request = build_request(operation, config, params)
if request and request.body then
-- cannot reliably compare non-canonicalized json, so decode to Lua table
local body_lines = pl_stringx.splitlines(request.body)
for i, line in ipairs(body_lines) do
body_lines[i] = pl_stringx.strip(line, ' ')
end
request.body = assert(require("pl.xml").parse(table.concat(body_lines, "")))
local to_lua = function(t)
-- convert LOM to comparable Lua table
for i, v in ipairs(t) do
if type(v) == "table" and v.tag then
t[v.tag] = v
v.tag = nil
t[i] = nil
if type(v.attr) == "table" and not next(v.attr) then
-- delete empty attr table
v.attr = nil
end
end
end
end
to_lua(request.body)
to_lua(request.body.someSubStructure)
end

assert.same({
headers = {
["X-Sooper-Secret"] = "towel",
["Content-Length"] = 456,
["Content-Type"] = "application/xml",
["X-Amz-Target"] = "sts.AssumeRole",
["Host"] = "sts.amazonaws.com",
},
method = 'POST',
path = '/hello%20world/42',
host = 'sts.amazonaws.com',
port = 443,
body = {
RoleArn = {
[1] = 'hello' },
RoleSessionName = {
[1] = 'world' },
BinaryData = {
[1] = binary_data },
attr = {
[1] = 'xmlns',
xmlns = 'cool-name-space' },
someSubStructure = {
hello = {
[1] = 'the default hello thinghy' },
world = {
[1] = 'the default world thinghy' } },
subList = {
[1] = {
[1] = '1',
attr = {},
tag = 'listELement' },
[2] = {
[1] = '2',
attr = {},
tag = 'listELement' },
[3] = {
[1] = '3',
attr = {},
tag = 'listELement' } },
tag = 'mainXmlElement' },
query = {
UserId = "Arthur Dent",
nice = '',
}
}, request)
end)


pending("ec2: querystring, uri, header and body params", function()

config.protocol = "ec2"
Loading