From 7b77dd59d87fee6c9a287fe91e3e78be2d422883 Mon Sep 17 00:00:00 2001 From: junot Date: Wed, 17 Jan 2024 16:37:02 +0800 Subject: [PATCH] fix unittest Signed-off-by: junot --- pkg/util/envoy_config.go | 16 ++++++++-------- pkg/util/envoy_config_test.go | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/util/envoy_config.go b/pkg/util/envoy_config.go index 94dc793c..69f419a6 100644 --- a/pkg/util/envoy_config.go +++ b/pkg/util/envoy_config.go @@ -9,7 +9,7 @@ import ( var EnvoyStaticConfigTemplate = template.Must(template.New("envoy.yaml").Parse(dedent.Dedent(` static_resources: listeners: -{{ if .LocalServiceEnabled }} +{{- if .LocalServiceEnabled }} - name: self_listener address: socket_address: @@ -46,8 +46,8 @@ static_resources: filename: {{ .ServiceTLSCertFile }} private_key: filename: {{ .ServiceTLSKeyFile }} -{{ end }} -{{ if .ProxyServiceEnabled }} +{{- end }} +{{- if .ProxyServiceEnabled }} - name: proxy_listener address: socket_address: @@ -74,9 +74,9 @@ static_resources: cluster: upstrean_serivce http_filters: - name: envoy.filters.http.router -{{ end }} +{{- end }} clusters: -{{ if .LocalServiceEnabled }} +{{- if .LocalServiceEnabled }} - name: local_serivce type: STATIC lb_policy: ROUND_ROBIN @@ -89,8 +89,8 @@ static_resources: socket_address: address: 127.0.0.1 port_value: {{ .ServiceListenPort }} -{{ end }} -{{ if .ProxyServiceEnabled }} +{{- end }} +{{- if .ProxyServiceEnabled }} - name: upstrean_serivce type: STRICT_DNS lb_policy: ROUND_ROBIN @@ -111,5 +111,5 @@ static_resources: validation_context: trust_chain_verification: ACCEPT_UNTRUSTED sni: {{ .ProxyServiceAddress }} -{{ end }} +{{- end }} `))) diff --git a/pkg/util/envoy_config_test.go b/pkg/util/envoy_config_test.go index ce933f99..d1713bc5 100644 --- a/pkg/util/envoy_config_test.go +++ b/pkg/util/envoy_config_test.go @@ -97,19 +97,19 @@ static_resources: socket_address: address: query-whizard-operated.kubesphere-monitoring-system.svc port_value: 10902 - transport_socket: - name: envoy.transport_sockets.tls - typed_config: - '@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext - common_tls_context: - validation_context: - trust_chain_verification: ACCEPT_UNTRUSTED - alpn_protocols: 'h2,http/1.1' - sni: query-whizard-operated.kubesphere-monitoring-system.svc + transport_socket: + name: envoy.transport_sockets.tls + typed_config: + '@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext + common_tls_context: + validation_context: + trust_chain_verification: ACCEPT_UNTRUSTED + sni: query-whizard-operated.kubesphere-monitoring-system.svc ` func TestTempExec(t *testing.T) { - variables := map[string]string{ + variables := map[string]interface{}{ + "LocalServiceEnabled": true, "ServiceMappingPort": "10902", "ServiceListenPort": "10904", "ServiceTLSCertFile": "/etc/whizard/certs/tls.crt",