Refactor UX for bearer create command #523

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:fix/cli-bearer-create into master 2023-07-17 10:18:01 +00:00

If issuedAt or notValidBefore are not specified, then use current epoch value.

Also added RPC endpoint value check.

Closes #512

If `issuedAt` or `notValidBefore` are not specified, then use current epoch value. Also added RPC endpoint value check. Closes #512
dstepanov-yadro force-pushed fix/cli-bearer-create from cb6d06ce7c to 1137d26591 2023-07-14 09:05:46 +00:00 Compare
ale64bit reviewed 2023-07-14 09:18:27 +00:00
@ -68,3 +66,3 @@
commonCmd.ExitOnErr(cmd, "can't parse --"+notValidBeforeFlag+" flag: %w", err)
if iatRelative || expRelative || nvbRelative {
iatMissing := !flagSpecified(cmd, issuedAtFlag)
Member

if this util function is used only negated, wasn't it easier to not have it and instead do

iatMissing := cmd.Flags().Lookup(issuedAtFlag) == nil

and so on?

if this util function is used only negated, wasn't it easier to not have it and instead do ```go iatMissing := cmd.Flags().Lookup(issuedAtFlag) == nil ``` and so on?
Author
Member

cmd.Flags().Lookup(issuedAtFlag) returns not nil, if flag with such name defined by code. We must to check Changed too:

func flagSpecified(cmd *cobra.Command, flag string) bool {
	v := cmd.Flags().Lookup(flag)
	return v != nil && v.Changed
}
`cmd.Flags().Lookup(issuedAtFlag)` returns not nil, if flag with such name defined by code. We must to check `Changed` too: ``` func flagSpecified(cmd *cobra.Command, flag string) bool { v := cmd.Flags().Lookup(flag) return v != nil && v.Changed } ```
ale64bit marked this conversation as resolved
ale64bit approved these changes 2023-07-14 10:45:08 +00:00
fyrchik requested changes 2023-07-15 09:50:34 +00:00
@ -69,2 +67,3 @@
if iatRelative || expRelative || nvbRelative {
iatMissing := !flagSpecified(cmd, issuedAtFlag)
nvbMissing := !flagSpecified(cmd, notValidBeforeFlag)
Owner

Couldn't we just set the default value +0 in the flag definition?

Couldn't we just set the default value `+0` in the flag definition?
Author
Member

nice idea! fixed

nice idea! fixed
fyrchik marked this conversation as resolved
dstepanov-yadro force-pushed fix/cli-bearer-create from 1137d26591 to 5f7e455b92 2023-07-17 08:18:26 +00:00 Compare
Owner

@dstepanov-yadro there are conflicts after #524

@dstepanov-yadro there are conflicts after #524
aarifullin approved these changes 2023-07-17 08:27:09 +00:00
aarifullin left a comment
Member

LGTM

LGTM
dstepanov-yadro force-pushed fix/cli-bearer-create from 5f7e455b92 to a0c7045f29 2023-07-17 08:45:57 +00:00 Compare
fyrchik merged commit a0c7045f29 into master 2023-07-17 10:18:01 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#523
No description provided.