Skip to content

Commit

Permalink
Fix #1599: running fly deploy when app has not been deployed uses sam…
Browse files Browse the repository at this point in the history
…e logic as fly launch for picking the v1 vs. v2 platform
  • Loading branch information
tvdfly authored and dangra committed Jan 25, 2023
1 parent 7696d3e commit be04703
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/command/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ type DeployWithConfigArgs struct {
ForceMachines bool
ForceNomad bool
ForceYes bool
Launching bool
Launching bool // FIXME: drop this and the other stuff that uses it once https://github.com/superfly/flyctl/pull/1602 is merged
}

func DeployWithConfig(ctx context.Context, appConfig *app.Config, args DeployWithConfigArgs) (err error) {
apiClient := client.FromContext(ctx).API()
appNameFromContext := app.NameFromContext(ctx)
appBasic, err := apiClient.GetAppBasic(ctx, appNameFromContext)
appCompact, err := apiClient.GetAppCompact(ctx, appNameFromContext)
if err != nil {
return err
}
deployToMachines, err := useMachines(ctx, *appConfig, appBasic, args)
deployToMachines, err := useMachines(ctx, *appConfig, appCompact, args)
if err != nil {
return err
}
Expand Down Expand Up @@ -230,16 +230,15 @@ func DeployWithConfig(ctx context.Context, appConfig *app.Config, args DeployWit
return err
}

func useMachines(ctx context.Context, appConfig app.Config, appBasic *api.AppBasic, args DeployWithConfigArgs) (bool, error) {
func useMachines(ctx context.Context, appConfig app.Config, appCompact *api.AppCompact, args DeployWithConfigArgs) (bool, error) {
if args.ForceNomad {
return false, nil
}
if args.ForceMachines {
return true, nil
}
// if we are not in launch scenario, use the existing platform set on the app
if !args.Launching {
return appBasic.PlatformVersion == app.MachinesPlatform, nil
if appCompact.Deployed {
return appCompact.PlatformVersion == app.MachinesPlatform, nil
}
// statics are not supported in Apps v2 yet
if len(appConfig.Statics) > 0 {
Expand All @@ -254,8 +253,9 @@ func useMachines(ctx context.Context, appConfig app.Config, appBasic *api.AppBas
if willUseStatics {
return false, nil
}
// if running automated, stay on nomad platform for now
case prompt.IsNonInteractive(err):
return false, prompt.NonInteractiveError("not running interactively, use --auto-confirm flag to confirm")
return false, nil
default:
return false, err
}
Expand Down

0 comments on commit be04703

Please sign in to comment.