Skip to content

Commit

Permalink
fix(dump) exclude consumer plugins when --skip-consumers
Browse files Browse the repository at this point in the history
Fix #119 
From #120
  • Loading branch information
owlwalks authored and hbagdi committed Jan 18, 2020
1 parent d0f72bc commit 9ffe5ab
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ func Get(client *kong.Client, config Config) (*utils.KongRawState, error) {
if err != nil {
return nil, errors.Wrap(err, "plugins")
}
state.Plugins = plugins
if config.SkipConsumers {
state.Plugins = excludeConsumersPlugins(plugins)
} else {
state.Plugins = plugins
}

certificates, err := GetAllCertificates(client, config.SelectorTags)
if err != nil {
Expand Down Expand Up @@ -444,3 +448,15 @@ func GetAllACLGroups(client *kong.Client, tags []string) ([]*kong.ACLGroup, erro
}
return aclGroups, nil
}

// excludeConsumersPlugins filter out consumer plugins
func excludeConsumersPlugins(plugins []*kong.Plugin) []*kong.Plugin {
var filtered []*kong.Plugin
for _, p := range plugins {
if p.Consumer != nil && !utils.Empty(p.Consumer.ID) {
continue
}
filtered = append(filtered, p)
}
return filtered
}

0 comments on commit 9ffe5ab

Please sign in to comment.