Skip to content

Commit

Permalink
newClientOpts.AppName is always set in every call path
Browse files Browse the repository at this point in the history
  • Loading branch information
haileys committed May 9, 2023
1 parent 4e0848a commit 59bea5e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions flaps/flaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,14 @@ type newClientOpts struct {

func newWithOptions(ctx context.Context, opts newClientOpts) (*Client, error) {
app := opts.AppCompact
appName := opts.AppName
if app != nil {
appName = app.Name
}
// FIXME: do this once we setup config for `fly config ...` commands, and then use cfg.FlapsBaseURL below
// cfg := config.FromContext(ctx)
var err error
flapsBaseURL := os.Getenv("FLY_FLAPS_BASE_URL")
if strings.TrimSpace(strings.ToLower(flapsBaseURL)) == "peer" {
app, err = resolveApp(ctx, app, appName)
app, err = resolveApp(ctx, app, opts.AppName)
if err != nil {
return nil, fmt.Errorf("failed to get app '%s': %w", appName, err)
return nil, fmt.Errorf("failed to get app '%s': %w", opts.AppName, err)
}
return newWithUsermodeWireguard(ctx, wireguardConnectionParams{
appName: opts.AppName,
Expand All @@ -90,7 +86,7 @@ func newWithOptions(ctx context.Context, opts newClientOpts) (*Client, error) {
return nil, fmt.Errorf("flaps: can't setup HTTP client to %s: %w", flapsUrl.String(), err)
}
return &Client{
appName: appName,
appName: opts.AppName,
baseUrl: flapsUrl,
authToken: flyctl.GetAPIToken(),
httpClient: httpClient,
Expand Down

0 comments on commit 59bea5e

Please sign in to comment.