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

filters: move annotate into own package #3023

Merged
merged 1 commit into from
Apr 19, 2024
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
6 changes: 3 additions & 3 deletions filters/builtin/annotate.go → filters/annotate/annotate.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package builtin
package annotate

import (
"fmt"
Expand All @@ -16,10 +16,10 @@ type (

const annotateStateBagKey = "filter." + filters.AnnotateName

// NewAnnotate is a filter to annotate a filter chain.
// New creates filters to annotate a filter chain.
// It stores its key and value arguments into the filter context.
// Use [GetAnnotations] to retrieve the annotations from the context.
func NewAnnotate() filters.Spec {
func New() filters.Spec {
return annotateSpec{}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package builtin_test
package annotate_test

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zalando/skipper/eskip"
"github.com/zalando/skipper/filters/builtin"
"github.com/zalando/skipper/filters/annotate"
"github.com/zalando/skipper/filters/filtertest"
)

func TestAnnotate(t *testing.T) {
spec := builtin.NewAnnotate()
spec := annotate.New()

for _, tc := range []struct {
name string
Expand Down Expand Up @@ -46,13 +46,13 @@ func TestAnnotate(t *testing.T) {
filter.Request(ctx)
}

assert.Equal(t, tc.expected, builtin.GetAnnotations(ctx))
assert.Equal(t, tc.expected, annotate.GetAnnotations(ctx))
})
}
}

func TestAnnotateArgs(t *testing.T) {
spec := builtin.NewAnnotate()
spec := annotate.New()

t.Run("valid", func(t *testing.T) {
for _, def := range []string{
Expand Down
3 changes: 2 additions & 1 deletion filters/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package builtin
import (
"github.com/zalando/skipper/filters"
"github.com/zalando/skipper/filters/accesslog"
"github.com/zalando/skipper/filters/annotate"
"github.com/zalando/skipper/filters/auth"
"github.com/zalando/skipper/filters/circuit"
"github.com/zalando/skipper/filters/consistenthash"
Expand Down Expand Up @@ -117,7 +118,7 @@ func Filters() []filters.Spec {
return []filters.Spec{
NewBackendIsProxy(),
NewComment(),
NewAnnotate(),
annotate.New(),
NewRequestHeader(),
NewSetRequestHeader(),
NewAppendRequestHeader(),
Expand Down
Loading