Skip to content

Commit

Permalink
ft: add selection_mode instance:paste (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu327 authored Nov 22, 2023
1 parent 43afc46 commit 21cfe43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions pkg/api/model/handler/action_slz.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions pkg/api/model/handler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 21cfe43

Please sign in to comment.