Skip to content

kv-store: support quoted values#28

Merged
tormath1 merged 2 commits intoflatcar-masterfrom
tormath1/kv-store
Oct 17, 2023
Merged

kv-store: support quoted values#28
tormath1 merged 2 commits intoflatcar-masterfrom
tormath1/kv-store

Conversation

@tormath1
Copy link
Copy Markdown
Contributor

@tormath1 tormath1 commented Oct 12, 2023

Locally tested with update_engine_client -check_for_update then inspecting the request/response.

Before adding the patch, I added test cases that fails with:

 Expected equality of these values:
  "my alias"
  (*test_map)["ALIAS"]
    Which is: "'my alias'"
i = 0
src/update_engine/simple_key_value_store_unittest.cc:37: Failure
Expected equality of these values:
  "this is a test"
  (*test_map)["TEST"]
    Which is: "\"this is a test\""
i = 0

Flatcar CI here: http://jenkins.infra.kinvolk.io:8080/job/container/job/packages_all_arches/2725/cldsv/

@tormath1 tormath1 self-assigned this Oct 12, 2023
Useful to test when the value contains whitespaces surrounded with
quotes/double-quotes.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
Comment on lines +32 to +33
((val.at(0) == '\"' && val.at(val.length() - 1) == '\"') ||
(val.at(0) == '\'' && val.at(val.length() - 1) == '\''))) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try these instead:
val.front()
val.back()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tips! Looks good on the CI.

@tormath1 tormath1 changed the title [wip] kv-store: support quoted values kv-store: support quoted values Oct 12, 2023
In the case of the value contains whitespaces, it has to be surrounded
with quotes (single or double).

We should exclude these characters from the final values.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
@tormath1 tormath1 marked this pull request as ready for review October 12, 2023 16:04
@tormath1 tormath1 requested a review from a team October 12, 2023 16:04
@tormath1 tormath1 merged commit 1130900 into flatcar-master Oct 17, 2023
@tormath1 tormath1 deleted the tormath1/kv-store branch October 17, 2023 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants