(ctx *gin.Context, scope string)
| 100 | } |
| 101 | |
| 102 | func (i *imlStrategyController) filterOptions(ctx *gin.Context, scope string) ([]*strategy_dto.FilterOption, error) { |
| 103 | m, has := strategy_filter.Options(scope) |
| 104 | if !has { |
| 105 | return nil, fmt.Errorf("scope not found: %s", scope) |
| 106 | } |
| 107 | |
| 108 | list := utils.MapToSlice(m, func(key string, value *strategy_filter.Option) *strategy_dto.FilterOption { |
| 109 | pattern := "" |
| 110 | if value.Pattern != nil { |
| 111 | pattern = value.Pattern.String() |
| 112 | } |
| 113 | return &strategy_dto.FilterOption{ |
| 114 | Name: value.Name, |
| 115 | Title: value.Title, |
| 116 | Type: value.Type, |
| 117 | Pattern: pattern, |
| 118 | Options: value.Options, |
| 119 | } |
| 120 | }) |
| 121 | sort.Slice(list, func(i, j int) bool { |
| 122 | return list[i].Name < list[j].Name |
| 123 | }) |
| 124 | return list, nil |
| 125 | } |
| 126 | |
| 127 | func (i *imlStrategyController) FilterServiceOptions(ctx *gin.Context) ([]*strategy_dto.FilterOption, error) { |
| 128 | return i.filterOptions(ctx, strategy_filter.ScopeService) |
no test coverage detected