-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: comment() filter to comment a given filter chain. (#2905)
One example use case is to use it in more complex objects like RouteGroups and have something that is shown also on kubectl edit rg case Signed-off-by: Sandor Szücs <[email protected]>
- Loading branch information
Showing
5 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package builtin | ||
|
||
import ( | ||
"github.com/zalando/skipper/filters" | ||
"github.com/zalando/skipper/routing" | ||
) | ||
|
||
type comment struct{} | ||
|
||
// NewComment is a filter to comment a filter chain. It does nothing | ||
func NewComment() filters.Spec { | ||
return &comment{} | ||
} | ||
|
||
func (*comment) Name() string { | ||
return filters.CommentName | ||
} | ||
|
||
func (c *comment) CreateFilter(args []interface{}) (filters.Filter, error) { | ||
return c, nil | ||
} | ||
|
||
func (*comment) Request(filters.FilterContext) {} | ||
|
||
func (*comment) Response(filters.FilterContext) {} | ||
|
||
type CommentPostProcessor struct{} | ||
|
||
func (CommentPostProcessor) Do(routes []*routing.Route) []*routing.Route { | ||
for _, r := range routes { | ||
var ff []*routing.RouteFilter | ||
for _, f := range r.Filters { | ||
if f.Name != filters.CommentName { | ||
ff = append(ff, f) | ||
} | ||
} | ||
r.Filters = ff | ||
} | ||
return routes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters