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

ft: add selection_mode instance:paste #276

Merged
merged 1 commit into from
Nov 22, 2023
Merged
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
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