diff --git a/README.md b/README.md index e5ba6f6..6591dad 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ The Kong agents are used to discover, provision access to, and track usages of K - [Kong admin API secured by Kong Gateway](#kong-admin-api-secured-by-kong-gateway) - [Specification discovery methods](#specification-discovery-methods) - [Local specification path](#local-specification-path) + - [Filtering gateway services](#filtering-gateway-services) - [URL specification paths](#url-specification-paths) - [Kong Dev Portal](#kong-dev-portal) - [HTTP Log plugin](#http-log-plugin) @@ -218,6 +219,16 @@ Configuration on my-service gateway service } ``` +##### Filtering gateway services + +Some possible ways to use the filter for gateway services (all these are done with the env var `KONG_SPEC_FILTER`): + +Ex1: "tag.Any() == \"spec_local_petstore.json\"" -> this will find all the services that have a tag as "spec_local_petstore.json" +Ex2: "tag.discover.Exists()" -> this will find all tags that are equal to "discover" +Note: while both ways can achieve the same functionality, the first one is preferred because it does not restrict you on character usages for Kong tags (note the dot in example 2) + +Currently, functionalities such as tag.Any().Contains() are not implemented in the SDK and only fully equal values are taken into account + ##### URL specification paths The URL specification paths discovery method is configured by value(s) for the `KONG_SPEC_URLPATHS` variable, comma separated. When values are set here, and a local path is not set, The Kong agent will query each of these paths against the gateway service in order to find a specification file. Once a specification file is found none of the other configured URL paths will be queried as that specification file will be used in the creation of the API Service on Central. diff --git a/go.mod b/go.mod index c9264d7..6f7ef2d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/Axway/agents-kong go 1.18 require ( - github.com/Axway/agent-sdk v1.1.70-0.20231207222513-e111e500a79c + github.com/Axway/agent-sdk v1.1.70 github.com/elastic/beats/v7 v7.17.15 github.com/google/uuid v1.3.1 github.com/kong/go-kong v0.47.0 diff --git a/go.sum b/go.sum index 712c939..b18d359 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Axway/agent-sdk v1.1.70-0.20231207222513-e111e500a79c h1:Ps/20eSKr6DcmSumAf/yE/KkffrofExw3D/e3lMtoO8= -github.com/Axway/agent-sdk v1.1.70-0.20231207222513-e111e500a79c/go.mod h1:Iuv9KlWksVTbTKdfs4bKVYMDc33ZTLYoHt572z2CbbI= +github.com/Axway/agent-sdk v1.1.70 h1:34QravPV19zkTp7tout7u7KX7XCXaO0OBOil17pRYSE= +github.com/Axway/agent-sdk v1.1.70/go.mod h1:Iuv9KlWksVTbTKdfs4bKVYMDc33ZTLYoHt572z2CbbI= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.12/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= diff --git a/pkg/discovery/gateway/client.go b/pkg/discovery/gateway/client.go index c5c03c0..fd39938 100644 --- a/pkg/discovery/gateway/client.go +++ b/pkg/discovery/gateway/client.go @@ -135,8 +135,8 @@ func (gc *Client) processKongServicesList(ctx context.Context, services []*klib. func toTagsMap(service *klib.Service) map[string]string { // The SDK currently only supports map[string]string format. filters := make(map[string]string) - for i, t := range service.Tags { - filters[fmt.Sprintf("t%d", i)] = *t + for _, tag := range service.Tags { + filters[*tag] = *tag } return filters } diff --git a/pkg/traceability/processor/processor_test.go b/pkg/traceability/processor/processor_test.go index 3da1e35..48605af 100644 --- a/pkg/traceability/processor/processor_test.go +++ b/pkg/traceability/processor/processor_test.go @@ -2,6 +2,7 @@ package processor import ( "context" + "sync" "testing" "github.com/Axway/agent-sdk/pkg/traceability/redaction" @@ -42,6 +43,7 @@ var testData = []byte(`[{ }]`) func TestNewHandler(t *testing.T) { + testLock := sync.Mutex{} cases := map[string]struct { data []byte constructorErr bool @@ -68,6 +70,9 @@ func TestNewHandler(t *testing.T) { } for name, tc := range cases { t.Run(name, func(t *testing.T) { + testLock.Lock() + defer testLock.Unlock() + ctx := context.WithValue(context.Background(), "test", name) redaction.SetupGlobalRedaction(redaction.DefaultConfig())