Skip to content

Commit

Permalink
changed protobuf and exposed flag to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrisyhjiang committed Jun 25, 2024
1 parent 96e3e74 commit a367e00
Show file tree
Hide file tree
Showing 4 changed files with 370 additions and 332 deletions.
4 changes: 3 additions & 1 deletion src/cmd/cli/command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func SetupCommands(version string) {
tailCmd.Flags().BoolP("raw", "r", false, "show raw (unparsed) logs")
tailCmd.Flags().StringP("since", "S", "", "show logs since duration/time")
tailCmd.Flags().Bool("utc", false, "show logs in UTC timezone (ie. TZ=UTC)")
tailCmd.Flags().String("job", "", "shows logs filtered by jobs") // Add the job flag definition
RootCmd.AddCommand(tailCmd)

// Delete Command
Expand Down Expand Up @@ -631,6 +632,7 @@ var tailCmd = &cobra.Command{
var raw, _ = cmd.Flags().GetBool("raw")
var since, _ = cmd.Flags().GetString("since")
var utc, _ = cmd.Flags().GetBool("utc")
var job, _ = cmd.Flags().GetString("job") // Ensure the flag is defined with usage string

if utc {
os.Setenv("TZ", "") // used by Go's "time" package, see https://pkg.go.dev/time#Location
Expand All @@ -656,8 +658,8 @@ var tailCmd = &cobra.Command{
Etag: etag,
Since: ts,
Raw: raw,
Job: job,
}

return cli.Tail(cmd.Context(), client, tailOptions)
},
}
Expand Down
8 changes: 7 additions & 1 deletion src/pkg/cli/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type TailOptions struct {
Etag types.ETag
Since time.Time
Raw bool
Job string // Updated to singular form to match usage
EndEventDetectFunc TailDetectStopEventFunc
}

Expand Down Expand Up @@ -172,7 +173,12 @@ func Tail(ctx context.Context, client client.Client, params TailOptions) error {
} else {
since = timestamppb.New(params.Since)
}
serverStream, err := client.Tail(ctx, &defangv1.TailRequest{Services: params.Services, Etag: params.Etag, Since: since})
serverStream, err := client.Tail(ctx, &defangv1.TailRequest{
Services: params.Services,
Etag: params.Etag,
Since: since,
Job: params.Job, // Pass the Jobs parameter
})
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit a367e00

Please sign in to comment.