Python plugin - configuration schema

Hi,

I’m struggling with configuration schema in custom python plugin. Maybe you know, what i am doing wrong. All suggestions are welcome.

Please find below the details:

Plugin configuration:

#!/usr/bin/python3
import kong_pdk.pdk.kong as kong

Schema = (
    {"message": {"type": "string"}}
)

class Plugin(object):

    def __init__(self, config):
        self.config = config

    def access(self, kong: kong):
        message = "defaultMsg"
        if 'message' in self.config:
            message = self.config['message']

        kong.log.err("Message:", str(message))


if __name__ == "__main__":
    from kong_pdk.cli import start_dedicated_server
    start_dedicated_server("py-hello", Plugin, version, priority)

Kong configuration:

apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
  name: py-hello
  annotations:
    kubernetes.io/ingress.class: kong
  labels:
    global: "true"
  config:
    message: "test"
plugin: py-hello

Unfortunately, it doesn’t work. I can’t set message value in the declarative configuration file.

Thank you in advance,
Mateusz


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ