Skip to content

Commit

Permalink
use the closest region to the user, if it's not set
Browse files Browse the repository at this point in the history
  • Loading branch information
billyb2 committed Aug 28, 2024
1 parent 18a2a08 commit 60b788a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions internal/build/imgsrc/depot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/build/imgsrc/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 60b788a

Please sign in to comment.