Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 重试校验接口 --story=119973458 #1085

Open
wants to merge 2 commits into
base: feat-loadbalancer
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* TencentBlueKing is pleased to support the open source community by making
* 蓝鲸智云 - 混合云管理平台 (BlueKing - Hybrid Cloud Management System) available.
* Copyright (C) 2022 THL A29 Limited,
* a Tencent company. 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 lblogic

import (
"encoding/json"

dataservice "hcm/pkg/client/data-service"
"hcm/pkg/criteria/enumor"
"hcm/pkg/kit"
)

var _ ImportValidator = (*CreateLayer4ListenerValidator)(nil)

func newCreateLayer4ListenerValidator(cli *dataservice.Client, vendor enumor.Vendor, bkBizID int64,
accountID string, regionIDs []string) *CreateLayer4ListenerValidator {

return &CreateLayer4ListenerValidator{
newBasePreviewExecutor(cli, vendor, bkBizID, accountID, regionIDs),
}
}

// CreateLayer4ListenerValidator ...
type CreateLayer4ListenerValidator struct {
*basePreviewExecutor
}

// Validate ...
func (c *CreateLayer4ListenerValidator) Validate(kt *kit.Kit, rawData json.RawMessage) (interface{}, error) {
validator := &CreateLayer4ListenerPreviewExecutor{
basePreviewExecutor: c.basePreviewExecutor,
}
err := json.Unmarshal(rawData, &validator.details)
if err != nil {
return nil, err
}

// reset status and validateResult
for _, detail := range validator.details {
detail.Status = ""
detail.ValidateResult = make([]string, 0)
}

if err = validator.validate(kt); err != nil {
return nil, err
}
return validator.details, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* TencentBlueKing is pleased to support the open source community by making
* 蓝鲸智云 - 混合云管理平台 (BlueKing - Hybrid Cloud Management System) available.
* Copyright (C) 2022 THL A29 Limited,
* a Tencent company. 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 lblogic

import (
"encoding/json"

dataservice "hcm/pkg/client/data-service"
"hcm/pkg/criteria/enumor"
"hcm/pkg/kit"
)

var _ ImportValidator = (*CreateLayer7ListenerValidator)(nil)

func newCreateLayer7ListenerValidator(cli *dataservice.Client, vendor enumor.Vendor, bkBizID int64,
accountID string, regionIDs []string) *CreateLayer7ListenerValidator {

return &CreateLayer7ListenerValidator{
newBasePreviewExecutor(cli, vendor, bkBizID, accountID, regionIDs),
}
}

// CreateLayer7ListenerValidator ...
type CreateLayer7ListenerValidator struct {
*basePreviewExecutor
}

// Validate ...
func (c *CreateLayer7ListenerValidator) Validate(kt *kit.Kit, rawData json.RawMessage) (interface{}, error) {
validator := &CreateLayer7ListenerPreviewExecutor{
basePreviewExecutor: c.basePreviewExecutor,
}
err := json.Unmarshal(rawData, &validator.details)
if err != nil {
return nil, err
}

// reset status and validateResult
for _, detail := range validator.details {
detail.Status = ""
detail.ValidateResult = make([]string, 0)
}

if err = validator.validate(kt); err != nil {
return nil, err
}
return validator.details, nil
}
65 changes: 65 additions & 0 deletions cmd/cloud-server/logics/load-balancer/create_url_rule_validator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* TencentBlueKing is pleased to support the open source community by making
* 蓝鲸智云 - 混合云管理平台 (BlueKing - Hybrid Cloud Management System) available.
* Copyright (C) 2022 THL A29 Limited,
* a Tencent company. 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 lblogic

import (
"encoding/json"

dataservice "hcm/pkg/client/data-service"
"hcm/pkg/criteria/enumor"
"hcm/pkg/kit"
)

var _ ImportValidator = (*CreateUrlRuleValidator)(nil)

func newCreateUrlRuleValidator(cli *dataservice.Client, vendor enumor.Vendor, bkBizID int64,
accountID string, regionIDs []string) *CreateUrlRuleValidator {

return &CreateUrlRuleValidator{
newBasePreviewExecutor(cli, vendor, bkBizID, accountID, regionIDs),
}
}

// CreateUrlRuleValidator ...
type CreateUrlRuleValidator struct {
*basePreviewExecutor
}

// Validate ...
func (c *CreateUrlRuleValidator) Validate(kt *kit.Kit, rawData json.RawMessage) (interface{}, error) {
validator := &CreateUrlRulePreviewExecutor{
basePreviewExecutor: c.basePreviewExecutor,
}
err := json.Unmarshal(rawData, &validator.details)
if err != nil {
return nil, err
}

// reset status and validateResult
for _, detail := range validator.details {
detail.Status = ""
detail.ValidateResult = make([]string, 0)
}

if err = validator.validate(kt); err != nil {
return nil, err
}
return validator.details, nil
}
54 changes: 54 additions & 0 deletions cmd/cloud-server/logics/load-balancer/import_validate_executor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* TencentBlueKing is pleased to support the open source community by making
* 蓝鲸智云 - 混合云管理平台 (BlueKing - Hybrid Cloud Management System) available.
* Copyright (C) 2022 THL A29 Limited,
* a Tencent company. 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 lblogic

import (
"encoding/json"
"fmt"

dataservice "hcm/pkg/client/data-service"
"hcm/pkg/criteria/enumor"
"hcm/pkg/kit"
)

// ImportValidator clb导入 参数校验器
type ImportValidator interface {
Validate(*kit.Kit, json.RawMessage) (interface{}, error)
}

// NewImportValidator ...
func NewImportValidator(operationType OperationType, service *dataservice.Client,
vendor enumor.Vendor, bkBizID int64, accountID string, regionIDs []string) (ImportValidator, error) {

switch operationType {
case CreateLayer4Listener:
return newCreateLayer4ListenerValidator(service, vendor, bkBizID, accountID, regionIDs), nil
case CreateLayer7Listener:
return newCreateLayer7ListenerValidator(service, vendor, bkBizID, accountID, regionIDs), nil
case CreateUrlRule:
return newCreateUrlRuleValidator(service, vendor, bkBizID, accountID, regionIDs), nil
case Layer4ListenerBindRs:
return newLayer4ListenerBindRSValidator(service, vendor, bkBizID, accountID, regionIDs), nil
case Layer7ListenerBindRs:
return newLayer7ListenerBindRSValidator(service, vendor, bkBizID, accountID, regionIDs), nil
default:
return nil, fmt.Errorf("unsupported operation type: %s", operationType)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* TencentBlueKing is pleased to support the open source community by making
* 蓝鲸智云 - 混合云管理平台 (BlueKing - Hybrid Cloud Management System) available.
* Copyright (C) 2022 THL A29 Limited,
* a Tencent company. 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 lblogic

import (
"encoding/json"

dataservice "hcm/pkg/client/data-service"
"hcm/pkg/criteria/enumor"
"hcm/pkg/kit"
)

var _ ImportValidator = (*Layer4ListenerBindRSValidator)(nil)

func newLayer4ListenerBindRSValidator(cli *dataservice.Client, vendor enumor.Vendor, bkBizID int64,
accountID string, regionIDs []string) *Layer4ListenerBindRSValidator {

return &Layer4ListenerBindRSValidator{
newBasePreviewExecutor(cli, vendor, bkBizID, accountID, regionIDs),
}
}

// Layer4ListenerBindRSValidator ...
type Layer4ListenerBindRSValidator struct {
*basePreviewExecutor
}

// Validate ...
func (c *Layer4ListenerBindRSValidator) Validate(kt *kit.Kit, rawData json.RawMessage) (interface{}, error) {
validator := &Layer4ListenerBindRSPreviewExecutor{
basePreviewExecutor: c.basePreviewExecutor,
}
err := json.Unmarshal(rawData, &validator.details)
if err != nil {
return nil, err
}

// reset status and validateResult
for _, detail := range validator.details {
detail.Status = ""
detail.ValidateResult = make([]string, 0)
}

if err = validator.validate(kt); err != nil {
return nil, err
}
return validator.details, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* TencentBlueKing is pleased to support the open source community by making
* 蓝鲸智云 - 混合云管理平台 (BlueKing - Hybrid Cloud Management System) available.
* Copyright (C) 2022 THL A29 Limited,
* a Tencent company. 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 lblogic

import (
"encoding/json"

dataservice "hcm/pkg/client/data-service"
"hcm/pkg/criteria/enumor"
"hcm/pkg/kit"
)

var _ ImportValidator = (*Layer7ListenerBindRSValidator)(nil)

func newLayer7ListenerBindRSValidator(cli *dataservice.Client, vendor enumor.Vendor, bkBizID int64,
accountID string, regionIDs []string) *Layer7ListenerBindRSValidator {

return &Layer7ListenerBindRSValidator{
newBasePreviewExecutor(cli, vendor, bkBizID, accountID, regionIDs),
}
}

// Layer7ListenerBindRSValidator ...
type Layer7ListenerBindRSValidator struct {
*basePreviewExecutor
}

// Validate ...
func (c *Layer7ListenerBindRSValidator) Validate(kt *kit.Kit, rawData json.RawMessage) (interface{}, error) {
validator := &Layer7ListenerBindRSPreviewExecutor{
basePreviewExecutor: c.basePreviewExecutor,
}
err := json.Unmarshal(rawData, &validator.details)
if err != nil {
return nil, err
}

// reset status and validateResult
for _, detail := range validator.details {
detail.Status = ""
detail.ValidateResult = make([]string, 0)
}

if err = validator.validate(kt); err != nil {
return nil, err
}
return validator.details, nil
}
Loading