mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-06 21:52:54 +08:00
fix: mv filterclause from pkg to onecloud (#20401)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
2
go.mod
2
go.mod
@@ -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
|
||||
|
||||
4
go.sum
4
go.sum
@@ -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=
|
||||
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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"
|
||||
81
pkg/util/filterclause/filterclause_test.go
Normal file
81
pkg/util/filterclause/filterclause_test.go
Normal file
@@ -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
vendor/modules.txt
vendored
3
vendor/modules.txt
vendored
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user