misc: sinceSeconds -> sinceDuration
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
This commit is contained in:
@@ -74,7 +74,7 @@ type logsFlags struct {
|
||||
fluxNamespace string
|
||||
allNamespaces bool
|
||||
sinceTime string
|
||||
sinceSeconds time.Duration
|
||||
sinceDuration time.Duration
|
||||
}
|
||||
|
||||
var logsArgs = logsFlags{
|
||||
@@ -91,7 +91,7 @@ func init() {
|
||||
logsCmd.Flags().Int64VarP(&logsArgs.tail, "tail", "", logsArgs.tail, "lines of recent log file to display")
|
||||
logsCmd.Flags().StringVarP(&logsArgs.fluxNamespace, "flux-namespace", "", rootArgs.defaults.Namespace, "the namespace where the Flux components are running")
|
||||
logsCmd.Flags().BoolVarP(&logsArgs.allNamespaces, "all-namespaces", "A", false, "displays logs for objects across all namespaces")
|
||||
logsCmd.Flags().DurationVar(&logsArgs.sinceSeconds, "since", logsArgs.sinceSeconds, "Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since-time / since may be used.")
|
||||
logsCmd.Flags().DurationVar(&logsArgs.sinceDuration, "since", logsArgs.sinceDuration, "Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since-time / since may be used.")
|
||||
logsCmd.Flags().StringVar(&logsArgs.sinceTime, "since-time", logsArgs.sinceTime, "Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used.")
|
||||
rootCmd.AddCommand(logsCmd)
|
||||
}
|
||||
@@ -129,8 +129,8 @@ func logsCmdRun(cmd *cobra.Command, args []string) error {
|
||||
logOpts.TailLines = &logsArgs.tail
|
||||
}
|
||||
|
||||
if len(logsArgs.sinceTime) > 0 && logsArgs.sinceSeconds != 0 {
|
||||
return fmt.Errorf("at most one of `sinceTime` or `sinceSeconds` may be specified")
|
||||
if len(logsArgs.sinceTime) > 0 && logsArgs.sinceDuration != 0 {
|
||||
return fmt.Errorf("at most one of `sinceTime` or `sinceDuration` may be specified")
|
||||
}
|
||||
|
||||
if len(logsArgs.sinceTime) > 0 {
|
||||
@@ -141,9 +141,9 @@ func logsCmdRun(cmd *cobra.Command, args []string) error {
|
||||
logOpts.SinceTime = &t
|
||||
}
|
||||
|
||||
if logsArgs.sinceSeconds != 0 {
|
||||
if logsArgs.sinceDuration != 0 {
|
||||
// round up to the nearest second
|
||||
sec := int64(logsArgs.sinceSeconds.Round(time.Second).Seconds())
|
||||
sec := int64(logsArgs.sinceDuration.Round(time.Second).Seconds())
|
||||
logOpts.SinceSeconds = &sec
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestLogsSinceTimeInvalid(t *testing.T) {
|
||||
func TestLogsSinceOnlyOneAllowed(t *testing.T) {
|
||||
cmd := cmdTestCase{
|
||||
args: "logs --since=2m --since-time=2021-08-06T14:26:25.546Z",
|
||||
assert: assertError("at most one of `sinceTime` or `sinceSeconds` may be specified"),
|
||||
assert: assertError("at most one of `sinceTime` or `sinceDuration` may be specified"),
|
||||
}
|
||||
cmd.runTestCmd(t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user