Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/cmd/egctl/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (f *fakeCLIClient) PodsForSelector(string, ...string) (*corev1.PodList, err
return &corev1.PodList{Items: f.pods}, nil
}

func (f *fakeCLIClient) PodExec(types.NamespacedName, string, string) (stdout string, stderr string, err error) {
func (f *fakeCLIClient) PodExec(types.NamespacedName, string, string) (stdout, stderr string, err error) {
return "", "", nil
}

Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/egctl/stats_envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func newEnvoyStatsCmd() *cobra.Command {
return statsConfigCmd
}

func setupEnvoyServerStatsConfig(kubeClient kubernetes.CLIClient, podName, podNamespace string, outputFormat string) (string, error) {
func setupEnvoyServerStatsConfig(kubeClient kubernetes.CLIClient, podName, podNamespace, outputFormat string) (string, error) {
path := "stats"
if outputFormat == jsonOutput || outputFormat == yamlOutput {
// for yaml output we will convert the json to yaml when printed
Expand All @@ -161,7 +161,7 @@ func setupEnvoyServerStatsConfig(kubeClient kubernetes.CLIClient, podName, podNa
return string(result), nil
}

func setupEnvoyClusterStatsConfig(kubeClient kubernetes.CLIClient, podName, podNamespace string, outputFormat string) (string, error) {
func setupEnvoyClusterStatsConfig(kubeClient kubernetes.CLIClient, podName, podNamespace, outputFormat string) (string, error) {
path := "clusters"
if outputFormat == jsonOutput || outputFormat == yamlOutput {
// for yaml output we will convert the json to yaml when printed
Expand All @@ -184,7 +184,7 @@ func setupEnvoyClusterStatsConfig(kubeClient kubernetes.CLIClient, podName, podN
return string(result), nil
}

func statsRequest(address string, path string) ([]byte, error) {
func statsRequest(address, path string) ([]byte, error) {
url := fmt.Sprintf("http://%s/%s", address, path)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/envoy/shutdown_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func shutdownReadyHandler(w http.ResponseWriter, readyTimeout time.Duration, rea
// Shutdown is called from a preStop hook on the shutdown-manager container where
// it will initiate a drain sequence on the Envoy proxy and block until
// connections are drained or a timeout is exceeded.
func Shutdown(drainTimeout time.Duration, minDrainDuration time.Duration, exitAtConnections int) error {
func Shutdown(drainTimeout, minDrainDuration time.Duration, exitAtConnections int) error {
startTime := time.Now()
allowedToExit := false

Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/ext_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (t *Translator) processExtServiceDestination(
return ds, nil
}

func irIndexedExtServiceDestinationName(policyNamespacedName types.NamespacedName, policyKind string, configType string, idx int) string {
func irIndexedExtServiceDestinationName(policyNamespacedName types.NamespacedName, policyKind, configType string, idx int) string {
return strings.ToLower(fmt.Sprintf(
"%s/%s/%s/%s/%d",
policyKind,
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (r *Resources) GetConfigMap(namespace, name string) *corev1.ConfigMap {
return nil
}

func (r *Resources) GetEndpointSlicesForBackend(svcNamespace, svcName string, backendKind string) []*discoveryv1.EndpointSlice {
func (r *Resources) GetEndpointSlicesForBackend(svcNamespace, svcName, backendKind string) []*discoveryv1.EndpointSlice {
var endpointSlices []*discoveryv1.EndpointSlice
for _, endpointSlice := range r.EndpointSlices {
var backendSelectorLabel string
Expand Down
4 changes: 2 additions & 2 deletions internal/gatewayapi/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _ TranslatorManager = (*Translator)(nil)

type TranslatorManager interface {
Translate(resources *resource.Resources) (*TranslateResult, error)
GetRelevantGateways(resources *resource.Resources) (acceptedGateways []*GatewayContext, failedGateways []*GatewayContext)
GetRelevantGateways(resources *resource.Resources) (acceptedGateways, failedGateways []*GatewayContext)

RoutesTranslator
ListenersTranslator
Expand Down Expand Up @@ -255,7 +255,7 @@ func (t *Translator) Translate(resources *resource.Resources) (*TranslateResult,
// GetRelevantGateways returns GatewayContexts, containing a copy of the original
// Gateway with the Listener statuses reset.
func (t *Translator) GetRelevantGateways(resources *resource.Resources) (
acceptedGateways []*GatewayContext, failedGateways []*GatewayContext,
acceptedGateways, failedGateways []*GatewayContext,
) {
for _, gateway := range resources.Gateways {
if gateway == nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/gatewayapi/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ func TestTranslateWithExtensionKinds(t *testing.T) {
}
}

func overrideOutputConfig(t *testing.T, data string, filepath string) {
func overrideOutputConfig(t *testing.T, data, filepath string) {
t.Helper()
file, err := os.OpenFile(filepath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
require.NoError(t, err)
Expand Down Expand Up @@ -846,7 +846,7 @@ type mockWasmCache struct{}

func (m *mockWasmCache) Start(_ context.Context) {}

func (m *mockWasmCache) Get(downloadURL string, options wasm.GetOptions) (url string, checksum string, err error) {
func (m *mockWasmCache) Get(downloadURL string, options wasm.GetOptions) (url, checksum string, err error) {
// This is a mock implementation of the wasm.Cache.Get method.
sha := sha256.Sum256([]byte(downloadURL))
hashedName := hex.EncodeToString(sha[:])
Expand Down
2 changes: 1 addition & 1 deletion internal/infrastructure/kubernetes/proxy/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func enablePrometheus(infra *ir.ProxyInfra) bool {
func expectedProxyContainers(infra *ir.ProxyInfra,
containerSpec *egv1a1.KubernetesContainerSpec,
shutdownConfig *egv1a1.ShutdownConfig, shutdownManager *egv1a1.ShutdownManager,
namespace string, dnsDomain string,
namespace, dnsDomain string,
) ([]corev1.Container, error) {
ports := make([]corev1.ContainerPort, 0, 2)
if enablePrometheus(infra) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type ResourceRender struct {
ShutdownManager *egv1a1.ShutdownManager
}

func NewResourceRender(ns string, dnsDomain string, infra *ir.ProxyInfra, gateway *egv1a1.EnvoyGateway) *ResourceRender {
func NewResourceRender(ns, dnsDomain string, infra *ir.ProxyInfra, gateway *egv1a1.EnvoyGateway) *ResourceRender {
return &ResourceRender{
Namespace: ns,
DNSDomain: dnsDomain,
Expand Down
2 changes: 1 addition & 1 deletion internal/infrastructure/kubernetes/ratelimit/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const (
)

// GetServiceURL returns the URL for the rate limit service.
func GetServiceURL(namespace string, dnsDomain string) string {
func GetServiceURL(namespace, dnsDomain string) string {
return fmt.Sprintf("grpc://%s.%s.svc.%s:%d", InfraName, namespace, dnsDomain, InfraGRPCPort)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type CLIClient interface {
PodsForSelector(namespace string, labelSelectors ...string) (*corev1.PodList, error)

// PodExec takes a command and the pod data to run the command in the specified pod.
PodExec(namespacedName types.NamespacedName, container string, command string) (stdout string, stderr string, err error)
PodExec(namespacedName types.NamespacedName, container, command string) (stdout, stderr string, err error)

// Kube returns kube client.
Kube() kubernetes.Interface
Expand Down Expand Up @@ -131,7 +131,7 @@ func (c *client) Pod(namespacedName types.NamespacedName) (*corev1.Pod, error) {
return c.kube.CoreV1().Pods(namespacedName.Namespace).Get(context.TODO(), namespacedName.Name, metav1.GetOptions{})
}

func (c *client) PodExec(namespacedName types.NamespacedName, container string, command string) (stdout string, stderr string, err error) {
func (c *client) PodExec(namespacedName types.NamespacedName, container, command string) (stdout, stderr string, err error) {
defer func() {
if err != nil {
if len(stderr) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion internal/logging/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewLogger(w io.Writer, logging *egv1a1.EnvoyGatewayLogging) Logger {
}
}

func FileLogger(file string, name string, level egv1a1.LogLevel) Logger {
func FileLogger(file, name string, level egv1a1.LogLevel) Logger {
writer, err := os.OpenFile(file, os.O_WRONLY, 0o666)
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/kubernetes/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1941,7 +1941,7 @@ func (r *gatewayAPIReconciler) processEnvoyProxy(ep *egv1a1.EnvoyProxy, resource
}

// crdExists checks for the existence of the CRD in k8s APIServer before watching it
func (r *gatewayAPIReconciler) crdExists(mgr manager.Manager, kind string, groupVersion string) bool {
func (r *gatewayAPIReconciler) crdExists(mgr manager.Manager, kind, groupVersion string) bool {
discoveryClient, err := discovery.NewDiscoveryClientForConfig(mgr.GetConfig())
if err != nil {
r.log.Error(err, "failed to create discovery client")
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/kubernetes/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
hmacSecretKey = "hmac-secret"
)

func newSecret(secretType corev1.SecretType, name string, namespace string, data map[string][]byte) corev1.Secret {
func newSecret(secretType corev1.SecretType, name, namespace string, data map[string][]byte) corev1.Secret {
return corev1.Secret{
Type: secretType,
TypeMeta: metav1.TypeMeta{
Expand Down
2 changes: 1 addition & 1 deletion internal/troubleshoot/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/envoyproxy/gateway/internal/troubleshoot/collect"
)

func CollectResult(ctx context.Context, restConfig *rest.Config, bundlePath string, egNamespace string) tbcollect.CollectorResult {
func CollectResult(ctx context.Context, restConfig *rest.Config, bundlePath, egNamespace string) tbcollect.CollectorResult {
var result tbcollect.CollectorResult

progressChan := make(chan interface{})
Expand Down
2 changes: 1 addition & 1 deletion internal/troubleshoot/collect/troubleshoot_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func getAllNamespaces(ctx context.Context, client *kubernetes.Clientset) ([]byte
return b, namespaces, nil
}

func crs(ctx context.Context, dyn dynamic.Interface, client *kubernetes.Clientset, config *rest.Config, namespaces []string, includeGroups []string) (map[string][]byte, map[string]string) {
func crs(ctx context.Context, dyn dynamic.Interface, client *kubernetes.Clientset, config *rest.Config, namespaces, includeGroups []string) (map[string][]byte, map[string]string) {
includeGroupSet := sets.New[string](includeGroups...)
errorList := make(map[string]string)
ok, err := discovery.HasResource(client, "apiextensions.k8s.io/v1", "CustomResourceDefinition")
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// Write writes data into a given filepath.
func Write(data string, filepath string) error {
func Write(data, filepath string) error {
file, err := os.OpenFile(filepath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions internal/utils/jsonpatch/jsonpathtopointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/pkg/errors"
)

func ConvertPathToPointers(jsonDoc []byte, jsonPath string, path string) ([]string, error) {
func ConvertPathToPointers(jsonDoc []byte, jsonPath, path string) ([]string, error) {
var jsonPointers []string

jObj, err := oj.Parse(jsonDoc)
Expand Down Expand Up @@ -45,7 +45,7 @@ func ConvertPathToPointers(jsonDoc []byte, jsonPath string, path string) ([]stri
return jsonPointers, nil
}

func concat(jsonPointer string, path string) string {
func concat(jsonPointer, path string) string {
if path == "" {
return jsonPointer
}
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/path/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ValidateOutputPath(outputPath string) (string, error) {
}

// ListDirsAndFiles return a list of directories and files from a list of paths recursively.
func ListDirsAndFiles(paths []string) (dirs sets.Set[string], files sets.Set[string]) {
func ListDirsAndFiles(paths []string) (dirs, files sets.Set[string]) {
dirs, files = sets.New[string](), sets.New[string]()
// Separate paths by whether is a directory or not.
paths = sets.NewString(paths...).UnsortedList()
Expand Down
4 changes: 2 additions & 2 deletions internal/wasm/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const (

// Cache models a Wasm module cache.
type Cache interface {
Get(downloadURL string, opts GetOptions) (url string, checksum string, err error)
Get(downloadURL string, opts GetOptions) (url, checksum string, err error)
Start(ctx context.Context)
}

Expand Down Expand Up @@ -171,7 +171,7 @@ func getModulePath(baseDir string, mkey moduleKey) (string, error) {
}

// Get returns path the local Wasm module file and its checksum.
func (c *localFileCache) Get(downloadURL string, opts GetOptions) (localFile string, checksum string, err error) {
func (c *localFileCache) Get(downloadURL string, opts GetOptions) (localFile, checksum string, err error) {
// If the checksum is not provided, try to extract it from the OCI image URL.
originalChecksum := opts.Checksum
if len(opts.Checksum) == 0 && strings.HasPrefix(downloadURL, ociURLPrefix) {
Expand Down
2 changes: 1 addition & 1 deletion internal/wasm/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ func TestWasmCachePolicyChangesUsingHTTP(t *testing.T) {
wantFilePath2 := generateModulePath(t, tmpDir, url2, fmt.Sprintf("%x.wasm", sha256.Sum256(binary2)))
var defaultPullPolicy PullPolicy

testWasmGet := func(downloadURL string, policy PullPolicy, resourceVersion string, wantFilePath string, wantNumRequest int) {
testWasmGet := func(downloadURL string, policy PullPolicy, resourceVersion, wantFilePath string, wantNumRequest int) {
t.Helper()
gotFilePath, _, err := cache.Get(downloadURL, GetOptions{
ResourceName: "namespace.resource",
Expand Down
2 changes: 1 addition & 1 deletion internal/wasm/httpserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// and the checksum of the Wasm module.
// EG downloads the Wasm module from its original URL, caches it locally in the
// file system, and serves it through an HTTP server.
func (s *HTTPServer) Get(originalURL string, opts GetOptions) (servingURL string, checksum string, err error) {
func (s *HTTPServer) Get(originalURL string, opts GetOptions) (servingURL, checksum string, err error) {
var (
mappingPath string
localFile string
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/bootstrap/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestApplyBootstrapConfig(t *testing.T) {
}
}

func loadData(caseName string, inOrOut string) (string, error) {
func loadData(caseName, inOrOut string) (string, error) {
filename := path.Join("testdata", "merge", fmt.Sprintf("%s.%s.yaml", caseName, inOrOut))
b, err := os.ReadFile(filename)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/translator/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func buildHTTPStatusRange(irStatuses []ir.HTTPStatus) []*xdstype.Int64Range {
return nil
}
ranges := []*xdstype.Int64Range{}
sort.Slice(irStatuses, func(i int, j int) bool {
sort.Slice(irStatuses, func(i, j int) bool {
return irStatuses[i] < irStatuses[j]
})
var start, end int64
Expand Down
4 changes: 2 additions & 2 deletions internal/xds/translator/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func processExtensionPostListenerHook(tCtx *types.ResourceVersionTable, xdsListe
} else if modifiedListener != nil {
// Use the resource table to update the listener with the modified version returned by the extension
// We're assuming that Listener names are unique.
if err := tCtx.AddOrReplaceXdsResource(resourcev3.ListenerType, modifiedListener, func(existing resourceTypes.Resource, new resourceTypes.Resource) bool {
if err := tCtx.AddOrReplaceXdsResource(resourcev3.ListenerType, modifiedListener, func(existing, new resourceTypes.Resource) bool {
oldListener := existing.(*listenerv3.Listener)
newListener := new.(*listenerv3.Listener)
if newListener == nil || oldListener == nil {
Expand Down Expand Up @@ -190,7 +190,7 @@ func processExtensionPostTranslationHook(tCtx *types.ResourceVersionTable, em *e
return nil
}

func deepCopyPtr(src interface{}, dest interface{}) error {
func deepCopyPtr(src, dest interface{}) error {
if src == nil || dest == nil {
return errors.New("cannot deep copy nil pointer")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/translator/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (t *Translator) buildRateLimitFilter(irListener *ir.HTTPListener) []*hcmv3.
}

// createRateLimitFilter creates a single rate limit filter for the given domain
func createRateLimitFilter(t *Translator, irListener *ir.HTTPListener, domain string, filterName string) *hcmv3.HttpFilter {
func createRateLimitFilter(t *Translator, irListener *ir.HTTPListener, domain, filterName string) *hcmv3.HttpFilter {
// Create a new rate limit filter configuration
rateLimitFilterProto := &ratelimitfilterv3.RateLimit{
Domain: domain,
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/translator/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func buildUpgradeConfig(trafficFeatures *ir.TrafficFeatures) []*routev3.RouteAct
return upgradeConfigs
}

func buildXdsRouteMatch(pathMatch *ir.StringMatch, headerMatches []*ir.StringMatch, queryParamMatches []*ir.StringMatch) *routev3.RouteMatch {
func buildXdsRouteMatch(pathMatch *ir.StringMatch, headerMatches, queryParamMatches []*ir.StringMatch) *routev3.RouteMatch {
outMatch := &routev3.RouteMatch{}

// Add a prefix match to '/' if no matches are specified
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/types/resourceversiontable.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (t *ResourceVersionTable) ValidateAll() error {
// AddOrReplaceXdsResource will update an existing resource of rType according to matchFunc or add as a new resource
// if none satisfy the match criteria. It will only update the first match it finds, regardless
// if multiple resources satisfy the match criteria.
func (t *ResourceVersionTable) AddOrReplaceXdsResource(rType resourcev3.Type, resource types.Resource, matchFunc func(existing types.Resource, new types.Resource) bool) error {
func (t *ResourceVersionTable) AddOrReplaceXdsResource(rType resourcev3.Type, resource types.Resource, matchFunc func(existing, new types.Resource) bool) error {
if t.XdsResources == nil || t.XdsResources[rType] == nil {
if err := t.AddXdsResource(rType, resource); err != nil {
return err
Expand Down
Loading