cli: Read ape rule from JSON file #989
No reviewers
Labels
No labels
P0
P1
P2
P3
badger
frostfs-adm
frostfs-cli
frostfs-ir
frostfs-lens
frostfs-node
good first issue
triage
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#989
Loading…
Reference in a new issue
No description provided.
Delete branch "aarifullin/frostfs-node:feat/cli_parse_json"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
JSON as string.
41f7981607
to88939c0a53
@ -4,3 +4,3 @@
APE is a replacement for eACL. Each rule can restrict somehow access to the object/container or list of them.
Here is a simple representation for the rule:
`<status>[:status_detail] <action>... <condition>... <resource>...`
`<status>[:status_detail] <action>... [any=true/false] <condition>... <resource>...`
Is it related to the commit?
I have splitted in 3 commits. Check this out
@ -50,2 +47,3 @@
chain.ID = apechain.ID(chainIDRaw)
serializedChain := chain.Bytes()
if ruleStmt, _ := cmd.Flags().GetStringArray(ruleFlag); len(ruleStmt) > 0 {
Why have you decided to go with 2 separate flags, second of which has 2 meanings?
See e.g.
cmd/frostfs-cli/internal/common/token.go:ReadBinaryOrJSON()
function: can we avoid the second parameter?First of all, I have made a mistake: the flag
ruleJSON
must be renamed topath
. Rules are statements whilepath
is a whole chain itself (id, conds, matchType etc.). Also, rules can be passed as an array of strings whilepath
is the only oneI have borrowed the idea with
ReadBinaryOrJSON
but adopted it to ape chain parsing. But still I insist on separate flag--path
. I expalined that above@ -105,6 +108,16 @@ func parseRuleLexemes(r *apechain.Rule, lexemes []string) error {
var isObject *bool
for i, lexeme := range lexemes[1:] {
anyVal, anyErr := parseAny(lexeme)
It is a new feature, not related to JSON format acceptance, could you move it to a separate commit?
Also, why is it
any=true/false
and not e.g.any
/all
or evenany
andall
by default?I have introduced
any
andall
statementcli: Read ape rule from JSON fileto cli: Read ape rule from JSON filecli: Read ape rule from JSON fileto cli: Read ape rule from JSON filecli: Read ape rule from JSON fileto cli: Read ape rule from JSON filecli: Read ape rule from JSON fileto cli: Read ape rule from JSON file2baa648245
toa5713ebda9
a5713ebda9
to1307794ccb
@ -60,0 +68,4 @@
if err != nil {
err = chain.UnmarshalJSON(data)
if err != nil {
return errors.New("invalid format")
What about passing context for both errors?
I hope I got your point correctly - I've made the error more verbose adding
%w
If you've been talking about adding
cmd.Context()
, then it wouldn't be correct becauseParse*
methods are placed inutil
package and also used by unit-tests1307794ccb
to6f9911e915
6f9911e915
tod3a6e289be
Please, check the last commit out. I have cherry-picked it from #986
I will revert the commit there