Skip to content

Commit

Permalink
TT-13269 - Refactor/streams (#6593)
Browse files Browse the repository at this point in the history
### **User description**
Extracts streaming middleware into internal/middleware/stream;
Implements a number of interfaces to cover gateway/base middleware
Implements `wrappedMiddleware` to allow middlewares with less coupling.

I tried to update couplings along as I went, it's passing `go build` and
`go test -c`.


___

### **PR Type**
enhancement, tests


___

### **Description**
- Refactored streaming middleware by introducing a new `Manager` for
handling streams and updated the `StreamingMiddleware` to use this new
structure.
- Replaced various `apidef` types with `model` types across multiple
files to improve modularity and reduce coupling.
- Introduced `WrapMiddleware` functionality to allow middleware wrapping
with less coupling.
- Updated test cases to align with the new streaming middleware
implementation and the use of the `model` package.
- Added new interfaces in the `model` package to define common behaviors
for Gateway and Middleware components.
- Updated method calls to use the new `ReplaceTykVariables` function for
consistency.


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>22
files</summary><table>
<tr>
  <td>
    <details>
<summary><strong>api_loader.go</strong><dd><code>Integrate new streaming
middleware and wrap functionality</code></dd></summary>
<hr>

gateway/api_loader.go

<li>Added import for <code>internal/middleware/stream</code>.<br> <li>
Replaced <code>StreamingMiddleware</code> with a new streaming
middleware <br>implementation.<br> <li> Introduced
<code>WrapMiddleware</code> for middleware wrapping.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+9/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>gateway.go</strong><dd><code>Update Gateway interface
implementation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

gateway/gateway.go

- Updated interface implementation to use `model.Gateway`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-17cb8b37eda9018fe1c6cdb5f96b3fc948fc8ba49bc516987b8269576db9fcd4">+2/-7</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>health_check.go</strong><dd><code>Use model package for
health check items</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

gateway/health_check.go

- Replaced `apidef.HealthCheckItem` with `model.HealthCheckItem`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-978a2d1427d9209765e541618af10683944c6396df1a6fb8b5221e4f16658a6a">+31/-30</a>&nbsp;
</td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>middleware.go</strong><dd><code>Update TykMiddleware
interface and constants</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/middleware.go

<li>Added <code>GetSpec</code> method to <code>TykMiddleware</code>
interface.<br> <li> Changed constant <code>mwStatusRespond</code> to use
<code>middleware.StatusRespond</code>.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-703054910891a4db633eca0f42ed779d6b4fa75cd9b3aa4c503e681364201c1b">+10/-12</a>&nbsp;
</td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>middleware_wrap.go</strong><dd><code>Introduce
middleware wrapping functionality</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

gateway/middleware_wrap.go

<li>Introduced <code>wrapMiddleware</code> struct for middleware
wrapping.<br> <li> Implemented <code>WrapMiddleware</code> function.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-1da43bd02220acad12bce8d8c5600b4acfee3c40f90c53825802747004c9fb0a">+51/-0</a>&nbsp;
&nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>mw_auth_key.go</strong><dd><code>Update variable
replacement method call</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_auth_key.go

- Updated method call to `ReplaceTykVariables`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-aeba053023a54c723dd9f83837e29ca0b2d9a212bc98fa6ad4bbb062669a1cf0">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>mw_graphql.go</strong><dd><code>Update variable
replacement method call</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_graphql.go

- Updated method call to `ReplaceTykVariables`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-c46e0f07348c8f519e5912f4394f048f43c1e3fb5063c27245272c8f645b4cab">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>mw_modify_headers.go</strong><dd><code>Update variable
replacement method call</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_modify_headers.go

- Updated method call to `ReplaceTykVariables`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-061b7bd9b76abe91c660494762ad868c6cc6135fdf1e97465377df39e1eeac8e">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>

<summary><strong>mw_persist_graphql_operation.go</strong><dd><code>Update
variable replacement method call</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_persist_graphql_operation.go

- Updated method call to `ReplaceTykVariables`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-ace7a721ebc7c7d61ce5a9f01b906cfe617aedf48364f08f40ccfde670685ca6">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>mw_rate_limiting.go</strong><dd><code>Update variable
replacement method call</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_rate_limiting.go

- Updated method call to `ReplaceTykVariables`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-4bf8ae01ccab67bb786468f793f6bb4324c8f6b950b0e98e203effebe763a630">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>mw_transform.go</strong><dd><code>Update variable
replacement method call</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_transform.go

- Updated method call to `ReplaceTykVariables`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-d7a3cdc3dcabd415dffee6c044ea27dbe877add0ddc42471e10943125693fc12">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>mw_url_rewrite.go</strong><dd><code>Rename and document
ReplaceTykVariables function</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_url_rewrite.go

<li>Renamed <code>replaceTykVariables</code> to
<code>ReplaceTykVariables</code> and added <br>documentation.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-84a6a5c810334aaa8702669f2aebf0284f116d83e8a55ec9d1d5b8bae87f1be6">+6/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>

<summary><strong>res_handler_header_injector.go</strong><dd><code>Update
variable replacement method call</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/res_handler_header_injector.go

- Updated method call to `ReplaceTykVariables`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-db30365a54a06d3fbf9f4aad3fe133de85dbb75fae2177d84ede3214407f31ca">+3/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>rpc_storage_handler.go</strong><dd><code>Use model
package for RPC storage handler types</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/rpc_storage_handler.go

<li>Replaced <code>apidef</code> types with <code>model</code> types for
RPC storage handling.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-8875f75b602664c44b62b67a4da41d748124ad270573a44db4ec977ee5d68021">+24/-25</a>&nbsp;
</td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>const.go</strong><dd><code>Add StatusRespond constant
for middleware</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

internal/middleware/const.go

- Added constant `StatusRespond` for middleware processing.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-8a6d0644eb989a86bc580dcdcee0ac94316c7883c7516d3e11e55c66a833965a">+5/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>stream_manager.go</strong><dd><code>Introduce Manager
for stream management</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

internal/middleware/stream/stream_manager.go

<li>Introduced <code>Manager</code> struct for stream management.<br>
<li> Implemented stream creation and removal functionalities.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-ed75e572397b02c39d91dcca90c9bfd84f527fa4b5522c0a08f7ee9e44585ef5">+133/-0</a>&nbsp;
</td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>streaming_middleware.go</strong><dd><code>Refactor
StreamingMiddleware with new Manager</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

internal/middleware/stream/streaming_middleware.go

<li>Refactored <code>StreamingMiddleware</code> to use new
<code>Manager</code>.<br> <li> Updated logging and stream management
logic.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-99c21a93ded6b6c0fcfba1af1b9a2189df150da067ecdb08cf33b1aced9242e3">+62/-133</a></td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>health_check.go</strong><dd><code>Rename package to
model</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

internal/model/health_check.go

- Renamed package from `apidef` to `model`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-44e3299d864d891747443f0c999d95e7d19410b67817fdfd1c5840c616fdcd64">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>interfaces.go</strong><dd><code>Add interfaces for
Gateway and Middleware</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

internal/model/interfaces.go

- Introduced interfaces for Gateway and Middleware.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-43ba6dd4a8d193850dea32e8af5c361470cd62bfa390c580a39f7142a56bd391">+66/-0</a>&nbsp;
&nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>rpc.go</strong><dd><code>Move RPC types to model
package</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

internal/model/rpc.go

- Moved RPC-related types to `model` package.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-a9cdd23914e87a8671ec07c0a83257f8bbd12dc8939c5014cf368b796bf8ade4">+2/-6</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>apply.go</strong><dd><code>Use model.PolicyProvider in
Service struct</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

internal/policy/apply.go

- Updated `Service` struct to use `model.PolicyProvider`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-59b92e9d31f142f1d99b746eb3ff7db4e26bf6c3044c9b87b58034a947ee04d1">+3/-10</a>&nbsp;
&nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>synchronization_forcer.go</strong><dd><code>Use model
package for GroupLoginRequest</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

rpc/synchronization_forcer.go

- Replaced `apidef.GroupLoginRequest` with `model.GroupLoginRequest`.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-97417011065a292f63eeb6fb031afbcfffa75cb3fc7073f8431add277b250c98">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>3
files</summary><table>
<tr>
  <td>
    <details>
<summary><strong>mw_streaming_test.go</strong><dd><code>Update streaming
test cases to use new package</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_streaming_test.go

<li>Updated test cases to use <code>stream</code> package for streaming
<br>functionalities.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-a0d1bd0196a741537a3c850e340225c8993e49d709c838af0f1b48b9893af1da">+8/-7</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>rpc_storage_handler_test.go</strong><dd><code>Update
RPC storage handler tests to use model package</code>&nbsp; &nbsp;
&nbsp; &nbsp; </dd></summary>
<hr>

gateway/rpc_storage_handler_test.go

- Updated tests to use `model` package for RPC storage handler.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-69de989a02b3bc32ae376c514ee84633c609200db22385c0e16c361d6ea74cd6">+20/-23</a>&nbsp;
</td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>rpc_test.go</strong><dd><code>Update RPC tests to use
model package</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/rpc_test.go

- Updated RPC test cases to use `model` package for API definitions.


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/6593/files#diff-68d6d05f22702a24741c6e233a2cb1f227dacf0309d7d94f651038ac7b90f49e">+5/-5</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></details></td></tr></tr></tbody></table>

___

> 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull
request to receive relevant information

---------

Co-authored-by: Tit Petric <[email protected]>
Co-authored-by: Leonid Bugaev <[email protected]>
  • Loading branch information
3 people authored Oct 19, 2024
1 parent cf5aeb0 commit aee8137
Show file tree
Hide file tree
Showing 38 changed files with 1,057 additions and 593 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/plugin-compiler-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- master
- release-**
tags:
- 'v*'
- "v*"

env:
GOLANG_CROSS: 1.22-bullseye
Expand Down Expand Up @@ -80,3 +80,35 @@ jobs:
BASE-IMAGE=tykio/golang-cross:${{ env.GOLANG_CROSS }}
GITHUB_SHA=${{ github.sha }}
GITHUB_TAG=${{ github.ref_name }}
- name: Set docker metadata EE
id: set-metadata-ee
uses: docker/metadata-action@v4
with:
images: |
tykio/tyk-plugin-compiler-ee,enable=${{ startsWith(github.ref, 'refs/tags') }}
${{ steps.login-ecr.outputs.registry }}/tyk-plugin-compiler-ee
labels: |
org.opencontainers.image.title=tyk-plugin-compiler-ee
org.opencontainers.image.description=Plugin compiler for the Tyk API Gateway Enterprise Edition
tags: |
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern={{raw}}
type=sha,format=long
- name: Build and push to dockerhub/ECR EE
uses: docker/build-push-action@v4
with:
context: .
file: ci/images/plugin-compiler/Dockerfile
platforms: linux/amd64
push: true
labels: ${{ steps.set-metadata-ee.outputs.labels }}
tags: ${{ steps.set-metadata-ee.outputs.tags }}
build-args: |
BASE-IMAGE=tykio/golang-cross:${{ env.GOLANG_CROSS }}
GITHUB_SHA=${{ github.sha }}
GITHUB_TAG=${{ github.ref_name }}
BUILD_TAG=ee
120 changes: 85 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
with:
mask-password: 'true'
- name: Docker metadata for CI
id: ci_metadata
id: ci_metadata_
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
uses: docker/metadata-action@v5
with:
Expand All @@ -157,10 +157,43 @@ jobs:
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.ci_metadata.outputs.tags }}
tags: ${{ steps.ci_metadata_.outputs.tags }}
labels: ${{ steps.tag_metadata.outputs.labels }}
build-args: |
EDITION=
- name: Docker metadata for CI ee
id: ci_metadata_ee
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
uses: docker/metadata-action@v5
with:
images: ${{ steps.ecr.outputs.registry }}/tyk-ee
flavor: |
latest=false
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,format=long
type=semver,pattern={{major}},prefix=v
type=semver,pattern={{major}}.{{minor}},prefix=v
type=semver,pattern={{version}},prefix=v
- name: push image to CI ee
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
uses: docker/build-push-action@v6
with:
context: "dist"
platforms: linux/amd64,linux/arm64
file: ci/Dockerfile.distroless
provenance: mode=max
sbom: true
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.ci_metadata_ee.outputs.tags }}
labels: ${{ steps.tag_metadata.outputs.labels }}
build-args: |
EDITION=-ee
- name: Docker metadata for tag push
id: tag_metadata
id: tag_metadata_
uses: docker/metadata-action@v5
with:
images: |
Expand All @@ -185,8 +218,39 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ startsWith(github.ref, 'refs/tags') }}
tags: ${{ steps.tag_metadata.outputs.tags }}
labels: ${{ steps.tag_metadata.outputs.labels }}
tags: ${{ steps.tag_metadata_.outputs.tags }}
labels: ${{ steps.tag_metadata_.outputs.labels }}
build-args: |
EDITION=
- name: Docker metadata for tag push ee
id: tag_metadata_ee
uses: docker/metadata-action@v5
with:
images: |
tykio/tyk-gateway-ee
flavor: |
latest=false
prefix=v
tags: |
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
labels: "org.opencontainers.image.title=tyk-gateway Enterprise Edition (distroless) \norg.opencontainers.image.description=Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols\norg.opencontainers.image.vendor=tyk.io\norg.opencontainers.image.version=${{ github.ref_name }}\n"
- name: push image to prod ee
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
uses: docker/build-push-action@v6
with:
context: "dist"
platforms: linux/amd64,linux/arm64
file: ci/Dockerfile.distroless
provenance: mode=max
sbom: true
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ startsWith(github.ref, 'refs/tags') }}
tags: ${{ steps.tag_metadata_ee.outputs.tags }}
labels: ${{ steps.tag_metadata_ee.outputs.labels }}
build-args: |
EDITION=-ee
- name: save deb
uses: actions/upload-artifact@v4
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
Expand Down Expand Up @@ -310,37 +374,9 @@ jobs:
repository: TykTechnologies/tyk-analytics
path: tyk-analytics
token: ${{ secrets.ORG_GH_TOKEN }}
fetch-depth: 0
fetch-depth: 1
ref: ${{ env.BASE_REF }}
sparse-checkout: tests/api
- name: Choosing test code branch
working-directory: tyk-analytics/tests/api
run: |
if [[ ${{ github.event_name }} == "release" ]]; then
echo "Checking out release tag..."
TAG_NAME=${{ github.event.release.tag_name }}
git checkout "$TAG_NAME"
fi
if [[ ${{ github.event_name }} == "pull_request" ]]; then
PR_BRANCH=${{ github.event.pull_request.head.ref }}
TARGET_BRANCH=${{ github.event.pull_request.base.ref }}
echo "Looking for PR_BRANCH:$PR_BRANCH or TARGET_BRANCH:$TARGET_BRANCH..."
if git rev-parse --verify "origin/$PR_BRANCH" >/dev/null 2>&1; then
echo "PR branch $PR_BRANCH exists. Checking out..."
git checkout "$PR_BRANCH"
elif git rev-parse --verify "origin/$TARGET_BRANCH" >/dev/null 2>&1; then
echo "Target branch $TARGET_BRANCH exists. Checking out..."
git checkout "$TARGET_BRANCH"
fi
fi
if [[ ${{ github.event_name }} == "push" ]]; then
PUSH_BRANCH=${{ github.ref_name }}
echo "Looking for PUSH_BRANCH:$PUSH_BRANCH..."
if git rev-parse --verify "origin/$PUSH_BRANCH" >/dev/null 2>&1; then
echo "Push branch $PUSH_BRANCH exists. Checking out..."
git checkout "$PUSH_BRANCH"
fi
fi
echo "Current commit: $(git rev-parse HEAD)"
- uses: actions/setup-python@v5
with:
cache: 'pip'
Expand Down Expand Up @@ -369,6 +405,20 @@ jobs:
USER_API_SECRET=${{ steps.env_up.outputs.USER_API_SECRET }}
EOF
env $(cat pytest.env | xargs) $pytest -m "${{ matrix.envfiles.apimarkers }}"
- name: Upload Playwright Test Report to S3
if: failure() && steps.test_execution.outcome != 'success' && steps.env_up.outcome == 'success'
run: npm run upload_report_to_s3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.UI_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.UI_AWS_SECRET_ACCESS_KEY }}
RUN_ID: 'tyk-analytics/${{ github.run_id }}'
working-directory: tyk-analytics/tests/ui
- name: Share S3 report link into summary
if: failure() && steps.test_execution.outcome != 'success' && steps.env_up.outcome == 'success'
run: |
echo "# :clipboard: S3 UI Test REPORT: ${{ matrix.envfiles.db }}-${{ matrix.envfiles.conf }}" >> $GITHUB_STEP_SUMMARY
echo "- Status: ${{ steps.test_execution.outcome == 'success' && ':white_check_mark:' || ':no_entry_sign:' }}" >> $GITHUB_STEP_SUMMARY
echo "- [Link to report](https://tyk-qa-reports.s3.eu-central-1.amazonaws.com/tyk-analytics/${{ github.run_id }}/index.html)" >> $GITHUB_STEP_SUMMARY
- name: Generate metadata and upload test reports
id: metadata_report
if: always() && (steps.test_execution.conclusion != 'skipped')
Expand Down
11 changes: 10 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
The code in the root directory and all subdirectories, except for the 'ee' folder,
is licensed under the Mozilla Public License Version 2.0 (the "MPL"), as detailed below.

The code in the 'ee' folder is subject to a separate commercial license.
See the [LICENSE-EE](ee/LICENSE-EE.md) file in the 'ee' folder for details on the Enterprise Edition license.

For the open source components:
-------------------------------

# Mozilla Public License Version 2.0

## 1. Definitions
Expand Down Expand Up @@ -181,4 +190,4 @@ You may add additional accurate notices of copyright ownership.

## Exhibit B - &ldquo;Incompatible With Secondary Licenses&rdquo; Notice

> This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
> This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Tyk runs natively on _Kubernetes_, if you prefer, thanks to the _[Tyk Kubernetes
<center>
<a href="https://tyk.io/docs/tyk-cloud"> <img src="https://raw.githubusercontent.com/TykTechnologies/tyk-docs/master/tyk-docs/assets/img/logos/tyk-logo-cloud.png" width="20%"></a>
</center>
</br>The Enterprise API Management platform SaaS: Management Control Plane, Dashboard GUI & Developer Portal.
</br>The Enterprise API Management platform SaaS: Management Control Plane, Dashboard GUI & Developer Portal.
</br><a href="https://tyk.io/docs/deployment-and-operations/tyk-cloud-platform/quick-start">Deploy Tyk Cloud </a>
</td>
</tr>
Expand Down Expand Up @@ -82,7 +82,7 @@ Your Tyk Gateway is now configured and ready to use. Confirm this by checking ag
```console
curl localhost:8080/hello
```
Output:
Output:
```json
{"status": "pass", "version": "v3.2.1", "description": "Tyk GW"}
```
Expand Down Expand Up @@ -166,11 +166,13 @@ All the documentation for Tyk Gateway and other OSS-related topics can be found
* [Newsletters ](https://pages.tyk.io/newsletter)- Subscribe to our GraphQL & API newsletters
* If you are using Tyk give us a star ⭐️

## Open Source License
## Licensing

Tyk is released under the MPL v2.0; please see [LICENSE.md](https://github.com/TykTechnologies/tyk/blob/master/LICENSE.md) for a full version of the license.
Tyk is dual-licensed:

![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FTykTechnologies%2Ftyk.svg?type=large)
1. Open Source License: The code in the root directory and all subdirectories except the 'ee' folder is released under the MPL v2.0. Please see [LICENSE](https://github.com/TykTechnologies/tyk/blob/master/LICENSE) for the full version of the open source license.

2. Commercial License: The code in the 'ee' folder is subject to a commercial license. For more information about obtaining a commercial license, please contact our sales team at [email protected].

## Compiling Tyk Gateway

Expand Down
3 changes: 2 additions & 1 deletion ci/Dockerfile.distroless
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

FROM debian:bookworm-slim as DEB

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

Stage names should be lowercase

StageNameCasing: Stage name 'DEB' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

Stage names should be lowercase

StageNameCasing: Stage name 'DEB' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

Stage names should be lowercase

StageNameCasing: Stage name 'DEB' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

Stage names should be lowercase

StageNameCasing: Stage name 'DEB' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

Stage names should be lowercase

StageNameCasing: Stage name 'DEB' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

Stage names should be lowercase

StageNameCasing: Stage name 'DEB' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

Stage names should be lowercase

StageNameCasing: Stage name 'DEB' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

Stage names should be lowercase

StageNameCasing: Stage name 'DEB' should be lowercase More info: https://docs.docker.com/go/dockerfile/rule/stage-name-casing/

Check warning on line 3 in ci/Dockerfile.distroless

View workflow job for this annotation

GitHub Actions / 1.22-bullseye

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
ARG TARGETARCH
ARG EDITION

ENV DEBIAN_FRONTEND=noninteractive

COPY *${TARGETARCH}.deb /
RUN rm -f /*fips*.deb && dpkg -i /tyk-gateway*${TARGETARCH}.deb && rm /*.deb
RUN rm -f /*fips*.deb && dpkg -i /tyk-gateway${EDITION}_*${TARGETARCH}.deb && rm /*.deb

FROM gcr.io/distroless/base-debian12:latest

Expand Down
Loading

0 comments on commit aee8137

Please sign in to comment.