Skip to content

Commit

Permalink
fix: mv filterclause from pkg to onecloud (#20401)
Browse files Browse the repository at this point in the history
Co-authored-by: Qiu Jian <[email protected]>
  • Loading branch information
swordqiu and Qiu Jian authored May 30, 2024
1 parent 618c1a0 commit 0b08619
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ require (
yunion.io/x/jsonutils v1.0.1-0.20240203102553-4096f103b401
yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91
yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900
yunion.io/x/pkg v1.10.1-0.20240529092737-3da904b113a0
yunion.io/x/pkg v1.10.1-0.20240530045123-0d65278dc326
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
yunion.io/x/sqlchemy v1.1.3-0.20240524113104-170e3ba87126
yunion.io/x/structarg v0.0.0-20231017124457-df4d5009457c
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,8 @@ yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900 h1:Hu/4ERvoWaN6aiFs4h4/yvVB
yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900/go.mod h1:0vLkNEhlmA64HViPBAnSTUMrx5QP1CLsxXmxDKQ80tc=
yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v1.10.1-0.20240529092737-3da904b113a0 h1:eJ24XjkLVZ+7HXVc5J/5E4b2hzXJsAAz0dvqeJjZBI0=
yunion.io/x/pkg v1.10.1-0.20240529092737-3da904b113a0/go.mod h1:ksCJVQ+DwKrJ5QBEoU8pzrDFfDaZVAFH/iJ6yQCYxJk=
yunion.io/x/pkg v1.10.1-0.20240530045123-0d65278dc326 h1:aGFAPLOA1CoE48qV4qeKSsRfeL9EC5YCukxPEQ3Q0Yw=
yunion.io/x/pkg v1.10.1-0.20240530045123-0d65278dc326/go.mod h1:EE/+PnAAdVMeWumUxMw26gVMobULwvBqvfpgCDarqko=
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo=
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo=
yunion.io/x/sqlchemy v1.1.3-0.20240524113104-170e3ba87126 h1:lg8ZkMsuF4L+yqRhFDNxhxaOuuvY9HLzr3FW7BRa5vE=
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudcommon/db/db_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/pkg/util/filterclause"
"yunion.io/x/pkg/util/printutils"
"yunion.io/x/pkg/util/rbacscope"
"yunion.io/x/pkg/util/version"
Expand All @@ -41,6 +40,7 @@ import (
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/util/filterclause"
"yunion.io/x/onecloud/pkg/util/logclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
"yunion.io/x/onecloud/pkg/util/stringutils2"
Expand Down
2 changes: 1 addition & 1 deletion pkg/monitor/models/alertrecord.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/filterclause"
"yunion.io/x/pkg/util/rbacscope"
"yunion.io/x/pkg/util/timeutils"
"yunion.io/x/sqlchemy"
Expand All @@ -32,6 +31,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/filterclause"
"yunion.io/x/onecloud/pkg/util/stringutils2"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package filterclause // import "yunion.io/x/pkg/util/filterclause"
package filterclause // import "yunion.io/x/onecloud/pkg/util/filterclause"
File renamed without changes.
81 changes: 81 additions & 0 deletions pkg/util/filterclause/filterclause_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package filterclause

import (
"reflect"
"testing"
)

func TestParseFilterClause(t *testing.T) {
for _, c := range []string{
"abc.in(1,2,3)",
"test.equals(1)",
} {
fc := ParseFilterClause(c)
t.Logf("%s => %s", c, fc.String())
}
}

func TestParseJointFilterClause(t *testing.T) {
type args struct {
jointFilter string
}
tests := []struct {
name string
args args
want *SJointFilterClause
}{
{
name: "test parse guestnetworks",
args: args{
jointFilter: "guestnetworks.guest_id(id).ip_addr.equals(10.168.222.232)",
},
want: &SJointFilterClause{
SFilterClause: SFilterClause{
field: "ip_addr",
funcName: "equals",
params: []string{"10.168.222.232"},
},
JointModel: "guestnetworks",
RelatedKey: "guest_id",
OriginKey: "id",
},
},
{
name: "test parse guestnetworks",
args: args{
jointFilter: "networks.id(network_id).name.contains(wp)",
},
want: &SJointFilterClause{
SFilterClause: SFilterClause{
field: "name",
funcName: "contains",
params: []string{"wp"},
},
JointModel: "networks",
RelatedKey: "id",
OriginKey: "network_id",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ParseJointFilterClause(tt.args.jointFilter); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ParseJointFilterClause() = %v, want %v", got, tt.want)
}
})
}
}
3 changes: 1 addition & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ yunion.io/x/log/hooks
yunion.io/x/ovsdb/cli_util
yunion.io/x/ovsdb/schema/ovn_nb
yunion.io/x/ovsdb/types
# yunion.io/x/pkg v1.10.1-0.20240529092737-3da904b113a0
# yunion.io/x/pkg v1.10.1-0.20240530045123-0d65278dc326
## explicit; go 1.18
yunion.io/x/pkg/appctx
yunion.io/x/pkg/errors
Expand All @@ -1801,7 +1801,6 @@ yunion.io/x/pkg/util/delayedwork
yunion.io/x/pkg/util/encode
yunion.io/x/pkg/util/errors
yunion.io/x/pkg/util/fileutils
yunion.io/x/pkg/util/filterclause
yunion.io/x/pkg/util/goroutine_pool
yunion.io/x/pkg/util/httputils
yunion.io/x/pkg/util/imagetools
Expand Down

0 comments on commit 0b08619

Please sign in to comment.