You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- mesa-description-start -->
## TL;DR
This PR enhances the `deploy` command by adding `logs` and `history`
subcommands, providing users with better tools to monitor and debug
deployments.
## Why we made these changes
The `deploy` command previously lacked built-in ways to easily access
deployment logs or view past deployment history. This change makes the
CLI more powerful and user-friendly by providing direct access to
critical deployment information, improving the overall developer
experience.
## What changed?
- **`cmd/deploy.go`**:
- Added a `deploy logs` subcommand to stream logs, with flags for
following (`-f`), specifying a time range (`--since`), and showing
timestamps.
- Added a `deploy history` subcommand to display a table of past
deployments.
- Improved error messages to include the Deployment ID and a direct
command to view logs on failure.
- **`cmd/root.go`**:
- Refactored the authentication exemption logic to correctly exempt the
root command when it's called without any subcommands.
<sup>_Description generated by Mesa. [Update
settings](https://app.mesa.dev/onkernel/settings/pull-requests)_</sup>
<!-- mesa-description-end -->
Copy file name to clipboardExpand all lines: cmd/deploy.go
+165-2Lines changed: 165 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,20 @@ import (
15
15
"github.com/spf13/cobra"
16
16
)
17
17
18
+
vardeployLogsCmd=&cobra.Command{
19
+
Use: "logs <deployment_id>",
20
+
Short: "Stream logs for a deployment",
21
+
Args: cobra.ExactArgs(1),
22
+
RunE: runDeployLogs,
23
+
}
24
+
25
+
vardeployHistoryCmd=&cobra.Command{
26
+
Use: "history [app_name]",
27
+
Short: "Show deployment history",
28
+
Args: cobra.RangeArgs(0, 1),
29
+
RunE: runDeployHistory,
30
+
}
31
+
18
32
vardeployCmd=&cobra.Command{
19
33
Use: "deploy <entrypoint>",
20
34
Short: "Deploy a Kernel application",
@@ -27,6 +41,15 @@ func init() {
27
41
deployCmd.Flags().Bool("force", false, "Allow overwrite of an existing version with the same name")
28
42
deployCmd.Flags().StringArrayP("env", "e", []string{}, "Set environment variables (e.g., KEY=value). May be specified multiple times")
29
43
deployCmd.Flags().StringArray("env-file", []string{}, "Read environment variables from a file (.env format). May be specified multiple times")
44
+
45
+
// Subcommands under deploy
46
+
deployLogsCmd.Flags().BoolP("follow", "f", false, "Follow logs in real-time (stream continuously)")
47
+
deployLogsCmd.Flags().StringP("since", "s", "", "How far back to retrieve logs. Supports duration formats: ns, us, ms, s, m, h (e.g., 5m, 2h, 1h30m). Note: 'd' not supported; use hours instead. Can also specify timestamps: 2006-01-02, 2006-01-02T15:04, 2006-01-02T15:04:05, 2006-01-02T15:04:05.000. Max lookback ~167h.")
48
+
deployLogsCmd.Flags().BoolP("with-timestamps", "t", false, "Include timestamps in each log line")
49
+
deployCmd.AddCommand(deployLogsCmd)
50
+
51
+
deployHistoryCmd.Flags().Bool("all", false, "Show deployment history for all applications")
0 commit comments