From 04fb089b0c0c4f7c4b48f97f05006c0e13ec071b Mon Sep 17 00:00:00 2001 From: sh2 Date: Wed, 8 May 2024 23:57:44 +0800 Subject: [PATCH] chore: correct typos in comments and code (#3349) * fix typos in comment and code Signed-off-by: shawnh2 * fix tmpl file Signed-off-by: shawnh2 --------- Signed-off-by: shawnh2 --- .../kubernetes/proxy/resource.go | 8 ++++---- internal/xds/bootstrap/bootstrap.go | 18 +++++++++--------- internal/xds/bootstrap/bootstrap.yaml.tpl | 4 ++-- internal/xds/bootstrap/bootstrap_test.go | 16 ++++++++-------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/internal/infrastructure/kubernetes/proxy/resource.go b/internal/infrastructure/kubernetes/proxy/resource.go index dd9f7a90ff9..c4da07d893d 100644 --- a/internal/infrastructure/kubernetes/proxy/resource.go +++ b/internal/infrastructure/kubernetes/proxy/resource.go @@ -143,10 +143,10 @@ func expectedProxyContainers(infra *ir.ProxyInfra, proxyMetrics = infra.Config.Spec.Telemetry.Metrics } - maxHeapSizeBytes := caclulateMaxHeapSizeBytes(containerSpec.Resources) + maxHeapSizeBytes := calculateMaxHeapSizeBytes(containerSpec.Resources) // Get the default Bootstrap - bootstrapConfigurations, err := bootstrap.GetRenderedBootstrapConfig(&bootstrap.RenderBootsrapConfigOptions{ + bootstrapConfigurations, err := bootstrap.GetRenderedBootstrapConfig(&bootstrap.RenderBootstrapConfigOptions{ ProxyMetrics: proxyMetrics, MaxHeapSizeBytes: maxHeapSizeBytes, }) @@ -395,9 +395,9 @@ func expectedContainerEnv(containerSpec *egv1a1.KubernetesContainerSpec) []corev } } -// caclulateMaxHeapSizeBytes calculates the maximum heap size in bytes as 80% of Envoy container memory limits. +// calculateMaxHeapSizeBytes calculates the maximum heap size in bytes as 80% of Envoy container memory limits. // In case no limits are defined '0' is returned, which means no heap size limit is set. -func caclulateMaxHeapSizeBytes(envoyResourceRequirements *corev1.ResourceRequirements) uint64 { +func calculateMaxHeapSizeBytes(envoyResourceRequirements *corev1.ResourceRequirements) uint64 { if envoyResourceRequirements == nil || envoyResourceRequirements.Limits == nil { return 0 } diff --git a/internal/xds/bootstrap/bootstrap.go b/internal/xds/bootstrap/bootstrap.go index 68146e2ddaf..eb5e4398dc5 100644 --- a/internal/xds/bootstrap/bootstrap.go +++ b/internal/xds/bootstrap/bootstrap.go @@ -45,7 +45,7 @@ var bootstrapTmplStr string var bootstrapTmpl = template.Must(template.New(envoyCfgFileName).Parse(bootstrapTmplStr)) -// envoyBootstrap defines the envoy Bootstrap configuration. +// bootstrapConfig defines the envoy Bootstrap configuration. type bootstrapConfig struct { // parameters defines configurable bootstrap configuration parameters. parameters bootstrapParameters @@ -53,7 +53,7 @@ type bootstrapConfig struct { rendered string } -// envoyBootstrap defines the envoy Bootstrap configuration. +// bootstrapParameters defines the envoy Bootstrap configuration. type bootstrapParameters struct { // XdsServer defines the configuration of the XDS server. XdsServer xdsServerParameters @@ -70,7 +70,7 @@ type bootstrapParameters struct { // OtelMetricSinks defines the configuration of the OpenTelemetry sinks. OtelMetricSinks []metricSink - // EnableStatConfig defines whether to to customize the Envoy proxy stats. + // EnableStatConfig defines whether to customize the Envoy proxy stats. EnableStatConfig bool // StatsMatcher is to control creation of custom Envoy stats with prefix, // suffix, and regex expressions match on the name of the stats. @@ -113,8 +113,8 @@ type readyServerParameters struct { type StatsMatcherParameters struct { Exacts []string - Prefixs []string - Suffixs []string + Prefixes []string + Suffixes []string RegularExpressions []string } @@ -122,7 +122,7 @@ type overloadManagerParameters struct { MaxHeapSizeBytes uint64 } -type RenderBootsrapConfigOptions struct { +type RenderBootstrapConfigOptions struct { ProxyMetrics *egv1a1.ProxyMetrics MaxHeapSizeBytes uint64 } @@ -139,7 +139,7 @@ func (b *bootstrapConfig) render() error { } // GetRenderedBootstrapConfig renders the bootstrap YAML string -func GetRenderedBootstrapConfig(opts *RenderBootsrapConfigOptions) (string, error) { +func GetRenderedBootstrapConfig(opts *RenderBootstrapConfigOptions) (string, error) { var ( enablePrometheus = true enablePrometheusCompression = false @@ -199,9 +199,9 @@ func GetRenderedBootstrapConfig(opts *RenderBootsrapConfigOptions) (string, erro case egv1a1.StringMatchExact: StatsMatcher.Exacts = append(StatsMatcher.Exacts, match.Value) case egv1a1.StringMatchPrefix: - StatsMatcher.Prefixs = append(StatsMatcher.Prefixs, match.Value) + StatsMatcher.Prefixes = append(StatsMatcher.Prefixes, match.Value) case egv1a1.StringMatchSuffix: - StatsMatcher.Suffixs = append(StatsMatcher.Suffixs, match.Value) + StatsMatcher.Suffixes = append(StatsMatcher.Suffixes, match.Value) case egv1a1.StringMatchRegularExpression: if err := regex.Validate(match.Value); err != nil { return "", err diff --git a/internal/xds/bootstrap/bootstrap.yaml.tpl b/internal/xds/bootstrap/bootstrap.yaml.tpl index cc59b913862..af05d9752a5 100644 --- a/internal/xds/bootstrap/bootstrap.yaml.tpl +++ b/internal/xds/bootstrap/bootstrap.yaml.tpl @@ -16,10 +16,10 @@ stats_config: {{- range $_, $item := .StatsMatcher.Exacts }} - exact: {{$item}} {{- end}} - {{- range $_, $item := .StatsMatcher.Prefixs }} + {{- range $_, $item := .StatsMatcher.Prefixes }} - prefix: {{$item}} {{- end}} - {{- range $_, $item := .StatsMatcher.Suffixs }} + {{- range $_, $item := .StatsMatcher.Suffixes }} - suffix: {{$item}} {{- end}} {{- range $_, $item := .StatsMatcher.RegularExpressions }} diff --git a/internal/xds/bootstrap/bootstrap_test.go b/internal/xds/bootstrap/bootstrap_test.go index 54ee52f3d4e..19e020c499e 100644 --- a/internal/xds/bootstrap/bootstrap_test.go +++ b/internal/xds/bootstrap/bootstrap_test.go @@ -22,11 +22,11 @@ import ( func TestGetRenderedBootstrapConfig(t *testing.T) { cases := []struct { name string - opts *RenderBootsrapConfigOptions + opts *RenderBootstrapConfigOptions }{ { name: "disable-prometheus", - opts: &RenderBootsrapConfigOptions{ + opts: &RenderBootstrapConfigOptions{ ProxyMetrics: &egv1a1.ProxyMetrics{ Prometheus: &egv1a1.ProxyPrometheusProvider{ Disable: true, @@ -36,7 +36,7 @@ func TestGetRenderedBootstrapConfig(t *testing.T) { }, { name: "enable-prometheus", - opts: &RenderBootsrapConfigOptions{ + opts: &RenderBootstrapConfigOptions{ ProxyMetrics: &egv1a1.ProxyMetrics{ Prometheus: &egv1a1.ProxyPrometheusProvider{}, }, @@ -44,7 +44,7 @@ func TestGetRenderedBootstrapConfig(t *testing.T) { }, { name: "enable-prometheus-gzip-compression", - opts: &RenderBootsrapConfigOptions{ + opts: &RenderBootstrapConfigOptions{ ProxyMetrics: &egv1a1.ProxyMetrics{ Prometheus: &egv1a1.ProxyPrometheusProvider{ Compression: &egv1a1.Compression{ @@ -56,7 +56,7 @@ func TestGetRenderedBootstrapConfig(t *testing.T) { }, { name: "otel-metrics", - opts: &RenderBootsrapConfigOptions{ + opts: &RenderBootstrapConfigOptions{ ProxyMetrics: &egv1a1.ProxyMetrics{ Prometheus: &egv1a1.ProxyPrometheusProvider{ Disable: true, @@ -75,7 +75,7 @@ func TestGetRenderedBootstrapConfig(t *testing.T) { }, { name: "otel-metrics-backendref", - opts: &RenderBootsrapConfigOptions{ + opts: &RenderBootstrapConfigOptions{ ProxyMetrics: &egv1a1.ProxyMetrics{ Prometheus: &egv1a1.ProxyPrometheusProvider{ Disable: true, @@ -103,7 +103,7 @@ func TestGetRenderedBootstrapConfig(t *testing.T) { }, { name: "custom-stats-matcher", - opts: &RenderBootsrapConfigOptions{ + opts: &RenderBootstrapConfigOptions{ ProxyMetrics: &egv1a1.ProxyMetrics{ Matches: []egv1a1.StringMatch{ { @@ -132,7 +132,7 @@ func TestGetRenderedBootstrapConfig(t *testing.T) { }, { name: "with-max-heap-size-bytes", - opts: &RenderBootsrapConfigOptions{ + opts: &RenderBootstrapConfigOptions{ MaxHeapSizeBytes: 1073741824, }, },