From 18d33132f173f82a6fedacc960b71dd340f5d466 Mon Sep 17 00:00:00 2001 From: Gabriele Gerbino Date: Tue, 22 Aug 2023 23:59:00 +0200 Subject: [PATCH] chore: fix linting --- file/writer.go | 17 +++++++++++++++++ types/core.go | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/file/writer.go b/file/writer.go index e503266b3..177d6d99d 100644 --- a/file/writer.go +++ b/file/writer.go @@ -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 } @@ -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 @@ -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 } @@ -347,6 +350,7 @@ func populateServicelessRoutes(kongState *state.KongState, file *Content, return err } for _, r := range routes { + r := r if r.Service != nil { continue } @@ -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 } @@ -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++ @@ -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) @@ -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) @@ -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 } @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 @@ -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) diff --git a/types/core.go b/types/core.go index 9d27a2283..466a63869 100644 --- a/types/core.go +++ b/types/core.go @@ -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"