-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
neofs-cli: bugfix expire-at flag for session create command. #2546
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2546 +/- ##
=======================================
Coverage 29.66% 29.67%
=======================================
Files 405 405
Lines 30756 30756
=======================================
+ Hits 9123 9126 +3
+ Misses 20863 20861 -2
+ Partials 770 769 -1 see 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
b393929
to
c3c6d50
Compare
|
||
exp, _ := cmd.Flags().GetUint64(commonflags.ExpireAt) | ||
lifetime := uint64(defaultLifetime) | ||
if lfArg, _ := cmd.Flags().GetUint64(commonflags.Lifetime); lfArg != 0 { | ||
exp = currEpoch + lfArg | ||
if cmd.Flags().Changed(commonflags.Lifetime) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IINW may be shortened to
var exp uint64
if cmd.Flags().Changed(commonflags.ExpireAt) {
// Cobra guarantees that commonflags.Lifetime is unset then (see init)
exp, _ = cmd.Flags().GetUint64(commonflags.ExpireAt)
if exp <= currEpoch {
common.ExitOnErr(cmd, "", errors.New("expiration epoch must be greater than current epoch"))
}
} else {
lifetime, _ := cmd.Flags().GetUint64(commonflags.Lifetime)
exp = currEpoch + lifetime
}
var tok session.Object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need a check of passing --lifetime 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest to add separate check for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if exp <= currEpoch {
common.ExitOnErr(cmd, "", errors.New("expiration epoch must be greater than current epoch"))
}
this should be enough, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically enough, but smth like lifetime must not be zero
would be more clearer, right?
i'm ok to leave if exp <= currEpoch
check below as before cuz it doesn't directly related to the bug. But if u find such clarification worthy - add new commit
CHANGELOG.md
Outdated
@@ -39,6 +39,7 @@ minor release, the component will be purged, so be prepared (see `Updating` sect | |||
- `neofs-lens write-cache list` command duplication (#2505) | |||
- `neofs-adm` works with contract wallet in `init` and `update-contracts` commands only (#2134) | |||
- Missing removed but locked objects in `SEARCH`'s results (#2526) | |||
- `--exire-at` flag in `neofs-cli session create` command (#2539) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `--exire-at` flag in `neofs-cli session create` command (#2539) | |
- `--expire-at` flag in `neofs-cli session create` command (#2539) |
btw was it broken in the latest release? if not, then this record is redundant
8314f6c
to
2eea1e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit header should not end with a period.
2eea1e7
to
3343cd0
Compare
Added a check for changes to the lifetime flag when it's passed by the user to prevent the settlement of the default lifetime value even if expire-at flag passed. Closes #2539. Signed-off-by: Ekaterina Pavlova <[email protected]>
3343cd0
to
a43f240
Compare
Added check of passing
--lifetime
flag by the user and handling of settingdefaultLifetime
valueCloses #2539.