mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 10:21:05 +02:00
core/envoy: add mode to download only the current binary (#5149)
This commit is contained in:
parent
815353ab67
commit
d9c6afc168
1 changed files with 46 additions and 14 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
@ -13,25 +14,42 @@ import (
|
||||||
"github.com/pomerium/pomerium/internal/log"
|
"github.com/pomerium/pomerium/internal/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
var (
|
||||||
ctx := context.Background()
|
envoyVersion = "1.30.2"
|
||||||
err := run(ctx)
|
targets = []string{
|
||||||
if err != nil {
|
|
||||||
log.Fatal().Err(err).Send()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func run(
|
|
||||||
ctx context.Context,
|
|
||||||
) error {
|
|
||||||
envoyVersion := "1.30.2"
|
|
||||||
targets := []string{
|
|
||||||
"darwin-amd64",
|
"darwin-amd64",
|
||||||
"darwin-arm64",
|
"darwin-arm64",
|
||||||
"linux-amd64",
|
"linux-amd64",
|
||||||
"linux-arm64",
|
"linux-arm64",
|
||||||
}
|
}
|
||||||
baseURL := "https://github.com/pomerium/envoy-binaries/releases/download/v" + envoyVersion
|
baseURL = "https://github.com/pomerium/envoy-binaries/releases/download/v" + envoyVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
ctx := context.Background()
|
||||||
|
err := run(ctx, os.Args)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal().Err(err).Send()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func run(ctx context.Context, args []string) error {
|
||||||
|
mode := "all"
|
||||||
|
if len(args) > 1 {
|
||||||
|
mode = args[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
switch mode {
|
||||||
|
case "all":
|
||||||
|
return runAll(ctx)
|
||||||
|
case "current":
|
||||||
|
return runCurrent(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("unknown mode: %s", mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runAll(ctx context.Context) error {
|
||||||
eg, ctx := errgroup.WithContext(ctx)
|
eg, ctx := errgroup.WithContext(ctx)
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
target := target
|
target := target
|
||||||
|
@ -48,6 +66,20 @@ func run(
|
||||||
return eg.Wait()
|
return eg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runCurrent(ctx context.Context) error {
|
||||||
|
err := download(ctx, "./envoy", baseURL+"/envoy-"+runtime.GOOS+"-"+runtime.GOARCH)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.Chmod("./envoy", 0o755)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func download(
|
func download(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
dstPath string,
|
dstPath string,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue