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
8 changes: 4 additions & 4 deletions internal/pkg/cli/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const (
envFlagShort = "e"
typeFlagShort = "t"
workloadFlagShort = "w"
// previousFlagShort = "p"
previousFlagShort = "p"

dockerFileFlagShort = "d"
commandFlagShort = "c"
Expand Down Expand Up @@ -233,9 +233,9 @@ Uploaded asset locations are filled in the template configuration.`
unless any time filtering flags are set.`
lastFlagDescription = `Optional. The number of executions of the scheduled job for which
logs should be shown.`
followFlagDescription = "Optional. Specifies if the logs should be streamed."
// previousFlagDescription = "Optional. Print logs for the last stopped task if exists."
sinceFlagDescription = `Optional. Only return logs newer than a relative duration like 5s, 2m, or 3h.
followFlagDescription = "Optional. Specifies if the logs should be streamed."
previousFlagDescription = "Optional. Print logs for the last stopped task if exists."
sinceFlagDescription = `Optional. Only return logs newer than a relative duration like 5s, 2m, or 3h.
Defaults to all logs. Only one of start-time / since may be used.`
startTimeFlagDescription = `Optional. Only return logs after a specific date (RFC3339).
Defaults to all logs. Only one of start-time / since may be used.`
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/cli/svc_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func (o *svcLogsOpts) Execute() error {
return err
}
o.taskIDs = []string{taskID}
log.Infoln("previously stopped task:", taskID)
}
err := o.logsSvc.WriteLogEvents(logging.WriteLogEventsOpts{
Follow: o.follow,
Expand Down Expand Up @@ -366,7 +367,7 @@ func buildSvcLogsCmd() *cobra.Command {
cmd.Flags().IntVar(&vars.limit, limitFlag, 0, limitFlagDescription)
cmd.Flags().StringSliceVar(&vars.taskIDs, tasksFlag, nil, tasksLogsFlagDescription)
cmd.Flags().StringVar(&vars.logGroup, logGroupFlag, "", logGroupFlagDescription)
// cmd.Flags().BoolVarP(&vars.previous, previousFlag, previousFlagShort, false, previousFlagDescription)
cmd.Flags().BoolVarP(&vars.previous, previousFlag, previousFlagShort, false, previousFlagDescription)
// cmd.Flags().StringVar(&vars.containerName, containerLogFlag, "", containerLogFlagDescription)
return cmd
}
12 changes: 12 additions & 0 deletions internal/pkg/cli/svc_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func TestSvcLogs_Validate(t *testing.T) {
inputStartTime string
inputEndTime string
inputSince time.Duration
inputPrevious bool
inputTaskIDs []string

mockstore func(m *mocks.Mockstore)

Expand Down Expand Up @@ -107,6 +109,14 @@ func TestSvcLogs_Validate(t *testing.T) {

wantedError: fmt.Errorf("--limit 10001 is out-of-bounds, value must be between 1 and 10000"),
},
"returns error if both previous and tasks flags are defined": {
Comment thread
huanjani marked this conversation as resolved.
inputPrevious: true,
inputTaskIDs: []string{"taskId"},

mockstore: func(m *mocks.Mockstore) {},

wantedError: fmt.Errorf("cannot specify both --previous and --tasks"),
},
}

for name, tc := range testCases {
Expand All @@ -128,7 +138,9 @@ func TestSvcLogs_Validate(t *testing.T) {
since: tc.inputSince,
name: tc.inputSvc,
appName: tc.inputApp,
taskIDs: tc.inputTaskIDs,
},
previous: tc.inputPrevious,
},
wkldLogOpts: wkldLogOpts{
configStore: mockstore,
Expand Down