Skip to content

Commit

Permalink
fix(solver) set foreign ID only for plugins PUT requests
Browse files Browse the repository at this point in the history
Kong 1.1 introduces a change where specifying the name and id of the
service on a POST request results in an incorrect error from Kong.

While, this is a bug in Kong, Kong doesn't promise any compat for cases
when Admin API reqeusts contains entire nested foreign objects.

From #16
  • Loading branch information
hbagdi committed May 8, 2019
1 parent 1f64b66 commit 05320e4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions solver/kong/plugin.go
Expand Up @@ -40,6 +40,16 @@ func pluginFromStuct(arg diff.Event) *state.Plugin {
func (s *PluginCRUD) Create(arg ...crud.Arg) (crud.Arg, error) {
event := eventFromArg(arg[0])
plugin := pluginFromStuct(event)

if plugin.Service != nil {
plugin.Service = &kong.Service{ID: plugin.Service.ID}
}
if plugin.Route != nil {
plugin.Route = &kong.Route{ID: plugin.Route.ID}
}
if plugin.Consumer != nil {
plugin.Consumer = &kong.Consumer{ID: plugin.Consumer.ID}
}
createdPlugin, err := s.client.Plugins.Create(nil, &plugin.Plugin)
if err != nil {
return nil, err
Expand Down

0 comments on commit 05320e4

Please sign in to comment.