Use strings.Cut
instead of strings.Split*
where possible #76
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#76
Loading…
Reference in a new issue
No description provided.
Delete branch "improve/65-use-cut-insteadof-split"
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?
Close #65
Signed-off-by: Anton Nikiforov an.nikiforov@yadro.com
@ -206,3 +205,4 @@
dst.SetAttribute(k, v)
}
if !containerNoTimestamp {
I suppose attribute
key=value=value
is not valid, but after this it will pass check.@ -24,2 +22,4 @@
k, v, found := strings.Cut(line, keyValueSeparator)
if !found {
return errors.New("missing attribute key and/or value")
}
Maybe
if !found || len(k) == 0 || len(v) == 0
will be better?@ -206,3 +205,4 @@
dst.SetAttribute(k, v)
}
if !containerNoTimestamp {
Agree, but there are no restriction in the sdk for the content of the key or value. it should be non empty only. The idea of the cli is to be as simple as it can, @fyrchik correct me if I'm wrong.
@ -206,3 +205,4 @@
dst.SetAttribute(k, v)
}
if !containerNoTimestamp {
Most likely, it was a bug. API gives no restrictions on container value https://github.com/TrueCloudLab/frostfs-api/blob/master/container/types.proto#L30
We also have a nice candidate for
Cut
here https://github.com/TrueCloudLab/frostfs-node/blob/master/pkg/local_object_storage/blobstor/fstree/fstree.go#L76@ -226,35 +226,32 @@ func parseEACLTable(tb *eacl.Table, args []string) error {
Can use
Cut
here too.@ -24,2 +22,4 @@
k, v, found := strings.Cut(line, keyValueSeparator)
if !found {
return errors.New("missing attribute key and/or value")
}
We already have this check in sdk.
@ -226,35 +226,32 @@ func parseEACLTable(tb *eacl.Table, args []string) error {
Done.