@@ -18,20 +18,49 @@ import (
1818 "bytes"
1919 "flag"
2020 "fmt"
21- "os"
22-
2321 "gopkg.in/yaml.v3"
22+ "istio.io/istio/pkg/test/scopes"
23+ "istio.io/istio/pkg/test/util/tmpl"
24+ "os"
25+ "regexp"
2426
2527 "istio.io/istio/pkg/test/framework/components/echo"
2628 "istio.io/istio/pkg/test/framework/config"
2729 "istio.io/istio/pkg/test/util/file"
2830)
2931
30- var additionalConfigs = & configs {}
32+ const defaultEchoConfigFilterTmpl = "{{.Service}}"
33+
34+ var (
35+ additionalConfigs = & configs {}
36+
37+ configFilter , configFilterTmpl string
38+ )
3139
3240func init () {
3341 flag .Var (additionalConfigs , "istio.test.echo.configs" , "The path to a file containing a list of " +
3442 "echo.Config in YAML which will be added to the set of echos for every suite." )
43+ flag .StringVar (& configFilter , "istio.test.echo.filter.match" , "" , "A regex that all echo configs must match " +
44+ "or deployment will be skipped." )
45+ flag .StringVar (& configFilterTmpl , "istio.test.echo.filter.matchTemplate" , defaultEchoConfigFilterTmpl , "Template rendered from the echo.Config that " +
46+ "builds a string for istio.test.echo.filter.match to check against." )
47+ }
48+
49+ func filterConfig (config echo.Config ) bool {
50+ if configFilter == "" {
51+ return true
52+ }
53+ configFilterRe , err := regexp .Compile (configFilter )
54+ if err != nil {
55+ scopes .Framework .Errorf ("failed to compile regexp for istio.test.echo.filter.match: %v" , err )
56+ return true
57+ }
58+ filterStr , err := tmpl .Evaluate (configFilterTmpl , config )
59+ if err != nil {
60+ scopes .Framework .Errorf ("failed evaluating template for istio.test.echo.filter.matchTemplate: %v" , err )
61+ return true
62+ }
63+ return configFilterRe .MatchString (filterStr )
3564}
3665
3766// configs wraps a slice of echo.Config to implement the config.Value interface, allowing
0 commit comments