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 Travis Raines committed Apr 21, 2021
1 parent 907cbe1 commit cbed841
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 @@ -48,7 +48,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 @@ -443,3 +447,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 cbed841

Please sign in to comment.