refactor: remove internal/logger from platform run#378
Conversation
…, delete, and uninstall
# Conflicts: # cmd/project/create.go # cmd/project/create_test.go # internal/pkg/apps/install.go # internal/pkg/platform/localserver.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #378 +/- ##
==========================================
+ Coverage 65.27% 65.43% +0.16%
==========================================
Files 216 216
Lines 17994 17937 -57
==========================================
- Hits 11745 11737 -8
+ Misses 5160 5112 -48
+ Partials 1089 1088 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mwbrooks
left a comment
There was a problem hiding this comment.
Some comments to connect the dots for the reviewers 🗺️ 📍
| // OnEvent | ||
| func(event *logger.LogEvent) { | ||
| switch event.Name { | ||
| case "on_update_app_install": |
There was a problem hiding this comment.
note: This event was never used, disappointingly 😢
| `Updating local app install for "%s"`, | ||
| event.DataToString("teamName"), | ||
| ))) | ||
| case "on_cloud_run_connection_connected": |
| case "on_cloud_run_connection_connected": | ||
| clients.IO.PrintTrace(ctx, slacktrace.PlatformRunReady) | ||
| cmd.Println(style.Secondary("Connected, awaiting events")) | ||
| case "on_cloud_run_connection_message": |
| case "on_cloud_run_connection_message": | ||
| message := event.DataToString("cloud_run_connection_message") | ||
| clients.IO.PrintDebug(ctx, "received: %s", message) | ||
| case "on_cloud_run_connection_command_error": |
| case "on_cloud_run_connection_command_error": | ||
| message := event.DataToString("cloud_run_connection_command_error") | ||
| clients.IO.PrintError(ctx, "Error: %s", message) | ||
| case "on_cloud_run_watch_error": |
There was a problem hiding this comment.
note: Moved to 3 places
| cmd.Println(style.Secondary(fmt.Sprintf("Manifest change detected: %s, reinstalling app...", path))) | ||
| case "on_cloud_run_watch_manifest_change_reinstalled": | ||
| cmd.Println(style.Secondary("App successfully reinstalled")) | ||
| case "on_cloud_run_watch_manifest_change_skipped_remote": |
| case "on_cloud_run_watch_manifest_change_skipped_remote": | ||
| path := event.DataToString("cloud_run_watch_manifest_change_skipped") | ||
| cmd.Println(style.Secondary(fmt.Sprintf("Manifest change detected: %s, skipped reinstalling app because manifest.source=remote", path))) | ||
| case "on_cloud_run_watch_app_change": |
| case "on_cloud_run_watch_app_change": | ||
| path := event.DataToString("cloud_run_watch_app_change") | ||
| cmd.Println(style.Secondary(fmt.Sprintf("App change detected: %s, restarting server...", path))) | ||
| case "on_cleanup_app_install_done": |
| `Cleaned up local app install for "%s".`, | ||
| event.DataToString("teamName"), | ||
| ))) | ||
| case "on_cleanup_app_install_failed": |
| ))) | ||
| message := event.DataToString("on_cleanup_app_install_error") | ||
| clients.IO.PrintWarning(ctx, "Local app cleanup failed: %s", message) | ||
| case "on_abort_cleanup_app_install": |
| r.log.Data["cloud_run_watch_app_change"] = event.Path | ||
| r.log.Info("on_cloud_run_watch_app_change") | ||
| r.clients.IO.PrintInfo(ctx, false, "%s", style.Secondary(fmt.Sprintf("App change detected: %s, restarting server...", event.Path))) |
There was a problem hiding this comment.
⭐ praise: Inlining variables with outputs makes this more simple to reason about! We've talked about styling within pkg but I remain optimistic for this surfacing within perhaps cmd in the future!
There was a problem hiding this comment.
Agreed on both points! Some of these outputs are complex and passing the variables through another layer has led to a number of issues - some of which we're just noticing as we flatten it!
internal/pkg is serving it's purpose well - as a shameful reminder that it must go away. I agree that moving more into cmd/ seems to be the right choice.
| func deleteAppOnTerminate(ctx context.Context, clients *shared.ClientFactory, auth types.SlackAuth, app types.App, teamName string) { | ||
| clients.IO.PrintDebug(ctx, "Removing the local version of this app from the workspace") | ||
| _, _, err := apps.Delete(ctx, clients, app.TeamDomain, app, auth) | ||
| if err != nil { | ||
| log.Data["on_cleanup_app_install_error"] = err.Error() | ||
| log.Info("on_cleanup_app_install_failed") | ||
| clients.IO.PrintInfo(ctx, false, "%s", style.Secondary(fmt.Sprintf(`Cleaning up local app install for "%s" failed.`, teamName))) | ||
| clients.IO.PrintWarning(ctx, "Local app cleanup failed: %s", err) | ||
| } else { | ||
| clients.IO.PrintInfo(ctx, false, "%s", style.Secondary(fmt.Sprintf(`Cleaned up local app install for "%s".`, teamName))) | ||
| } | ||
| log.Info("on_cleanup_app_install_done") | ||
| } |
There was a problem hiding this comment.
💡 thought(non-blocking): Using a familiar iostreams package for these outputs might make this inlined logic more simple to test also! Thanks so much for finding these changes 🎁
| variables, err := clients.Config.GetDotEnvFileVariables() | ||
| if err != nil { | ||
| return nil, "", slackerror.Wrap(err, slackerror.ErrLocalAppRun). | ||
| return "", slackerror.Wrap(err, slackerror.ErrLocalAppRun). |
There was a problem hiding this comment.
🎆 praise: Wrapping errors is a most exciting pattern we should continue to support!
| break | ||
| } | ||
|
|
||
| r.log.Info("on_cloud_run_connection_command_output") |
There was a problem hiding this comment.
🪬 note: I don't believe this log was output either!
🗣️ ramble: Inlining these outputs makes me so much more confident that we're outputting messages we expect more often. I saw in #367 that the run command now shows details on app installation progress. These are such appreciated changes.
There was a problem hiding this comment.
I saw in #367 that the run command now shows details on app installation progress. These are such appreciated changes.
Heh, I just noticed that while testing this PR as well. I had to go back to our latest production release to double-check that I wasn't crazy 🤪
|
@zimeg Thanks for much for the review, again! 🙇🏻 Only one more PR left! 🤞🏻 |
Changelog
Summary
This pull request is Part 4 of removing
internal/loggerpackage and is focused on the theruncommand.Test Steps
Requirements