From 7bc1789ee884ba93a5c8fb772b494d839334216c Mon Sep 17 00:00:00 2001 From: zhu327 Date: Tue, 14 Nov 2023 16:48:25 +0800 Subject: [PATCH] ft: add selection_mode instance:paste --- pkg/api/model/handler/action_slz.go | 7 ++++--- pkg/api/model/handler/util.go | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/api/model/handler/action_slz.go b/pkg/api/model/handler/action_slz.go index f8c19885..e3f6645b 100644 --- a/pkg/api/model/handler/action_slz.go +++ b/pkg/api/model/handler/action_slz.go @@ -28,8 +28,8 @@ type relatedResourceType struct { NameAlias string `json:"name_alias" example:""` NameAliasEn string `json:"name_alias_en" example:""` - // 实例选择方式/范围: ["all", "instance", "attribute"] - SelectionMode string `json:"selection_mode" binding:"omitempty,oneof=all instance attribute" example:"instance"` + // 实例选择方式/范围: ["all", "instance", "attribute", "instance:paste"] + SelectionMode string `json:"selection_mode" binding:"omitempty,oneof=all instance attribute instance:paste"` RelatedInstanceSelections []referenceInstanceSelection `json:"related_instance_selections" binding:"omitempty"` } @@ -221,7 +221,8 @@ func validateActionAuthType(authType string, relatedResourceTypes []relatedResou // 2.1 if len(action.RelatedResourceTypes) > 0 { for index, rrt := range relatedResourceTypes { // selectionMode == "" will be set to SelectionModeInstance later - if rrt.SelectionMode != "" && rrt.SelectionMode != SelectionModeInstance { + if rrt.SelectionMode != "" && rrt.SelectionMode != SelectionModeInstance && + rrt.SelectionMode != SelectionModeInstancePaste { return false, fmt.Sprintf( "action.auth_type is 'rbac', so the related_resource_types[%d]'s selection_mode should be 'instance'(or empty)", index, diff --git a/pkg/api/model/handler/util.go b/pkg/api/model/handler/util.go index 7c0055fc..d2334929 100644 --- a/pkg/api/model/handler/util.go +++ b/pkg/api/model/handler/util.go @@ -18,9 +18,10 @@ import ( // SelectionModeAll ... const ( - SelectionModeAll = "all" - SelectionModeInstance = "instance" - SelectionModeAttribute = "attribute" + SelectionModeAll = "all" + SelectionModeInstance = "instance" + SelectionModeAttribute = "attribute" + SelectionModeInstancePaste = "instance:paste" ) func convertToRelatedResourceTypes(rrts []relatedResourceType) []svctypes.ActionResourceType {