nixpkgs/pkgs/by-name/po/pomerium/0001-envoy-allow-specification-of-external-binary.patch
2025-04-08 21:17:43 -05:00

67 lines
1.7 KiB
Diff

From dfb6e2797e7c9166c8dd3dc0d87a4d91474244c7 Mon Sep 17 00:00:00 2001
From: Morgan Helton <mhelton@gmail.com>
Date: Sun, 26 May 2024 12:17:01 -0500
Subject: [PATCH] envoy: allow specification of external binary
---
pkg/envoy/envoy.go | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/pkg/envoy/envoy.go b/pkg/envoy/envoy.go
index 8224f364..bb8b6506 100644
--- a/pkg/envoy/envoy.go
+++ b/pkg/envoy/envoy.go
@@ -8,9 +8,9 @@ import (
"errors"
"fmt"
"io"
+ "io/fs"
"os"
"os/exec"
- "path"
"path/filepath"
"regexp"
"strconv"
@@ -35,8 +35,17 @@ import (
const (
configFileName = "envoy-config.yaml"
+ workingDirectoryName = ".pomerium-envoy"
+ embeddedEnvoyPermissions fs.FileMode = 0o700
)
+var OverrideEnvoyPath = ""
+
+type serverOptions struct {
+ services string
+ logLevel config.LogLevel
+}
+
// A Server is a pomerium proxy implemented via envoy.
type Server struct {
ServerOptions
@@ -94,14 +103,17 @@ func NewServer(ctx context.Context, src config.Source, builder *envoyconfig.Buil
log.Ctx(ctx).Debug().Err(err).Msg("couldn't preserve RLIMIT_NOFILE before starting Envoy")
}
- envoyPath, err := Extract()
+ envoyPath := OverrideEnvoyPath
+ wd := filepath.Join(os.TempDir(), workingDirectoryName)
+
+ err := os.MkdirAll(wd, embeddedEnvoyPermissions)
if err != nil {
- return nil, fmt.Errorf("extracting envoy: %w", err)
+ return nil, fmt.Errorf("error creating temporary working directory for envoy: %w", err)
}
srv := &Server{
ServerOptions: options,
- wd: path.Dir(envoyPath),
+ wd: wd,
builder: builder,
grpcPort: src.GetConfig().GRPCPort,
httpPort: src.GetConfig().HTTPPort,
--
2.48.1