Skip to content

Commit 2a89c3b

Browse files
authored
Optimize wasmplugin proto (#1656)
1 parent a570c72 commit 2a89c3b

File tree

3 files changed

+79
-69
lines changed

3 files changed

+79
-69
lines changed

api/extensions/v1alpha1/wasmplugin.pb.go

+70-64
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/extensions/v1alpha1/wasmplugin.proto

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ message WasmPlugin {
112112
// Extended by Higress, matching rules take effect
113113
repeated MatchRule match_rules = 102;
114114
// disable the default config
115-
bool default_config_disable = 103;
115+
google.protobuf.BoolValue default_config_disable = 103;
116116
}
117117

118118
// Extended by Higress
119119
message MatchRule {
120120
repeated string ingress = 1;
121121
repeated string domain = 2;
122122
google.protobuf.Struct config = 3;
123-
bool config_disable = 4;
123+
google.protobuf.BoolValue config_disable = 4;
124124
repeated string service = 5;
125125
}
126126

pkg/ingress/config/ingress_config.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
881881
if result.PluginConfig != nil {
882882
return result, nil
883883
}
884-
if !obj.DefaultConfigDisable {
884+
if !isBoolValueTrue(obj.DefaultConfigDisable) {
885885
result.PluginConfig = obj.DefaultConfig
886886
}
887887
hasValidRule := false
@@ -893,7 +893,7 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
893893
}
894894
var ruleValues []*_struct.Value
895895
for _, rule := range obj.MatchRules {
896-
if rule.ConfigDisable {
896+
if isBoolValueTrue(rule.ConfigDisable) {
897897
continue
898898
}
899899
if rule.Config == nil {
@@ -982,13 +982,17 @@ func (m *IngressConfig) convertIstioWasmPlugin(obj *higressext.WasmPlugin) (*ext
982982
}
983983
}
984984
}
985-
if !hasValidRule && obj.DefaultConfigDisable {
985+
if !hasValidRule && isBoolValueTrue(obj.DefaultConfigDisable) {
986986
return nil, nil
987987
}
988988
return result, nil
989989

990990
}
991991

992+
func isBoolValueTrue(b *wrappers.BoolValue) bool {
993+
return b != nil && b.Value
994+
}
995+
992996
func (m *IngressConfig) AddOrUpdateWasmPlugin(clusterNamespacedName util.ClusterNamespacedName) {
993997
if clusterNamespacedName.Namespace != m.namespace {
994998
return

0 commit comments

Comments
 (0)