Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pep plugin #10

Merged
merged 42 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f18f534
add pep plugin
wistefan Jun 28, 2022
060376e
fix small parts
wistefan Jun 28, 2022
c963c17
update workflows
wistefan Jun 28, 2022
eeba43f
correct paht
wistefan Jun 28, 2022
703c734
cahnge paths
wistefan Jun 28, 2022
f55f4b1
tidy
wistefan Jun 28, 2022
ecd7f18
change it
wistefan Jun 28, 2022
8f86d55
more ficxes
wistefan Jun 28, 2022
af22a20
build and use tar
wistefan Jun 28, 2022
3e7e389
copy tar file
wistefan Jun 28, 2022
606e84f
ls
wistefan Jun 28, 2022
62509f6
change syntax
wistefan Jun 28, 2022
7643d12
backj
wistefan Jun 28, 2022
bc7708e
enable buildkit
wistefan Jun 28, 2022
9244675
kong image
wistefan Jun 28, 2022
06653eb
dont load
wistefan Jun 28, 2022
e6dd37a
test compile and make public
wistefan Jun 28, 2022
6d925c7
update pom
wistefan Jun 28, 2022
a45cd66
fix workflow
wistefan Jun 28, 2022
0b8c645
whats going on?
wistefan Jun 28, 2022
7ab7c15
add &
wistefan Jun 28, 2022
c22f077
again
wistefan Jun 28, 2022
17c3996
stream logs
wistefan Jun 28, 2022
5b6a88d
try to fix go build
wistefan Jun 28, 2022
8def0dc
change build
wistefan Jun 28, 2022
19a4a2f
cahnge build approach
wistefan Jun 28, 2022
62f4f79
where are my tests?
wistefan Jun 28, 2022
54498ba
correct packaging
wistefan Jun 28, 2022
37db21d
change the build again
wistefan Jun 28, 2022
4738a6a
add pre and release
wistefan Jun 28, 2022
5cc7c77
test rm
wistefan Jun 28, 2022
0eba7e1
add docs
wistefan Jun 28, 2022
4ccb426
Cleanup the yaml
wistefan Jun 29, 2022
561e1e0
add log
wistefan Jun 29, 2022
78309b4
move
wistefan Jun 29, 2022
ff3e7e7
remove log again
wistefan Jun 29, 2022
feb52b0
use temp llib
wistefan Jun 29, 2022
cec7cf5
fix syntax
wistefan Jun 29, 2022
3c729cb
install lua lib
wistefan Jun 29, 2022
e80801f
add unit tests
wistefan Jun 30, 2022
1fb0e7f
update spec
wistefan Jun 30, 2022
9f4b726
add kong keycloak plugin (#11)
Jul 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/it.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Integration tests

on:
push

env:
KONG_VERSION: 2.8.1

jobs:

prepare-and-run:

runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: '17'
java-package: jdk

- uses: actions/setup-go@v3
with:
go-version: '>=1.17.0'

- name: Build pep-plugin
run: |
cd ./kong-pep-plugin
docker run -v $(pwd):/temp/ --workdir="/temp" kong/go-plugin-tool:2.0.4-alpine-latest go build -ldflags "-X pep-plugin.Version=${{ needs.generate-version.outputs.version }}" -o pep-plugin .
cd ..
mkdir ./go-plugins/
cp ./kong-pep-plugin/pep-plugin ./go-plugins/pep-plugin


- name: Prepare values
run: |
echo GITHUB_ORGANISATION: fiware >> values.yaml
echo GITHUB_REPO: kong-plugins-fiware >> values.yaml
echo VERSION: 0.0.1 >> values.yaml


- name: Parse rockspec
run: |
go install github.com/cbroglie/mustache/cmd/mustache@v1.3.1
~/go/bin/mustache values.yaml kong-plugin-auth-endpoint-config-ishare/rockspec.mustache > kong-plugin-auth-endpoint-config-ishare/kong-plugin-auth-endpoint-config-ishare-0.0.1-1.rockspec
~/go/bin/mustache values.yaml kong-plugin-ngsi-ishare-policies/rockspec.mustache > kong-plugin-ngsi-ishare-policies/kong-plugin-ngsi-ishare-policies-0.0.1-1.rockspec

- uses: leafo/gh-actions-lua@v9
- uses: leafo/gh-actions-luarocks@v4

- name: Make rock
run: |
cd kong-plugin-auth-endpoint-config-ishare
luarocks make
luarocks pack kong-plugin-auth-endpoint-config-ishare 0.0.1-1
cd ..
cd kong-plugin-ngsi-ishare-policies
luarocks make
luarocks pack kong-plugin-ngsi-ishare-policies 0.0.1-1
cd ..
mkdir plugin-dir
cp -r kong-plugin-auth-endpoint-config-ishare/. plugin-dir/
cp -r kong-plugin-ngsi-ishare-policies/. plugin-dir/
cd plugin-dir/
luarocks install lua-fiware-lib
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be extracted somehow of the dependencies in the rock manifests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be extracted somehow of the dependencies in the rock manifests?

It is in the release build, but there is no published version during the IT tests, thus I have to create them in-line(same as with pre-release).

luarocks pack lua-fiware-lib
luarocks install lua-resty-jwt
luarocks pack lua-resty-jwt

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Get dockerfiles
run: |
wget https://raw.githubusercontent.com/Kong/docker-kong/master/customize/Dockerfile
wget https://raw.githubusercontent.com/Kong/docker-kong/master/customize/empty_file
wget https://raw.githubusercontent.com/Kong/docker-kong/master/customize/packer.lua

- name: Add plugins
run: |
echo "USER root" >> Dockerfile
echo "COPY ./go-plugins /kong/go-plugins" >> Dockerfile
echo "RUN chmod -R 777 /kong/go-plugins/" >> Dockerfile
echo "USER kong" >> Dockerfile

- name: Build image
run: |
docker build --build-arg KONG_BASE="kong:${{ env.KONG_VERSION }}-alpine" --build-arg PLUGINS="lua-fiware-lib,kong-plugin-auth-endpoint-config-ishare,kong-plugin-ngsi-ishare-policies" --build-arg ROCKS_DIR="./plugin-dir" . -t fiware/kong:0.0.1

- name: Execute test
run: |
cd it/
mvn integration-test
52 changes: 46 additions & 6 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,49 @@ jobs:
echo "::set-output name=version::$(echo ${VERSION}-PRE-${{ steps.pr_number.outputs.nr }})"
echo "::set-output name=plain-version::$(echo ${VERSION})"

git-release:
build-pep-plugin:
needs: ["generate-version"]
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2

- name: Build pep-plugin
run: |
cd ./kong-pep-plugin
docker run -v $(pwd):/temp/ --workdir="/temp" kong/go-plugin-tool:2.0.4-alpine-latest go build -ldflags "-X pep-plugin.Version=${{ needs.generate-version.outputs.version }}" -o pep-plugin .

- uses: actions/upload-artifact@v2
with:
name: pep-plugin
path: ./kong-pep-plugin/pep-plugin


git-release:
needs: ["generate-version", "build-pep-plugin"]
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2

- uses: actions/download-artifact@v2
with:
name: pep-plugin
path: ./go-plugins/


- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ needs.generate-version.outputs.version }}
prerelease: true
title: ${{ needs.generate-version.outputs.version }}

files: |
./go-plugins/pep-plugin


pre-release-kong:
needs: ["git-release", "generate-version"]
runs-on: ubuntu-latest
Expand All @@ -69,6 +97,12 @@ jobs:
with:
go-version: '>=1.17.0'

- uses: actions/download-artifact@v2
with:
name: pep-plugin
path: ./go-plugins/


- name: Prepare values
run: |
echo GITHUB_ORGANISATION: fiware >> values.yaml
Expand Down Expand Up @@ -100,7 +134,7 @@ jobs:
cp -r kong-plugin-ngsi-ishare-policies/. plugin-dir/
cd plugin-dir/
luarocks install lua-fiware-lib
luarocks pack lua-fiware-lib
luarocks pack lua-fiware-lib
luarocks install lua-resty-jwt
luarocks pack lua-resty-jwt

Expand All @@ -119,9 +153,15 @@ jobs:
wget https://raw.githubusercontent.com/Kong/docker-kong/master/customize/empty_file
wget https://raw.githubusercontent.com/Kong/docker-kong/master/customize/packer.lua

- name: Insert go plugins
run: |
echo "USER root" >> Dockerfile
echo "COPY ./go-plugins /kong/go-plugins" >> Dockerfile
echo "RUN chmod -R 777 /kong/go-plugins/" >> Dockerfile
echo "USER kong" >> Dockerfile

- name: Build and push
run: |
docker build --build-arg KONG_BASE="kong:2.8.1-alpine" --build-arg PLUGINS="lua-fiware-lib,kong-plugin-auth-endpoint-config-ishare,kong-plugin-ngsi-ishare-policies" --build-arg ROCKS_DIR="./plugin-dir" --tag quay.io/fiware/kong:${{ needs.generate-version.outputs.version }} .

docker push quay.io/fiware/kong:${{ needs.generate-version.outputs.version }}


docker push quay.io/fiware/kong:${{ needs.generate-version.outputs.version }}
27 changes: 26 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,47 @@ jobs:
- name: Set version output
id: out
run: echo "::set-output name=version::$(echo ${VERSION})"

build-pep-plugin:
needs: ["generate-version"]
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2

- name: Build pep-plugin
run: |
cd ./kong-pep-plugin
docker run -v $(pwd):/temp/ --workdir="/temp" kong/go-plugin-tool:2.0.4-alpine-latest go build -ldflags "-X pep-plugin.Version=${{ needs.generate-version.outputs.version }}" -o pep-plugin .

- uses: actions/upload-artifact@v2
with:
name: pep-plugin
path: ./kong-pep-plugin/pep-plugin

git-release:
needs: ["generate-version"]
needs: ["generate-version", "build-pep-plugin"]
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2


- uses: actions/download-artifact@v2
with:
name: pep-plugin
path: ./go-plugins/

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ needs.generate-version.outputs.version }}
title: ${{ needs.generate-version.outputs.version }}
prerelease: false
files: |
./go-plugins/pep-plugin

auth-endpoint-config-ishare:

Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ jobs:
with:
name: test-image
path: /tmp/test-image.tar



ngsi-ishare-policies:

Expand Down Expand Up @@ -124,3 +122,19 @@ jobs:

- name: Run tests
run: ./pongo/pongo-docker.sh run

pep-plugin:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.3

- name: Go test
run: |
cd kong-pep-plugin/
go test -v -covermode=count -coverprofile=coverage.out
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,12 @@ KONG_VERSION=2.8.1
# Run pongo
PONGO_PLUGIN_SOURCE=./kong-plugin-ngsi-ishare-policies ./pongo/pongo-docker.sh run
```

## Integration tests

Some plugins connect kong to external components. In order to assure them working in real environments, an integration-test framework based on [k3s](https://k3s.io/) is provided. The tests are executed using the [k3s-maven-plugin](https://github.com/kokuwaio/k3s-maven-plugin).
The tests itself are written using [Junit5](https://junit.org/junit5/docs/current/user-guide/).

### Usage

The tests use the local docker-image "fiware/kong:0.0.1". If a different one should be used, either provide it with that tag or change it inside the [kong.yaml](./it/src/test/k3s/kong.yaml). The tests can be executed via ```mvn integration-test```. For local development, a k3s-setup can be started with ```mvn k3s:create k3s:start k3s:image k3s:kubectl```. Tear down afterwards is executed via ```mvn k3s:rm```.
Loading