From cd6cad8ed0a4747c23d1becd00de2b078c0a2f3b Mon Sep 17 00:00:00 2001 From: Daniel Reuter Date: Thu, 23 Feb 2023 16:08:17 +0100 Subject: [PATCH] feat: added `Matcher` to TargetEnrichmentRule -> Attribute --- go/discovery_kit_api/discovery_kit_api.go | 13 ++++++++++++- go/discovery_kit_api/discovery_kit_api_test.go | 2 ++ openapi/spec.yml | 7 +++++++ typescript/discovery_kit_api/index.test.ts | 2 ++ typescript/discovery_kit_api/schemas.d.ts | 2 ++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/go/discovery_kit_api/discovery_kit_api.go b/go/discovery_kit_api/discovery_kit_api.go index a1de337..0c07a95 100644 --- a/go/discovery_kit_api/discovery_kit_api.go +++ b/go/discovery_kit_api/discovery_kit_api.go @@ -13,6 +13,13 @@ const ( Any AttributeAggregationType = "any" ) +// Defines values for AttributeMatcher. +const ( + Contains AttributeMatcher = "contains" + Equals AttributeMatcher = "equals" + StartsWith AttributeMatcher = "starts_with" +) + // Defines values for DescribingEndpointReferenceMethod. const ( DescribingEndpointReferenceMethodGET DescribingEndpointReferenceMethod = "GET" @@ -39,12 +46,16 @@ const ( // Attribute defines model for Attribute. type Attribute struct { AggregationType AttributeAggregationType `json:"aggregationType"` + Matcher AttributeMatcher `json:"matcher"` Name string `json:"name"` } // AttributeAggregationType defines model for Attribute.AggregationType. type AttributeAggregationType string +// AttributeMatcher defines model for Attribute.Matcher. +type AttributeMatcher string + // AttributeDescription defines model for AttributeDescription. type AttributeDescription struct { // The attribute name, for example `cat.name` @@ -401,4 +412,4 @@ func (t *TargetDiscoveryResponse) UnmarshalJSON(b []byte) error { } func Ptr[T any](val T) *T { return &val -} \ No newline at end of file +} diff --git a/go/discovery_kit_api/discovery_kit_api_test.go b/go/discovery_kit_api/discovery_kit_api_test.go index 4bf89f3..d51396d 100644 --- a/go/discovery_kit_api/discovery_kit_api_test.go +++ b/go/discovery_kit_api/discovery_kit_api_test.go @@ -124,10 +124,12 @@ func TestTargetDescription(t *testing.T) { Attributes: []Attribute{ { AggregationType: Any, + Matcher: Equals, Name: "container.name", }, { AggregationType: All, + Matcher: Equals, Name: "container.name", }, }, diff --git a/openapi/spec.yml b/openapi/spec.yml index fdd5c86..884d88d 100644 --- a/openapi/spec.yml +++ b/openapi/spec.yml @@ -220,6 +220,12 @@ components: properties: name: type: string + matcher: + type: string + enum: + - equals + - contains + - starts_with aggregationType: type: string enum: @@ -227,6 +233,7 @@ components: - all required: - name + - matcher - aggregationType SourceOrDestination: type: object diff --git a/typescript/discovery_kit_api/index.test.ts b/typescript/discovery_kit_api/index.test.ts index d1665ca..d5a9224 100644 --- a/typescript/discovery_kit_api/index.test.ts +++ b/typescript/discovery_kit_api/index.test.ts @@ -107,10 +107,12 @@ export const targetDescription: TargetDescription = { attributes: [ { aggregationType: "all", + matcher:"equals", name: 'container.name' }, { aggregationType: "any", + matcher:"equals", name: 'container.name' } ] diff --git a/typescript/discovery_kit_api/schemas.d.ts b/typescript/discovery_kit_api/schemas.d.ts index 8ef6d73..5ba095f 100644 --- a/typescript/discovery_kit_api/schemas.d.ts +++ b/typescript/discovery_kit_api/schemas.d.ts @@ -110,6 +110,8 @@ export interface components { Attribute: { name: string; /** @enum {string} */ + matcher: 'equals' | 'contains' | 'starts_with'; + /** @enum {string} */ aggregationType: 'any' | 'all'; }; SourceOrDestination: {