Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/scene_server/admin_server/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ import (
_ "configcenter/src/scene_server/admin_server/upgrader/y3.14.202405141035"
_ "configcenter/src/scene_server/admin_server/upgrader/y3.14.202410100930"
_ "configcenter/src/scene_server/admin_server/upgrader/y3.14.202502101200"
_ "configcenter/src/scene_server/admin_server/upgrader/y3.14.202603161200"
_ "configcenter/src/scene_server/admin_server/upgrader/y3.14.202603231000"
_ "configcenter/src/scene_server/admin_server/upgrader/y3.14.202605111642"
)
42 changes: 42 additions & 0 deletions src/scene_server/admin_server/upgrader/y3.14.202603161200/pkg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Tencent is pleased to support the open source community by making
* 蓝鲸智云 - 配置平台 (BlueKing - Configuration System) available.
* Copyright (C) 2017 Tencent. All rights reserved.
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://opensource.org/licenses/MIT
* 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.
* We undertake not to change the open source license (MIT license) applicable
* to the current version of the project delivered to anyone in the future.
*/

package y3_14_202603161200

import (
"context"

"configcenter/src/common/blog"
"configcenter/src/scene_server/admin_server/upgrader"
"configcenter/src/storage/dal"
)

func init() {
upgrader.RegistUpgrader("y3.14.202603161200", upgrade)
}

func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) {

blog.Infof("start execute y3.14.202603161200")
err = upsertObjAttDesBoolDefaultValue(ctx, db, conf)
if err != nil {
blog.Errorf("upgrade y3.14.202603161200 add host os kernel version field failed, error: %v", err)
return err
}
blog.Infof("execute y3.14.202603161200, add host os kernel version field success!")

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Tencent is pleased to support the open source community by making
* 蓝鲸智云 - 配置平台 (BlueKing - Configuration System) available.
* Copyright (C) 2017 Tencent. All rights reserved.
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://opensource.org/licenses/MIT
* 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.
* We undertake not to change the open source license (MIT license) applicable
* to the current version of the project delivered to anyone in the future.
*/

package y3_14_202603161200

import (
"configcenter/src/common"
"configcenter/src/common/blog"
"configcenter/src/scene_server/admin_server/upgrader"
"configcenter/src/storage/dal"
"context"

"go.mongodb.org/mongo-driver/bson"
)

// upsertObjAttDesBoolDefaultValue
//
//option:true ->default:true
//option:false or default:null ->default:false
func upsertObjAttDesBoolDefaultValue(ctx context.Context, db dal.RDB, conf *upgrader.Config) error {
updateCond := bson.M{
common.BKPropertyTypeField: common.FieldTypeBool,
common.BKDBOR: bson.A{
bson.M{common.BKOptionField: false},
bson.M{common.BKDefaultField: nil},
},
}
updateData := map[string]interface{}{common.BKDefaultField: false}
if err := db.Table(common.BKTableNameObjAttDes).Update(ctx, updateCond, updateData); err != nil {
blog.Errorf("update bool attribute failed, err: %v, cond: %v, updateData: %v", err, updateCond,
updateData)
return err
}

updateCond = bson.M{common.BKOptionField: true}
updateData = map[string]interface{}{common.BKDefaultField: true}
if err := db.Table(common.BKTableNameObjAttDes).Update(ctx, updateCond, updateData); err != nil {
blog.Errorf("update bool attribute failed, err: %v, cond: %v, updateData: %v", err, updateCond,
updateData)
return err
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@ func fillLostListFieldValue(valData mapstr.MapStr, field metadata.Attribute) err
func fillLostBoolFieldValue(valData mapstr.MapStr, field metadata.Attribute) error {
valData[field.PropertyID] = false
if field.Default == nil {
return nil
field.Default = false
field.Option = false
}

field.Option = field.Default
if err := valid.ValidateBoolType(field.Default); err != nil {
return err
}

valData[field.PropertyID] = field.Default
return nil
}
Expand Down