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

json-schema support #77

Merged
merged 14 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 53 additions & 0 deletions .github/workflows/generate-json-schemas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Generate json schemas
on:
workflow_dispatch:
inputs:
kong-image-tag:
required: true
type: string
description: |
Kong Docker image tag to run, 3.6.1.4.
version:
required: true
type: string
description: |
Kong Gateway release, e.x. 3.4.x.
Used by some commands for storing files in the corresponding folder.
kong-image-name:
type: choice
description: |
Kong Docker image name to use, e.g. kong-gateway, kong-gateway-dev.
options:
- kong-gateway
- kong-gateway-dev

jobs:
generate-json-schemas:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/reusable-steps/install-deps
- name: Run Kong EE
uses: ./.github/reusable-steps/run-kong-ee
with:
op-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
kong-image-tag: ${{ github.event.inputs.kong-image-tag }}
kong-image-name: ${{ github.event.inputs.kong-image-name }}
- name: Run convert_json_schema
run: |
bundle exec ./plugins convert_json_schema --version=${{ github.event.inputs.version }} --plugins $(ls ./schemas) --verbose
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.PAT }}
title: "Generate JSON Schemas for ${{ github.event.inputs.version }}"
branch: generate-json-schemas
commit-message: "JSON Schemas for ${{ github.event.inputs.version }}"
delete-branch: true
add-paths: |
./json_schemas/*
- name: Cleanup
if: always()
uses: ./.github/reusable-steps/cleanup
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source 'https://rubygems.org'

gem 'thor'
gem 'deepsort'
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
GEM
remote: https://rubygems.org/
specs:
deepsort (0.5.0)
thor (1.3.2)

PLATFORMS
arm64-darwin-23
ruby

DEPENDENCIES
deepsort
thor

BUNDLED WITH
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,22 @@ Example:
./plugins copy_data_files --version 3.5.x
```

### Generate JSON Schemas

Converts schemas into JSON schemas.

| Options | Descriptions |
|--------------------------- |-----|
| `version` | **Required**. Kong Gateway release version, e.g. `3.3.x`. The new example file is named after it. |
| `plugins` | **Required**. Space separated list of plugins to use, .e.g. `acme acl`. |
| `source` | Path to the root folder containing the exisiting schemas. Default: `./schemas`. |

For example, running:
```bash
./plugins convert_json_schema --version 3.9.x --plugins acme
```
converts `./schemas/acme/3.9.x.json` into a valid JSON schema and writes it to `./json_schemas/acme/3.9.json`.

## Updating the repo after a new release

Whenever a new version of Kong Gateway is released, we need run the following commands in order. For all of them, specify all the plugins `--plugins $(ls ./schemas)`
Expand All @@ -152,3 +168,5 @@ Whenever a new version of Kong Gateway is released, we need run the following co
1. Validate Examples - specify the new version `x.x.x`
1. Generate Referenceable Fields List - specify the new version `x.x.x`
1. Generate Priorities List - for `oss` and `ee` and specify the new version `x.x.x`
1. Copy Data files
1. Generate JSON Schemas
1 change: 1 addition & 0 deletions config/descriptions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
protocols: "A list of the request protocols that will trigger this plugin. The default value, as well as the possible values allowed on this field, may change depending on the plugin type. For example, plugins that only work in stream mode will only support tcp and tls."
28 changes: 28 additions & 0 deletions config/foreign_keys.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
consumer:
additionalProperties: false
description: 'If set, the plugin will activate only for requests where the specified has been authenticated. (Note that some plugins can not be restricted to consumers this way.). Leave unset for the plugin to activate regardless of the authenticated Consumer.'
properties:
id:
type: string
type: object
consumer_group:
additionalProperties: false
description: If set, the plugin will activate only for requests where the specified consumer group has been authenticated. (Note that some plugins can not be restricted to consumers groups this way.). Leave unset for the plugin to activate regardless of the authenticated Consumer Groups
properties:
id:
type: string
type: object
route:
additionalProperties: false
description: 'If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the route being used.'
properties:
id:
type: string
type: object
service:
additionalProperties: false
description: 'If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched.'
properties:
id:
type: string
type: object
78 changes: 78 additions & 0 deletions json_schemas/acl/3.7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"properties": {
"config": {
"properties": {
"allow": {
"description": "Arbitrary group names that are allowed to consume the service or route. One of `config.allow` or `config.deny` must be specified.",
"items": {
"required": [],
"type": "string"
},
"type": "array"
},
"deny": {
"description": "Arbitrary group names that are not allowed to consume the service or route. One of `config.allow` or `config.deny` must be specified.",
"items": {
"required": [],
"type": "string"
},
"type": "array"
},
"hide_groups_header": {
"default": false,
"description": "If enabled (`true`), prevents the `X-Consumer-Groups` header from being sent in the request to the upstream service.",
"type": "boolean"
},
"include_consumer_groups": {
"default": false,
"type": "boolean"
}
},
"required": [],
"type": "object"
},
"protocols": {
"default": [
"grpc",
"grpcs",
"http",
"https"
],
"description": "A set of strings representing HTTP protocols.",
"items": {
"enum": [
"grpc",
"grpcs",
"http",
"https"
],
"required": [],
"type": "string"
},
"type": "array"
},
"route": {
"additionalProperties": false,
"description": "If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the route being used.",
"properties": {
"id": {
"type": "string"
}
},
"required": [],
"type": "object"
},
"service": {
"additionalProperties": false,
"description": "If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched.",
"properties": {
"id": {
"type": "string"
}
},
"required": [],
"type": "object"
}
},
"required": []
}
83 changes: 83 additions & 0 deletions json_schemas/acl/3.8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"properties": {
"config": {
"properties": {
"allow": {
"description": "Arbitrary group names that are allowed to consume the service or route. One of `config.allow` or `config.deny` must be specified.",
"items": {
"required": [],
"type": "string"
},
"type": "array"
},
"always_use_authenticated_groups": {
"default": false,
"description": "If enabled (`true`), the authenticated groups will always be used even when an authenticated consumer already exists. If the authenticated groups don't exist, it will fallback to use the groups associated with the consumer. By default the authenticated groups will only be used when there is no consumer or the consumer is anonymous.",
"type": "boolean"
},
"deny": {
"description": "Arbitrary group names that are not allowed to consume the service or route. One of `config.allow` or `config.deny` must be specified.",
"items": {
"required": [],
"type": "string"
},
"type": "array"
},
"hide_groups_header": {
"default": false,
"description": "If enabled (`true`), prevents the `X-Consumer-Groups` header from being sent in the request to the upstream service.",
"type": "boolean"
},
"include_consumer_groups": {
"default": false,
"type": "boolean"
}
},
"required": [],
"type": "object"
},
"protocols": {
"default": [
"grpc",
"grpcs",
"http",
"https"
],
"description": "A set of strings representing HTTP protocols.",
"items": {
"enum": [
"grpc",
"grpcs",
"http",
"https"
],
"required": [],
"type": "string"
},
"type": "array"
},
"route": {
"additionalProperties": false,
"description": "If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the route being used.",
"properties": {
"id": {
"type": "string"
}
},
"required": [],
"type": "object"
},
"service": {
"additionalProperties": false,
"description": "If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched.",
"properties": {
"id": {
"type": "string"
}
},
"required": [],
"type": "object"
}
},
"required": []
}
84 changes: 84 additions & 0 deletions json_schemas/acl/3.9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"properties": {
"config": {
"properties": {
"allow": {
"description": "Arbitrary group names that are allowed to consume the service or route. One of `config.allow` or `config.deny` must be specified.",
"items": {
"required": [],
"type": "string"
},
"type": "array"
},
"always_use_authenticated_groups": {
"default": false,
"description": "If enabled (`true`), the authenticated groups will always be used even when an authenticated consumer already exists. If the authenticated groups don't exist, it will fallback to use the groups associated with the consumer. By default the authenticated groups will only be used when there is no consumer or the consumer is anonymous.",
"type": "boolean"
},
"deny": {
"description": "Arbitrary group names that are not allowed to consume the service or route. One of `config.allow` or `config.deny` must be specified.",
"items": {
"required": [],
"type": "string"
},
"type": "array"
},
"hide_groups_header": {
"default": false,
"description": "If enabled (`true`), prevents the `X-Consumer-Groups` header from being sent in the request to the upstream service.",
"type": "boolean"
},
"include_consumer_groups": {
"default": false,
"description": "If enabled (`true`), allows the consumer-groups to be used in the `allow|deny` fields",
"type": "boolean"
}
},
"required": [],
"type": "object"
},
"protocols": {
"default": [
"grpc",
"grpcs",
"http",
"https"
],
"description": "A set of strings representing HTTP protocols.",
"items": {
"enum": [
"grpc",
"grpcs",
"http",
"https"
],
"required": [],
"type": "string"
},
"type": "array"
},
"route": {
"additionalProperties": false,
"description": "If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the route being used.",
"properties": {
"id": {
"type": "string"
}
},
"required": [],
"type": "object"
},
"service": {
"additionalProperties": false,
"description": "If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched.",
"properties": {
"id": {
"type": "string"
}
},
"required": [],
"type": "object"
}
},
"required": []
}
Loading