Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/commands/app/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func deployAction(cCtx *cli.Context) error {

// 13. Collect app profile while deployment is in progress (optional)
environment := preflightCtx.EnvironmentConfig.Name
suggestedName, err := utils.ExtractAndFindAvailableName(environment, imageRef)
suggestedName, err := utils.ExtractAndFindAvailableName(cCtx, environment, imageRef)
if err != nil {
logger.Warn("Failed to extract suggested name: %s", err.Error())
suggestedName = ""
Expand All @@ -138,6 +138,11 @@ func deployAction(cCtx *cli.Context) error {
logger.Warn("Failed to upload profile: %s", err.Error())
} else {
logger.Info("✓ Profile uploaded successfully")

// Invalidate profile cache to ensure fresh data on next command
if err := common.InvalidateProfileCache(); err != nil {
logger.Debug("Failed to invalidate profile cache: %v", err)
}
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions pkg/commands/app/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func listAction(cCtx *cli.Context) error {

func infoAction(cCtx *cli.Context) error {
// Get app address from args or interactive selection
appID, err := utils.GetAppIDInteractive(cCtx, 0, "view")
appID, err := utils.GetAppIDInteractive(cCtx, nil, 0, "view")
if err != nil {
return fmt.Errorf("failed to get app address: %w", err)
}
Expand All @@ -158,23 +158,22 @@ func logsAction(cCtx *cli.Context) error {
fmt.Println()
logger := common.LoggerFromContext(cCtx)

appID, err := utils.GetAppIDInteractive(cCtx, 0, "view logs for")
resolver, err := utils.NewAppResolver(cCtx)
if err != nil {
return fmt.Errorf("failed to get app address: %w", err)
return fmt.Errorf("failed to create app resolver: %w", err)
}

environmentConfig, err := utils.GetEnvironmentConfig(cCtx)
appID, err := utils.GetAppIDInteractive(cCtx, resolver, 0, "view logs for")
if err != nil {
return fmt.Errorf("failed to get environment config: %w", err)
return fmt.Errorf("failed to get app address: %w", err)
}

userApiClient, err := utils.NewUserApiClient(cCtx)
if err != nil {
return fmt.Errorf("failed to create API client: %w", err)
}

profileName := utils.GetAppProfileName(cCtx, appID)
formattedApp := common.FormatAppDisplay(environmentConfig.Name, appID, profileName)
formattedApp := resolver.FormatAppDisplay(appID)

logs, err := userApiClient.GetLogs(cCtx, appID)
watchMode := cCtx.Bool(common.WatchFlag.Name)
Expand Down
15 changes: 6 additions & 9 deletions pkg/commands/app/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ func startAction(cCtx *cli.Context) error {
}

// Get app address from args or interactive selection
appID, err := utils.GetAppIDInteractive(cCtx, 0, "start")
appID, err := utils.GetAppIDInteractive(cCtx, preflightCtx.Resolver, 0, "start")
if err != nil {
return fmt.Errorf("failed to get app address: %w", err)
}

profileName := utils.GetAppProfileName(cCtx, appID)
formattedApp := common.FormatAppDisplay(preflightCtx.EnvironmentConfig.Name, appID, profileName)
formattedApp := preflightCtx.Resolver.FormatAppDisplay(appID)

// Call AppController.StartApp
err = preflightCtx.Caller.StartApp(ctx, appID)
Expand Down Expand Up @@ -90,13 +89,12 @@ func stopAction(cCtx *cli.Context) error {
}

// Get app address from args or interactive selection
appID, err := utils.GetAppIDInteractive(cCtx, 0, "stop")
appID, err := utils.GetAppIDInteractive(cCtx, preflightCtx.Resolver, 0, "stop")
if err != nil {
return fmt.Errorf("failed to get app address: %w", err)
}

profileName := utils.GetAppProfileName(cCtx, appID)
formattedApp := common.FormatAppDisplay(preflightCtx.EnvironmentConfig.Name, appID, profileName)
formattedApp := preflightCtx.Resolver.FormatAppDisplay(appID)

// Call AppController.StopApp
err = preflightCtx.Caller.StopApp(ctx, appID)
Expand Down Expand Up @@ -124,7 +122,7 @@ func terminateAction(cCtx *cli.Context) error {
}

// Get app address from args or interactive selection
appID, err := utils.GetAppIDInteractive(cCtx, 0, "terminate")
appID, err := utils.GetAppIDInteractive(cCtx, preflightCtx.Resolver, 0, "terminate")
if err != nil {
return fmt.Errorf("failed to get app address: %w", err)
}
Expand All @@ -139,8 +137,7 @@ func terminateAction(cCtx *cli.Context) error {
return err
}

profileName := utils.GetAppProfileName(cCtx, appID)
logger.Info("App %s terminated successfully", common.FormatAppDisplay(preflightCtx.EnvironmentConfig.Name, appID, profileName))
logger.Info("App %s terminated successfully", preflightCtx.Resolver.FormatAppDisplay(appID))

return utils.GetAndPrintAppInfo(cCtx, appID, common.AppStatusTerminating)
}
72 changes: 0 additions & 72 deletions pkg/commands/app/name.go

This file was deleted.

7 changes: 6 additions & 1 deletion pkg/commands/app/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func profileSetAction(cCtx *cli.Context) error {
logger := common.LoggerFromContext(cCtx)

// Get app ID
appID, err := utils.GetAppIDInteractive(cCtx, 0, "set profile for")
appID, err := utils.GetAppIDInteractive(cCtx, nil, 0, "set profile for")
if err != nil {
return err
}
Expand All @@ -61,6 +61,11 @@ func profileSetAction(cCtx *cli.Context) error {
return fmt.Errorf("failed to upload profile: %w", err)
}

// Invalidate profile cache to ensure fresh data on next command
if err := common.InvalidateProfileCache(); err != nil {
logger.Debug("Failed to invalidate profile cache: %v", err)
}

// Display success message with returned data
logger.Info("✓ Profile updated successfully for app '%s'", response.Name)

Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func upgradeAction(cCtx *cli.Context) error {
}

// 3. Get app ID from args or interactive selection
appID, err := utils.GetAppIDInteractive(cCtx, 0, "upgrade")
appID, err := utils.GetAppIDInteractive(cCtx, preflightCtx.Resolver, 0, "upgrade")
if err != nil {
return fmt.Errorf("failed to get app id: %w", err)
}
Expand Down
Loading
Loading