Skip to content

Commit 963b99e

Browse files
authored
Merge pull request #25 from linuxfoundation/andrest50/tags-all
[LFXV2-775] Add support for tags_all parameter with AND logic
2 parents c2602d7 + 5141b4f commit 963b99e

File tree

20 files changed

+379
-202
lines changed

20 files changed

+379
-202
lines changed

charts/lfx-v2-query-service/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ apiVersion: v2
55
name: lfx-v2-query-service
66
description: LFX Platform V2 Query Service chart
77
type: application
8-
version: 0.4.8
8+
version: 0.4.9
99
appVersion: "latest"

cmd/service/converters.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func (s *querySvcsrvc) payloadToCriteria(ctx context.Context, p *querysvc.QueryR
2222
Parent: p.Parent,
2323
ResourceType: p.Type,
2424
Tags: p.Tags,
25+
TagsAll: p.TagsAll,
2526
SortBy: p.Sort,
2627
PageToken: p.PageToken,
2728
PageSize: constants.DefaultPageSize,
@@ -91,6 +92,7 @@ func (s *querySvcsrvc) payloadToCountPublicCriteria(payload *querysvc.QueryResou
9192

9293
// Set the criteria from the payload
9394
criteria.Tags = payload.Tags
95+
criteria.TagsAll = payload.TagsAll
9496
if payload.Name != nil {
9597
criteria.Name = payload.Name
9698
}
@@ -119,6 +121,7 @@ func (s *querySvcsrvc) payloadToCountAggregationCriteria(payload *querysvc.Query
119121

120122
// Set the criteria from the payload
121123
criteria.Tags = payload.Tags
124+
criteria.TagsAll = payload.TagsAll
122125
if payload.Name != nil {
123126
criteria.Name = payload.Name
124127
}

design/query-svc.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ var _ = dsl.Service("query-svc", func() {
5050
dsl.Attribute("type", dsl.String, "Resource type to search", func() {
5151
dsl.Example("committee")
5252
})
53-
dsl.Attribute("tags", dsl.ArrayOf(dsl.String), "Tags to search (varies by object type)", func() {
54-
dsl.Example([]string{"active"})
53+
dsl.Attribute("tags", dsl.ArrayOf(dsl.String), "Tags to search with OR logic - matches resources with any of these tags", func() {
54+
dsl.Example([]string{"active", "public"})
55+
})
56+
dsl.Attribute("tags_all", dsl.ArrayOf(dsl.String), "Tags to search with AND logic - matches resources that have all of these tags", func() {
57+
dsl.Example([]string{"governance", "security"})
5558
})
5659
dsl.Required("bearer_token", "version")
5760
})
@@ -74,6 +77,7 @@ var _ = dsl.Service("query-svc", func() {
7477
dsl.Param("parent")
7578
dsl.Param("type")
7679
dsl.Param("tags")
80+
dsl.Param("tags_all")
7781
dsl.Param("sort")
7882
dsl.Param("page_token")
7983
dsl.Header("bearer_token:Authorization")
@@ -110,8 +114,11 @@ var _ = dsl.Service("query-svc", func() {
110114
dsl.Attribute("type", dsl.String, "Resource type to search", func() {
111115
dsl.Example("committee")
112116
})
113-
dsl.Attribute("tags", dsl.ArrayOf(dsl.String), "Tags to search (varies by object type)", func() {
114-
dsl.Example([]string{"active"})
117+
dsl.Attribute("tags", dsl.ArrayOf(dsl.String), "Tags to search with OR logic - matches resources with any of these tags", func() {
118+
dsl.Example([]string{"active", "public"})
119+
})
120+
dsl.Attribute("tags_all", dsl.ArrayOf(dsl.String), "Tags to search with AND logic - matches resources that have all of these tags", func() {
121+
dsl.Example([]string{"governance", "security"})
115122
})
116123
dsl.Required("bearer_token", "version")
117124
})
@@ -129,15 +136,14 @@ var _ = dsl.Service("query-svc", func() {
129136
dsl.Required("count", "has_more")
130137
})
131138

132-
dsl.Error("BadRequest", dsl.ErrorResult, "Bad request")
133-
134139
dsl.HTTP(func() {
135140
dsl.GET("/query/resources/count")
136141
dsl.Param("version:v")
137142
dsl.Param("name")
138143
dsl.Param("parent")
139144
dsl.Param("type")
140145
dsl.Param("tags")
146+
dsl.Param("tags_all")
141147
dsl.Header("bearer_token:Authorization")
142148
dsl.Response(dsl.StatusOK, func() {
143149
dsl.Header("cache_control:Cache-Control")

gen/http/cli/lfx_v2_query_service/cli.go

Lines changed: 23 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)