Skip to content

Commit 18ef8a5

Browse files
author
Steven Landow
committed
[tf] flag to skip deployment of specific apps
Change-Id: I7f1dbf6c7ec5bbd26fe2deb195efc0ee5c5f26e2
1 parent 04168cf commit 18ef8a5

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

pkg/test/framework/components/echo/deployment/builder.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ func (b builder) With(i *echo.Instance, cfg echo.Config) Builder {
132132
return b
133133
}
134134

135+
if !filterConfig(cfg) {
136+
scopes.Framework.Infof("filtered echo config %s due to istio.test.echo.filter.match", cfg)
137+
return b
138+
}
139+
135140
cfg = cfg.DeepCopy()
136141
if err := cfg.FillDefaults(b.ctx); err != nil {
137142
b.errs = multierror.Append(b.errs, err)

pkg/test/framework/components/echo/deployment/flags.go

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3240
func 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

Comments
 (0)