4040 appInteractive bool
4141 appContainerName string
4242 appTag string
43+ deploymentTarget string
4344 appCpuMilli int
4445 appMemoryMi int
4546 jobName string
@@ -58,6 +59,14 @@ func registerCommand_App(cliConf config.CLIConfig) *cobra.Command {
5859 Short : "Runs a command for your application." ,
5960 }
6061
62+ appCmd .PersistentFlags ().StringVarP (
63+ & deploymentTarget ,
64+ "target" ,
65+ "x" ,
66+ "default" ,
67+ "the deployment target for the app, default is \" default\" " ,
68+ )
69+
6170 // appRunCmd represents the "porter app run" subcommand
6271 appRunCmd := & cobra.Command {
6372 Use : "run [application] -- COMMAND [args...]" ,
@@ -238,7 +247,7 @@ func appRun(ctx context.Context, _ *types.GetAuthenticatedUserResponse, client a
238247 // updated exec args includes launcher command prepended if needed, otherwise it is the same as execArgs
239248 var updatedExecArgs []string
240249 if project .ValidateApplyV2 {
241- podsSimple , updatedExecArgs , namespace , err = getPodsFromV2PorterYaml (ctx , execArgs , client , cliConfig , args [0 ])
250+ podsSimple , updatedExecArgs , namespace , err = getPodsFromV2PorterYaml (ctx , execArgs , client , cliConfig , args [0 ], deploymentTarget )
242251 if err != nil {
243252 return err
244253 }
@@ -553,23 +562,12 @@ func appGetPodsV1PorterYaml(ctx context.Context, cliConfig config.CLIConfig, cli
553562 return res , containerHasLauncherStartCommand , nil
554563}
555564
556- func appGetPodsV2PorterYaml (ctx context.Context , cliConfig config.CLIConfig , client api.Client , porterAppName string ) ([]appPodSimple , string , bool , error ) {
565+ func appGetPodsV2PorterYaml (ctx context.Context , cliConfig config.CLIConfig , client api.Client , porterAppName string , deploymentTargetName string ) ([]appPodSimple , string , bool , error ) {
557566 pID := cliConfig .Project
558567 cID := cliConfig .Cluster
559568 var containerHasLauncherStartCommand bool
560569
561- targetResp , err := client .DefaultDeploymentTarget (ctx , pID , cID )
562- if err != nil {
563- return nil , "" , containerHasLauncherStartCommand , fmt .Errorf ("error calling default deployment target endpoint: %w" , err )
564- }
565-
566- if targetResp .DeploymentTargetID == "" {
567- return nil , "" , containerHasLauncherStartCommand , errors .New ("deployment target id is empty" )
568- }
569-
570- resp , err := client .PorterYamlV2Pods (ctx , pID , cID , porterAppName , & types.PorterYamlV2PodsRequest {
571- DeploymentTargetID : targetResp .DeploymentTargetID ,
572- })
570+ resp , err := client .PorterYamlV2Pods (ctx , pID , cID , porterAppName , deploymentTargetName )
573571 if err != nil {
574572 return nil , "" , containerHasLauncherStartCommand , err
575573 }
@@ -1215,7 +1213,7 @@ func appUpdateTag(ctx context.Context, user *types.GetAuthenticatedUserResponse,
12151213 }
12161214
12171215 if project .ValidateApplyV2 {
1218- tag , err := v2 .UpdateImage (ctx , appTag , client , cliConf .Project , cliConf .Cluster , args [0 ])
1216+ tag , err := v2 .UpdateImage (ctx , appTag , client , cliConf .Project , cliConf .Cluster , args [0 ], deploymentTarget )
12191217 if err != nil {
12201218 return fmt .Errorf ("error updating tag: %w" , err )
12211219 }
@@ -1276,8 +1274,8 @@ func getPodsFromV1PorterYaml(ctx context.Context, execArgs []string, client api.
12761274 return podsSimple , execArgs , nil
12771275}
12781276
1279- func getPodsFromV2PorterYaml (ctx context.Context , execArgs []string , client api.Client , cliConfig config.CLIConfig , porterAppName string ) ([]appPodSimple , []string , string , error ) {
1280- podsSimple , namespace , containerHasLauncherStartCommand , err := appGetPodsV2PorterYaml (ctx , cliConfig , client , porterAppName )
1277+ func getPodsFromV2PorterYaml (ctx context.Context , execArgs []string , client api.Client , cliConfig config.CLIConfig , porterAppName string , deploymentTargetName string ) ([]appPodSimple , []string , string , error ) {
1278+ podsSimple , namespace , containerHasLauncherStartCommand , err := appGetPodsV2PorterYaml (ctx , cliConfig , client , porterAppName , deploymentTargetName )
12811279 if err != nil {
12821280 return nil , nil , "" , fmt .Errorf ("could not retrieve list of pods: %w" , err )
12831281 }
0 commit comments