From 60b788a37d7aed0d851c37973f02bfdb5cf006fd Mon Sep 17 00:00:00 2001 From: William Batista Date: Wed, 28 Aug 2024 18:04:45 -0400 Subject: [PATCH] use the closest region to the user, if it's not set --- internal/build/imgsrc/depot.go | 7 +++++++ internal/build/imgsrc/resolver.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/build/imgsrc/depot.go b/internal/build/imgsrc/depot.go index 0ad2248a06..a91201c203 100644 --- a/internal/build/imgsrc/depot.go +++ b/internal/build/imgsrc/depot.go @@ -181,6 +181,13 @@ func initBuilder(ctx context.Context, buildState *build, appName string, streams region = regionEnv } + if region == "" { + closestRegion, err := apiClient.GetNearestRegion(ctx) + if err == nil { + region = closestRegion.Code + } + } + if region != "" { region = "fly-" + region } diff --git a/internal/build/imgsrc/resolver.go b/internal/build/imgsrc/resolver.go index db04711fdd..a8b5478df0 100644 --- a/internal/build/imgsrc/resolver.go +++ b/internal/build/imgsrc/resolver.go @@ -242,7 +242,7 @@ func (r *Resolver) BuildImage(ctx context.Context, streams *iostreams.IOStreams, return nil, fmt.Errorf("invalid depot-scope value. must be 'org' or 'app'") } - builderSize := flag.GetString(ctx, "depot-builder-size") + builderSize := flag.GetInt(ctx, "depot-builder-size") region := flag.GetString(ctx, "depot-builder-region") update := flag.GetBool(ctx, "depot-builder-update")