summaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-08-26 10:12:09 -0400
committerGitHub <noreply@github.com>2021-08-26 10:12:09 -0400
commit54e0afffe7dd8e5ab7daa75de2f06331cd78dd48 (patch)
tree9eda4d0f39327c2e777aa1faa600968c7963ab9e /pkg/util
parentcb235592702550c94bdc526a033ca2cebecb7337 (diff)
parentd06d285e66251784126b4f19e047c2a93182d08e (diff)
downloadpodman-54e0afffe7dd8e5ab7daa75de2f06331cd78dd48.tar.gz
podman-54e0afffe7dd8e5ab7daa75de2f06331cd78dd48.tar.bz2
podman-54e0afffe7dd8e5ab7daa75de2f06331cd78dd48.zip
Merge pull request #11218 from cdoern/untilBug
logFile until flag issue, negative duration replaced with positive
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/utils.go7
-rw-r--r--pkg/util/utils_test.go2
2 files changed, 6 insertions, 3 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index 63fad0286..208d815d9 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -520,7 +520,7 @@ func WriteStorageConfigFile(storageOpts *stypes.StoreOptions, storageConf string
// ParseInputTime takes the users input and to determine if it is valid and
// returns a time format and error. The input is compared to known time formats
// or a duration which implies no-duration
-func ParseInputTime(inputTime string) (time.Time, error) {
+func ParseInputTime(inputTime string, since bool) (time.Time, error) {
timeFormats := []string{time.RFC3339Nano, time.RFC3339, "2006-01-02T15:04:05", "2006-01-02T15:04:05.999999999",
"2006-01-02Z07:00", "2006-01-02"}
// iterate the supported time formats
@@ -542,7 +542,10 @@ func ParseInputTime(inputTime string) (time.Time, error) {
if err != nil {
return time.Time{}, errors.Errorf("unable to interpret time value")
}
- return time.Now().Add(-duration), nil
+ if since {
+ return time.Now().Add(-duration), nil
+ }
+ return time.Now().Add(duration), nil
}
// OpenExclusiveFile opens a file for writing and ensure it doesn't already exist
diff --git a/pkg/util/utils_test.go b/pkg/util/utils_test.go
index 62de7509f..3d74d4c78 100644
--- a/pkg/util/utils_test.go
+++ b/pkg/util/utils_test.go
@@ -303,7 +303,7 @@ func TestPeriodAndQuotaToCores(t *testing.T) {
}
func TestParseInputTime(t *testing.T) {
- tm, err := ParseInputTime("1.5")
+ tm, err := ParseInputTime("1.5", true)
if err != nil {
t.Errorf("expected error to be nil but was: %v", err)
}