Map in schema for go plugin

Hi guys, I am at the moment trying to write a custom plugin in go. My config scheme should contain a map, but I can’t get it working.

My config object in my go plugin looks like that:

type Config struct {
    MyMap map[string]string
}

but whenever I try to start Kong I get:

Error: /usr/local/share/lua/5.1/kong/cmd/start.lua:64: nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:425: error loading plugin schemas: on plugin 'my-plugin': [off] schema violation
(fields.1: {
  fields = {
    {
      keys = {
        type = "expected a string"
      },
      values = {
        type = "expected a string"
      }
    }
  }
})

What am I doing wrong?

I am also facing the same issue with slices. Trying to use custom go plugin with kong ingress controller

type Config struct {
	ProtectedUrls []string `json:protectedUrls`
	. . .
}

I get following error

[error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:427: error loading plugin schemas: on plugin 'my-go-plugin': [off] schema violation (fields.1: {
  fields = {
    {
      elements = {
        type = "expected a string"
      }
    }
  }
})
stack traceback:
	[C]: in function 'assert'
	/usr/local/share/lua/5.1/kong/init.lua:427: in function 'init'
	init_by_lua:3: in main chunk
nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:427: error loading plugin schemas: on plugin 'my-go-plugin': [off] schema violation (fields.1: {
  fields = {
    {
      elements = {
        type = "expected a string"
      }
    }
  }
})
stack traceback:
	[C]: in function 'assert'
	/usr/local/share/lua/5.1/kong/init.lua:427: in function 'init'
	init_by_lua:3: in main chunk

I think solutions to both of our problems are at the moment proposed in github as pull requests: #19 for maps and #20 for slices.

I used this to build the go-pluginserver executable for my own and then it worked for me.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ