Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: zirain <zirain2009@gmail.com>
  • Loading branch information
zirain committed Sep 11, 2023
1 parent 9d357c5 commit 94a99f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions internal/xds/translator/jsonpatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func processJSONPatches(tCtx *types.ResourceVersionTable, envoyPatchPolicies []*
case string(resourcev3.ListenerType):
temp := &listenerv3.Listener{}
if err = protojson.Unmarshal(modifiedJSON, temp); err != nil {
msg := fmt.Sprintf("unable to unmarshal xds resource %s, err:%s", string(modifiedJSON), err.Error())
msg := unmarshalErrorMessage(err, string(modifiedJSON))
status.SetEnvoyPatchPolicyInvalid(e.Status, msg)
continue
}
Expand All @@ -232,7 +232,7 @@ func processJSONPatches(tCtx *types.ResourceVersionTable, envoyPatchPolicies []*
case string(resourcev3.RouteType):
temp := &routev3.RouteConfiguration{}
if err = protojson.Unmarshal(modifiedJSON, temp); err != nil {
msg := fmt.Sprintf("unable to unmarshal xds resource %s, err:%s", string(modifiedJSON), err.Error())
msg := unmarshalErrorMessage(err, string(modifiedJSON))

Check warning on line 235 in internal/xds/translator/jsonpatch.go

View check run for this annotation

Codecov / codecov/patch

internal/xds/translator/jsonpatch.go#L235

Added line #L235 was not covered by tests
status.SetEnvoyPatchPolicyInvalid(e.Status, msg)
continue
}
Expand All @@ -249,7 +249,7 @@ func processJSONPatches(tCtx *types.ResourceVersionTable, envoyPatchPolicies []*
case string(resourcev3.ClusterType):
temp := &clusterv3.Cluster{}
if err = protojson.Unmarshal(modifiedJSON, temp); err != nil {
msg := fmt.Sprintf("unable to unmarshal xds resource %s, err:%s", string(modifiedJSON), err.Error())
msg := unmarshalErrorMessage(err, string(modifiedJSON))

Check warning on line 252 in internal/xds/translator/jsonpatch.go

View check run for this annotation

Codecov / codecov/patch

internal/xds/translator/jsonpatch.go#L252

Added line #L252 was not covered by tests
status.SetEnvoyPatchPolicyInvalid(e.Status, msg)
continue
}
Expand All @@ -266,7 +266,7 @@ func processJSONPatches(tCtx *types.ResourceVersionTable, envoyPatchPolicies []*
case string(resourcev3.EndpointType):
temp := &endpointv3.ClusterLoadAssignment{}
if err = protojson.Unmarshal(modifiedJSON, temp); err != nil {
msg := fmt.Sprintf("unable to unmarshal xds resource %s, err:%s", string(modifiedJSON), err.Error())
msg := unmarshalErrorMessage(err, string(modifiedJSON))

Check warning on line 269 in internal/xds/translator/jsonpatch.go

View check run for this annotation

Codecov / codecov/patch

internal/xds/translator/jsonpatch.go#L269

Added line #L269 was not covered by tests
status.SetEnvoyPatchPolicyInvalid(e.Status, msg)
continue
}
Expand All @@ -293,7 +293,7 @@ func processJSONPatches(tCtx *types.ResourceVersionTable, envoyPatchPolicies []*
return errs
}

var unescaper = strings.NewReplacer(`\u00a0`, ` `)
var unescaper = strings.NewReplacer(" ", " ")

func unmarshalErrorMessage(err error, xdsResource any) string {
return fmt.Sprintf("unable to unmarshal xds resource %+v, err:%s", xdsResource, unescaper.Replace(err.Error()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
conditions:
- lastTransitionTime: null
message: 'unable to unmarshal xds resource {"name":"first-listener","address":{"socket_address":{"address":"0.0.0.0","port_value":10080}},"default_filter_chain":{"filters":[{"name":"envoy.filters.network.http_connection_manager","typed_config":{"@type":"type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager","stat_prefix":"http","rds":{"config_source":{"ads":{},"resource_api_version":"V3"},"route_config_name":"first-listener"},"http_filters":[{"name":"envoy.filters.http.router","typed_config":{"@type":"type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"}}],"common_http_protocol_options":{"headers_with_underscores_action":"REJECT_REQUEST"},"http2_protocol_options":{"max_concurrent_streams":100,"initial_stream_window_size":65536,"initial_connection_window_size":1048576},"use_remote_address":true,"upgrade_configs":[{"upgrade_type":"websocket"}],"normalize_path":true,"merge_slashes":true,"path_with_escaped_slashes_action":"UNESCAPE_AND_REDIRECT"}}]},"per_connection_buffer_limit_bytes":32768,"this":{"path":{"never":{"existed":{"name":"envoy.filters.http.ratelimit","typed_config":{"@type":"type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit","domain":"eg-ratelimit","failure_mode_deny":true,"rate_limit_service":{"grpc_service":{"envoy_grpc":{"cluster_name":"rate-limit-cluster"}},"transport_api_version":"V3"},"timeout":"1s"}}}}}},
err:proto: (line 1:1023): unknown field "this"'
err:proto: (line 1:1023): unknown field "this"'
reason: Invalid
status: "False"
type: Programmed

0 comments on commit 94a99f5

Please sign in to comment.