Skip to content

Commit 3c67ac4

Browse files
move stat prefix to constants (#57879)
* move stat prefix to constants Signed-off-by: Rama Chavali <[email protected]> * use constants in tests Signed-off-by: Rama Chavali <[email protected]> --------- Signed-off-by: Rama Chavali <[email protected]>
1 parent 12716c9 commit 3c67ac4

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

pkg/istio-agent/xds_proxy_delta_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"istio.io/istio/pkg/config/constants"
3636
"istio.io/istio/pkg/test/env"
3737
"istio.io/istio/pkg/test/util/assert"
38+
wasmcache "istio.io/istio/pkg/wasm"
3839
)
3940

4041
// Validates basic xds proxy flow by proxying one CDS requests end to end.
@@ -199,7 +200,7 @@ func TestDeltaECDSWasmConversion(t *testing.T) {
199200
}
200201
httpDenyAll := &httprbac.RBAC{
201202
Rules: &rbacv3.RBAC{},
202-
RulesStatPrefix: "wasm-default-deny",
203+
RulesStatPrefix: wasmcache.DefaultDenyStatPrefix,
203204
}
204205
wantEcdsConfig = &core.TypedExtensionConfig{
205206
Name: "extension-config",

pkg/istio-agent/xds_proxy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ func TestECDSWasmConversion(t *testing.T) {
539539
}
540540
httpDenyAll := &httprbac.RBAC{
541541
Rules: &rbacv3.RBAC{},
542-
RulesStatPrefix: "wasm-default-deny",
542+
RulesStatPrefix: wasmcache.DefaultDenyStatPrefix,
543543
}
544544
wantEcdsConfig = &core.TypedExtensionConfig{
545545
Name: "extension-config",

pkg/wasm/convert.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,33 @@ import (
3737
"istio.io/istio/pkg/util/protomarshal"
3838
)
3939

40+
const (
41+
// DefaultAllowStatPrefix is the stat prefix used for WASM default allow RBAC filters
42+
DefaultAllowStatPrefix = "wasm-default-allow"
43+
// DefaultDenyStatPrefix is the stat prefix used for WASM default deny RBAC filters
44+
DefaultDenyStatPrefix = "wasm-default-deny"
45+
)
46+
4047
var (
4148
allowHTTPTypedConfig, _ = anypb.New(&httprbac.RBAC{
4249
// no rules mean allow all.
43-
RulesStatPrefix: "wasm-default-allow",
50+
RulesStatPrefix: DefaultAllowStatPrefix,
4451
})
4552

4653
denyHTTPTypedConfig, _ = anypb.New(&httprbac.RBAC{
4754
// empty rule means deny all.
4855
Rules: &rbacv3.RBAC{},
49-
RulesStatPrefix: "wasm-default-deny",
56+
RulesStatPrefix: DefaultDenyStatPrefix,
5057
})
5158

5259
allowNetworkTypeConfig, _ = anypb.New(&networkrbac.RBAC{
5360
// no rules mean allow all.
54-
StatPrefix: "wasm-default-allow",
61+
StatPrefix: DefaultAllowStatPrefix,
5562
})
5663
denyNetworkTypedConfig, _ = anypb.New(&networkrbac.RBAC{
5764
// empty rule means deny all.
5865
Rules: &rbacv3.RBAC{},
59-
StatPrefix: "wasm-default-deny",
66+
StatPrefix: DefaultDenyStatPrefix,
6067
})
6168
)
6269

pkg/wasm/convert_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,11 @@ var extensionConfigMap = map[string]*core.TypedExtensionConfig{
480480
},
481481
}),
482482
"remote-load-allow": buildAnyExtensionConfig("remote-load-fail", &rbac.RBAC{
483-
RulesStatPrefix: "wasm-default-allow",
483+
RulesStatPrefix: DefaultAllowStatPrefix,
484484
}),
485485
"remote-load-deny": buildAnyExtensionConfig("remote-load-fail", &rbac.RBAC{
486486
Rules: &rbacv3.RBAC{},
487-
RulesStatPrefix: "wasm-default-deny",
487+
RulesStatPrefix: DefaultDenyStatPrefix,
488488
}),
489489
"remote-load-secret": buildTypedStructExtensionConfig("remote-load-success", &wasm.Wasm{
490490
Config: &v3.PluginConfig{

0 commit comments

Comments
 (0)