Skip to content

Commit

Permalink
chore: correct typos in comments and code (#3349)
Browse files Browse the repository at this point in the history
* fix typos in comment and code

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* fix tmpl file

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

---------

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
  • Loading branch information
shawnh2 authored May 8, 2024
1 parent c8f1220 commit 04fb089
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions internal/infrastructure/kubernetes/proxy/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down Expand Up @@ -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
}
Expand Down
18 changes: 9 additions & 9 deletions internal/xds/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ 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
// rendered is the rendered bootstrap configuration.
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
Expand All @@ -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.
Expand Down Expand Up @@ -113,16 +113,16 @@ type readyServerParameters struct {

type StatsMatcherParameters struct {
Exacts []string
Prefixs []string
Suffixs []string
Prefixes []string
Suffixes []string
RegularExpressions []string
}

type overloadManagerParameters struct {
MaxHeapSizeBytes uint64
}

type RenderBootsrapConfigOptions struct {
type RenderBootstrapConfigOptions struct {
ProxyMetrics *egv1a1.ProxyMetrics
MaxHeapSizeBytes uint64
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/xds/bootstrap/bootstrap.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
16 changes: 8 additions & 8 deletions internal/xds/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,15 +36,15 @@ func TestGetRenderedBootstrapConfig(t *testing.T) {
},
{
name: "enable-prometheus",
opts: &RenderBootsrapConfigOptions{
opts: &RenderBootstrapConfigOptions{
ProxyMetrics: &egv1a1.ProxyMetrics{
Prometheus: &egv1a1.ProxyPrometheusProvider{},
},
},
},
{
name: "enable-prometheus-gzip-compression",
opts: &RenderBootsrapConfigOptions{
opts: &RenderBootstrapConfigOptions{
ProxyMetrics: &egv1a1.ProxyMetrics{
Prometheus: &egv1a1.ProxyPrometheusProvider{
Compression: &egv1a1.Compression{
Expand All @@ -56,7 +56,7 @@ func TestGetRenderedBootstrapConfig(t *testing.T) {
},
{
name: "otel-metrics",
opts: &RenderBootsrapConfigOptions{
opts: &RenderBootstrapConfigOptions{
ProxyMetrics: &egv1a1.ProxyMetrics{
Prometheus: &egv1a1.ProxyPrometheusProvider{
Disable: true,
Expand All @@ -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,
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestGetRenderedBootstrapConfig(t *testing.T) {
},
{
name: "custom-stats-matcher",
opts: &RenderBootsrapConfigOptions{
opts: &RenderBootstrapConfigOptions{
ProxyMetrics: &egv1a1.ProxyMetrics{
Matches: []egv1a1.StringMatch{
{
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestGetRenderedBootstrapConfig(t *testing.T) {
},
{
name: "with-max-heap-size-bytes",
opts: &RenderBootsrapConfigOptions{
opts: &RenderBootstrapConfigOptions{
MaxHeapSizeBytes: 1073741824,
},
},
Expand Down

0 comments on commit 04fb089

Please sign in to comment.