Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(declarative-config): set hash when config is loaded #9911

Merged
merged 3 commits into from Dec 26, 2022
Merged

Conversation

samugi
Copy link
Contributor

@samugi samugi commented Dec 7, 2022

Ensure the hash field is correctly configured when the declarative configuration is loaded.

@samugi samugi linked an issue Dec 7, 2022 that may be closed by this pull request
1 task
@samugi samugi marked this pull request as draft December 7, 2022 16:09
@samugi samugi marked this pull request as ready for review December 7, 2022 16:24
@samugi samugi marked this pull request as draft December 7, 2022 16:58
@samugi samugi marked this pull request as ready for review December 7, 2022 17:47
@@ -660,6 +660,11 @@ end
declarative.unique_field_key = unique_field_key


local function config_is_empty(entities)
-- empty configuration has no entries other than workspaces
return entities["workspaces"] and tablex.size(entities) == 1
Copy link
Member

Choose a reason for hiding this comment

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

You can use https://github.com/openresty/luajit2#tablenkeys for tablex.size. Might be faster for large configs.

Also, do we need to do and entities.workspace just to be safe? I'm not sure if it is possible to have an entities that has not workspace or will it always be added by the parser.

Copy link
Contributor Author

@samugi samugi Dec 13, 2022

Choose a reason for hiding this comment

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

@dndx

You can use https://github.com/openresty/luajit2#tablenkeys for tablex.size. Might be faster for large configs.

Done, thanks!

do we need to do and entities.workspace just to be safe?

Do you mean the entities["workspaces"] check in my return statement above? That should be always populated here:

self.schema:insert_default_workspace_if_not_given(entities)
Or were you referring to something else?

@chronolaw
Copy link
Contributor

Due to #9890, we should rebase this PR.

Ensure the configuration hash field is correctly configured when the
declarative configuration is loaded on startup.
ensure the default (empty) config returns the appropriate hash that
identifies the empty configuration: 00000000000000000000000000000000
@samugi
Copy link
Contributor Author

samugi commented Dec 14, 2022

Due to #9890, we should rebase this PR.

thank you @chronolaw, done.

@samugi samugi requested a review from dndx December 15, 2022 20:24
@dndx dndx merged commit 9e44850 into master Dec 26, 2022
@dndx dndx deleted the fix/FT-3652 branch December 26, 2022 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

invalid "configuration_hash" despite valid configuration
6 participants