Use strings.Cut instead of strings.Split* where possible #76

Merged
acid-ant merged 1 commit from improve/65-use-cut-insteadof-split into master 2023-02-28 10:39:15 +00:00
acid-ant commented 2023-02-27 14:20:53 +00:00 (Migrated from github.com)

Close #65

Signed-off-by: Anton Nikiforov an.nikiforov@yadro.com

Close #65 Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
carpawell (Migrated from github.com) reviewed 2023-02-27 14:20:53 +00:00
ale64bit (Migrated from github.com) reviewed 2023-02-27 14:20:53 +00:00
dstepanov-yadro (Migrated from github.com) requested changes 2023-02-27 15:00:34 +00:00
@ -206,3 +205,4 @@
dst.SetAttribute(k, v)
}
if !containerNoTimestamp {
dstepanov-yadro (Migrated from github.com) commented 2023-02-27 14:52:25 +00:00

I suppose attribute key=value=value is not valid, but after this it will pass check.
image

I suppose attribute `key=value=value` is not valid, but after this it will pass check. ![image](https://user-images.githubusercontent.com/125876766/221595977-22eb48c8-171e-490d-b4f7-96d661bae234.png)
@ -24,2 +22,4 @@
k, v, found := strings.Cut(line, keyValueSeparator)
if !found {
return errors.New("missing attribute key and/or value")
}
dstepanov-yadro (Migrated from github.com) commented 2023-02-27 15:00:21 +00:00

Maybe if !found || len(k) == 0 || len(v) == 0 will be better?

Maybe `if !found || len(k) == 0 || len(v) == 0` will be better?
acid-ant (Migrated from github.com) reviewed 2023-02-28 07:02:25 +00:00
@ -206,3 +205,4 @@
dst.SetAttribute(k, v)
}
if !containerNoTimestamp {
acid-ant (Migrated from github.com) commented 2023-02-28 07:02:19 +00:00

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.

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.
fyrchik (Migrated from github.com) reviewed 2023-02-28 07:22:28 +00:00
@ -206,3 +205,4 @@
dst.SetAttribute(k, v)
}
if !containerNoTimestamp {
fyrchik (Migrated from github.com) commented 2023-02-28 07:22:27 +00:00

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

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
fyrchik (Migrated from github.com) reviewed 2023-02-28 07:32:11 +00:00
fyrchik (Migrated from github.com) left a comment
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 {
fyrchik (Migrated from github.com) commented 2023-02-28 07:29:08 +00:00

Can use Cut here too.

Can use `Cut` here too.
acid-ant (Migrated from github.com) reviewed 2023-02-28 08:04:47 +00:00
@ -24,2 +22,4 @@
k, v, found := strings.Cut(line, keyValueSeparator)
if !found {
return errors.New("missing attribute key and/or value")
}
acid-ant (Migrated from github.com) commented 2023-02-28 08:04:47 +00:00

We already have this check in sdk.

We already have this check in sdk.
acid-ant (Migrated from github.com) reviewed 2023-02-28 08:12:06 +00:00
@ -226,35 +226,32 @@ func parseEACLTable(tb *eacl.Table, args []string) error {
acid-ant (Migrated from github.com) commented 2023-02-28 08:12:06 +00:00

Done.

Done.
fyrchik (Migrated from github.com) approved these changes 2023-02-28 10:31:48 +00:00
dstepanov-yadro (Migrated from github.com) approved these changes 2023-02-28 10:37:13 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#76
No description provided.