Feature Request: Support External Lua Files for custom_plugins Definitions

Aperta
#2,213 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go, lua, yaml
Ambito
cli, devops

Direzione di ricerca

Inizia tracciando il modo in cui deck gateway apply e sync caricano custom_plugins quando è impostato --include-plugin-definitions. Usa come riferimento la gestione inline esistente di schema e handler, quindi verifica che schema_file e handler_file possano caricare schema.lua e handler.lua, preservando il comportamento inline attuale e il payload Kong risultante.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem Statement

Currently, decK supports custom plugin deployment through the custom_plugins section in the declarative configuration file.

Example:
_format_version: "3.0"
_transform: true

custom_plugins:
  - name: my-example-plugin
    schema: |
      return {
        name = "my-example-plugin",
        fields = {
          {
            config = {
              type = "record",
              fields = {
                { example_field = { type = "string", required = true } },
                { another_example_field = { type = "string", required = true } },
              },
            },
          },
        },
      }
    handler: |
      local MyPluginHandler = {
        PRIORITY = 1000,
        VERSION = "0.0.1",
      }

      function MyPluginHandler:access(config)
        -- plugin logic here
      end

      return MyPluginHandler

Deployment:

deck gateway apply --include-plugin-definitions kong.yaml

or

deck gateway sync --include-plugin-definitions kong.yaml

While this works well for distributing plugin definitions, it creates challenges during plugin development, testing, and debugging.

Current Challenges

The plugin source code is typically developed and maintained as standalone Lua files:

plugins/
├── my-example-plugin/
│   ├── handler.lua
│   └── schema.lua

A common workflow is:

  1. Develop and test handler.lua and schema.lua.
  2. Copy the contents into the decK YAML file.
  3. Run deck gateway apply.
  4. Make changes during debugging.
  5. Copy the updated code back into the YAML file.
  6. Re-apply with decK.

This results in:

  • Duplication of source code.
  • Additional manual steps during development.
  • Risk of YAML and Lua files becoming out of sync.
  • Reduced IDE support when the source of truth becomes embedded YAML content.
  • Larger and harder-to-maintain declarative configuration files.

Proposed Enhancement

Allow custom_plugins to reference external files for the schema and handler definitions.

Example:

custom_plugins:
  - name: my-example-plugin
    schema_file: ./plugins/my-example-plugin/schema.lua
    handler_file: ./plugins/my-example-plugin/handler.lua

During deck gateway apply --include-plugin-definitions, decK would:

  1. Read the referenced files.
  2. Load their contents internally.
  3. Upload the plugin definitions exactly as it does today.

The resulting payload sent to Kong would remain unchanged.

Benefits

  • Improved developer experience.
  • Faster plugin development and debugging iterations.
  • Eliminates duplication between Lua source files and YAML definitions.
  • Better integration with IDE features such as syntax highlighting, formatting, linting, and testing.
  • Easier version control and code reviews.
  • Keeps declarative configuration files concise and readable.
  • Aligns with common Infrastructure-as-Code practices where large artifacts are stored in dedicated files and referenced from configuration.

Use Case

Teams developing custom Kong plugins often maintain plugin source code in a repository and use decK to publish plugin definitions to Konnect or Kong Gateway.

Supporting external file references would enable a workflow where the Lua files remain the single source of truth, allowing developers to:

# Edit Lua files
vim handler.lua

# Apply changes directly
deck gateway apply --include-plugin-definitions kong.yaml

without requiring a manual copy-and-paste step into the YAML file.

Expected Outcome

decK should support reading plugin schema and handler code from external Lua files and automatically embedding their contents during the apply/sync operation, while maintaining full backward compatibility with the current inline YAML approach.

Lingua principale
Go
Stelle
507
Fork
142
Merge medio
1g 15h
PR unite (30g)
9

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Kong/deck

Tutte le issue di Kong/deck

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.