Skip to content

Commit

Permalink
Merge pull request #1607 from flanksource/topo-sort-by-opts
Browse files Browse the repository at this point in the history
chore: add support for sort by in topology query
  • Loading branch information
moshloop authored Jan 24, 2024
2 parents 6ad6854 + bcf9105 commit 2b8a082
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/fergusstrange/embedded-postgres v1.25.0
github.com/flanksource/artifacts v1.0.4
github.com/flanksource/commons v1.20.3
github.com/flanksource/duty v1.0.294
github.com/flanksource/duty v1.0.298
github.com/flanksource/gomplate/v3 v3.21.0
github.com/flanksource/is-healthy v0.0.0-20231003215854-76c51e3a3ff7
github.com/flanksource/kommons v0.31.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ github.com/flanksource/artifacts v1.0.4 h1:KjQTwsvQ73uHqTK7o4Jwt/RW8fyxJOTJ6JLgz
github.com/flanksource/artifacts v1.0.4/go.mod h1:wkbdseaTkDo4Q6k6T86vXd4Uy47M6NPCmexgHvCTDl0=
github.com/flanksource/commons v1.20.3 h1:8HQvskTl6yghQIEMuLs4RWUtt9NS60MPD/iyG32VrYI=
github.com/flanksource/commons v1.20.3/go.mod h1:bs2nMwaTCpTQGZNtJv8KNqEVyfGjFZTGUDaAbPHB1cw=
github.com/flanksource/duty v1.0.294 h1:tREoAbst8IxBizwb2dhTkdXPjixy5l4h3+v85glYjfg=
github.com/flanksource/duty v1.0.294/go.mod h1:CpUK3Hh9tMSRcotQhdQCYOE/VRqT2uy3IIGpH2DWzoY=
github.com/flanksource/duty v1.0.298 h1:CZzlCr4vViY9vNEzx1IaNdN4PHgJIFp+t++qCTjndTc=
github.com/flanksource/duty v1.0.298/go.mod h1:CpUK3Hh9tMSRcotQhdQCYOE/VRqT2uy3IIGpH2DWzoY=
github.com/flanksource/gomplate/v3 v3.20.4/go.mod h1:27BNWhzzSjDed1z8YShO6W+z6G9oZXuxfNFGd/iGSdc=
github.com/flanksource/gomplate/v3 v3.21.0 h1:HbgJ7GCv2fGjjKhGBBtMmo+uA9T6pI9FVm+M/eEurOA=
github.com/flanksource/gomplate/v3 v3.21.0/go.mod h1:m2WVc04GMVBOcZhtDaz/LTtrVWKejeJhFM1Jy/h9VZQ=
Expand Down
2 changes: 1 addition & 1 deletion hack/generate-schemas/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/exaring/otelpgx v0.5.2 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/flanksource/duty v1.0.294 // indirect
github.com/flanksource/duty v1.0.298 // indirect
github.com/flanksource/is-healthy v0.0.0-20231003215854-76c51e3a3ff7 // indirect
github.com/flanksource/kommons v0.31.4 // indirect
github.com/flanksource/postq v1.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions hack/generate-schemas/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/flanksource/commons v1.20.3 h1:8HQvskTl6yghQIEMuLs4RWUtt9NS60MPD/iyG32VrYI=
github.com/flanksource/commons v1.20.3/go.mod h1:bs2nMwaTCpTQGZNtJv8KNqEVyfGjFZTGUDaAbPHB1cw=
github.com/flanksource/duty v1.0.294 h1:tREoAbst8IxBizwb2dhTkdXPjixy5l4h3+v85glYjfg=
github.com/flanksource/duty v1.0.294/go.mod h1:CpUK3Hh9tMSRcotQhdQCYOE/VRqT2uy3IIGpH2DWzoY=
github.com/flanksource/duty v1.0.298 h1:CZzlCr4vViY9vNEzx1IaNdN4PHgJIFp+t++qCTjndTc=
github.com/flanksource/duty v1.0.298/go.mod h1:CpUK3Hh9tMSRcotQhdQCYOE/VRqT2uy3IIGpH2DWzoY=
github.com/flanksource/gomplate/v3 v3.20.4/go.mod h1:27BNWhzzSjDed1z8YShO6W+z6G9oZXuxfNFGd/iGSdc=
github.com/flanksource/gomplate/v3 v3.21.0 h1:HbgJ7GCv2fGjjKhGBBtMmo+uA9T6pI9FVm+M/eEurOA=
github.com/flanksource/gomplate/v3 v3.21.0/go.mod h1:m2WVc04GMVBOcZhtDaz/LTtrVWKejeJhFM1Jy/h9VZQ=
Expand Down
27 changes: 14 additions & 13 deletions pkg/topology/query.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package topology

import (
"context"
"net/url"
"strconv"
"strings"

"github.com/flanksource/commons/collections"
"github.com/flanksource/duty"
dutyContext "github.com/flanksource/duty/context"
dutyQuery "github.com/flanksource/duty/query"
)

const DefaultDepth = 3

func NewTopologyParams(values url.Values) duty.TopologyOptions {
func NewTopologyParams(values url.Values) dutyQuery.TopologyOptions {
parseItems := func(items string) []string {
if strings.TrimSpace(items) == "" {
return nil
Expand All @@ -34,17 +33,19 @@ func NewTopologyParams(values url.Values) duty.TopologyOptions {
depth = DefaultDepth
}
}
return duty.TopologyOptions{
ID: values.Get("id"),
Owner: values.Get("owner"),
Labels: labels,
Status: parseItems(values.Get("status")),
Depth: depth,
Types: parseItems(values.Get("type")),
Flatten: values.Get("flatten") == "true",
return dutyQuery.TopologyOptions{
ID: values.Get("id"),
Owner: values.Get("owner"),
Labels: labels,
Status: parseItems(values.Get("status")),
Depth: depth,
Types: parseItems(values.Get("type")),
Flatten: values.Get("flatten") == "true",
SortBy: dutyQuery.TopologyQuerySortBy(values.Get("sortBy")),
SortOrder: values.Get("sortOrder"),
}
}

func Query(ctx dutyContext.Context, params duty.TopologyOptions) (*duty.TopologyResponse, error) {
return duty.QueryTopology(context.Background(), ctx.Pool(), params)
func Query(ctx dutyContext.Context, params dutyQuery.TopologyOptions) (*dutyQuery.TopologyResponse, error) {
return dutyQuery.Topology(ctx, params)
}

0 comments on commit 2b8a082

Please sign in to comment.