Skip to content

Commit

Permalink
chore: fix linting (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
GGabriele authored Sep 21, 2023
1 parent b193a18 commit 6336929
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions file/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ func fetchService(id string, kongState *state.KongState, config WriteConfig) (*F
return nil, err
}
for _, p := range plugins {
p := p
if p.Route != nil || p.Consumer != nil {
continue
}
Expand All @@ -306,6 +307,7 @@ func fetchService(id string, kongState *state.KongState, config WriteConfig) (*F
return compareOrder(s.Plugins[i], s.Plugins[j])
})
for _, r := range routes {
r := r
plugins, err := kongState.Plugins.GetAllByRouteID(*r.ID)
if err != nil {
return nil, err
Expand All @@ -316,6 +318,7 @@ func fetchService(id string, kongState *state.KongState, config WriteConfig) (*F
utils.MustRemoveTags(&r.Route, config.SelectTags)
route := &FRoute{Route: r.Route}
for _, p := range plugins {
p := p
if p.Service != nil || p.Consumer != nil {
continue
}
Expand Down Expand Up @@ -347,6 +350,7 @@ func populateServicelessRoutes(kongState *state.KongState, file *Content,
return err
}
for _, r := range routes {
r := r
if r.Service != nil {
continue
}
Expand All @@ -359,6 +363,7 @@ func populateServicelessRoutes(kongState *state.KongState, file *Content,
utils.MustRemoveTags(&r.Route, config.SelectTags)
route := &FRoute{Route: r.Route}
for _, p := range plugins {
p := p
if p.Service != nil || p.Consumer != nil {
continue
}
Expand Down Expand Up @@ -387,6 +392,7 @@ func populatePlugins(kongState *state.KongState, file *Content,
return err
}
for _, p := range plugins {
p := p
associations := 0
if p.Consumer != nil {
associations++
Expand Down Expand Up @@ -464,6 +470,7 @@ func populateUpstreams(kongState *state.KongState, file *Content,
return err
}
for _, t := range targets {
t := t
t.Upstream = nil
utils.ZeroOutID(t, t.Target.Target, config.WithID)
utils.ZeroOutTimestamps(t)
Expand Down Expand Up @@ -523,6 +530,7 @@ func populateCertificates(kongState *state.KongState, file *Content,
return err
}
for _, s := range snis {
s := s
s.Certificate = nil
utils.ZeroOutID(s, s.Name, config.WithID)
utils.ZeroOutTimestamps(s)
Expand Down Expand Up @@ -579,6 +587,7 @@ func populateConsumers(kongState *state.KongState, file *Content,
return err
}
for _, p := range plugins {
p := p
if p.Service != nil || p.Route != nil {
continue
}
Expand All @@ -597,6 +606,7 @@ func populateConsumers(kongState *state.KongState, file *Content,
return err
}
for _, k := range keyAuths {
k := k
utils.ZeroOutID(k, k.Key, config.WithID)
utils.ZeroOutTimestamps(k)
utils.MustRemoveTags(k, config.SelectTags)
Expand All @@ -608,6 +618,7 @@ func populateConsumers(kongState *state.KongState, file *Content,
return err
}
for _, k := range hmacAuth {
k := k
k.Consumer = nil
utils.ZeroOutID(k, k.Username, config.WithID)
utils.ZeroOutTimestamps(k)
Expand All @@ -619,6 +630,7 @@ func populateConsumers(kongState *state.KongState, file *Content,
return err
}
for _, k := range jwtSecrets {
k := k
k.Consumer = nil
utils.ZeroOutID(k, k.Key, config.WithID)
utils.ZeroOutTimestamps(k)
Expand All @@ -630,6 +642,7 @@ func populateConsumers(kongState *state.KongState, file *Content,
return err
}
for _, k := range basicAuths {
k := k
k.Consumer = nil
utils.ZeroOutID(k, k.Username, config.WithID)
utils.ZeroOutTimestamps(k)
Expand All @@ -641,6 +654,7 @@ func populateConsumers(kongState *state.KongState, file *Content,
return err
}
for _, k := range oauth2Creds {
k := k
k.Consumer = nil
utils.ZeroOutID(k, k.ClientID, config.WithID)
utils.ZeroOutTimestamps(k)
Expand All @@ -652,6 +666,7 @@ func populateConsumers(kongState *state.KongState, file *Content,
return err
}
for _, k := range aclGroups {
k := k
k.Consumer = nil
utils.ZeroOutID(k, k.Group, config.WithID)
utils.ZeroOutTimestamps(k)
Expand All @@ -663,6 +678,7 @@ func populateConsumers(kongState *state.KongState, file *Content,
return err
}
for _, k := range mtlsAuths {
k := k
utils.ZeroOutTimestamps(k)
utils.MustRemoveTags(k, config.SelectTags)
k.Consumer = nil
Expand Down Expand Up @@ -732,6 +748,7 @@ func populateConsumerGroups(kongState *state.KongState, file *Content,
group := FConsumerGroupObject{ConsumerGroup: cg.ConsumerGroup}
for _, plugin := range cgPlugins {
if plugin.ID != nil && cg.ID != nil {
plugin := plugin
if plugin.ConsumerGroup != nil && *plugin.ConsumerGroup.ID == *cg.ID {
utils.ZeroOutID(plugin, plugin.Name, config.WithID)
utils.ZeroOutID(plugin.ConsumerGroup, plugin.ConsumerGroup.Name, config.WithID)
Expand Down
2 changes: 1 addition & 1 deletion types/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const (
// RBACRole identifies a RBACRole in Kong Enterprise.
RBACRole EntityType = "rbac-role"
// RBACEndpointPermission identifies a RBACEndpointPermission in Kong Enterprise.
RBACEndpointPermission EntityType = "rbac-endpoint-permission"
RBACEndpointPermission EntityType = "rbac-endpoint-permission" //nolint:gosec

// ServicePackage identifies a ServicePackage in Konnect.
ServicePackage EntityType = "service-package"
Expand Down

0 comments on commit 6336929

Please sign in to comment.