From a68888979f455720f0c3d950f860e83a03286c8d Mon Sep 17 00:00:00 2001 From: rainzm Date: Thu, 14 Jan 2021 19:00:55 +0800 Subject: [PATCH] refactor(climc): remove dependence for `yunion.io/x/pkg/cloudcommon/db` --- pkg/apis/cloudcommon/db/doc.go | 15 +++++++++++++++ pkg/apis/cloudcommon/db/metadata.go | 21 +++++++++++++++++++++ pkg/cloudcommon/db/metadata.go | 7 ++++--- pkg/mcclient/options/base.go | 6 +++--- 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 pkg/apis/cloudcommon/db/doc.go create mode 100644 pkg/apis/cloudcommon/db/metadata.go diff --git a/pkg/apis/cloudcommon/db/doc.go b/pkg/apis/cloudcommon/db/doc.go new file mode 100644 index 0000000000..e56b74db00 --- /dev/null +++ b/pkg/apis/cloudcommon/db/doc.go @@ -0,0 +1,15 @@ +// 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 db // import "yunion.io/x/onecloud/pkg/apis/cloudcommon/db" diff --git a/pkg/apis/cloudcommon/db/metadata.go b/pkg/apis/cloudcommon/db/metadata.go new file mode 100644 index 0000000000..e9803a3716 --- /dev/null +++ b/pkg/apis/cloudcommon/db/metadata.go @@ -0,0 +1,21 @@ +// 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 db + +const ( + CLOUD_TAG_PREFIX = "ext:" + USER_TAG_PREFIX = "user:" + SYS_CLOUD_TAG_PREFIX = "sys:" +) diff --git a/pkg/cloudcommon/db/metadata.go b/pkg/cloudcommon/db/metadata.go index 8901118638..d4221d6058 100644 --- a/pkg/cloudcommon/db/metadata.go +++ b/pkg/cloudcommon/db/metadata.go @@ -29,6 +29,7 @@ import ( "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" + dbapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/cloudcommon/policy" @@ -41,9 +42,9 @@ import ( const ( SYSTEM_ADMIN_PREFIX = "__sys_" SYS_TAG_PREFIX = "__" - CLOUD_TAG_PREFIX = "ext:" - USER_TAG_PREFIX = "user:" - SYS_CLOUD_TAG_PREFIX = "sys:" + CLOUD_TAG_PREFIX = dbapi.CLOUD_TAG_PREFIX + USER_TAG_PREFIX = dbapi.USER_TAG_PREFIX + SYS_CLOUD_TAG_PREFIX = dbapi.SYS_CLOUD_TAG_PREFIX // TAG_DELETE_RANGE_USER = "user" // TAG_DELETE_RANGE_CLOUD = CLOUD_TAG_PREFIX // "cloud" diff --git a/pkg/mcclient/options/base.go b/pkg/mcclient/options/base.go index d7d365a15d..6dee13004c 100644 --- a/pkg/mcclient/options/base.go +++ b/pkg/mcclient/options/base.go @@ -24,7 +24,7 @@ import ( "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/util/reflectutils" - "yunion.io/x/onecloud/pkg/cloudcommon/db" + dbapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/db" ) // Int returns a pointer to int type with the same value as the argument. This @@ -288,14 +288,14 @@ func (opts *BaseListOptions) Params() (*jsonutils.JSONDict, error) { tagIdx++ } for _, tag := range opts.UserTags { - err = opts.addTag(db.USER_TAG_PREFIX, tag, tagIdx, params) + err = opts.addTag(dbapi.USER_TAG_PREFIX, tag, tagIdx, params) if err != nil { return nil, err } tagIdx++ } for _, tag := range opts.CloudTags { - err = opts.addTag(db.CLOUD_TAG_PREFIX, tag, tagIdx, params) + err = opts.addTag(dbapi.CLOUD_TAG_PREFIX, tag, tagIdx, params) if err != nil { return nil, err }