-
Notifications
You must be signed in to change notification settings - Fork 330
Conversation
889dea3
to
621dfbc
Compare
// is the simplest way for users to upgrade since custom config sourcer | ||
// plugins aren't yet supported, as of 1/10/2023. | ||
key := string(k) | ||
re := regexp.MustCompile(`aws-ssm|consul|kubernetes|null|packer|terraform-cloud|vault`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think it's good for performance to compile your regex once at startup, and then use it throughout (example here:
Line 167 in e19fa4d
reHelpHeader = regexp.MustCompile(`^[a-zA-Z0-9_-].*:$`) |
I don't think it really matters here, because I don't think this is in a hot loop, so feel free to disregard in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@izaaklauer thanks for pointing that out! with bucket.ForEach
we do loop through each record in the bucket, so I'd say it's a "warm" loop 😄 I'm going to set the regex before we enter the loop, but still in this function, since this function is called once at the start up of the server.
This commit updates the Bolt DB implementation of config sources to "upgrade" a pre-v0.10.4 database record from the config_source table. Prior to v0.10.4, the unique identifier for each record in the table was the name of the plugin. This was changed in v0.10.4 with the addition of scoped config sources, and now the ID is a hashed value, whose hash structure is defined by the plugin name, scope, and workspace name. This commit therefore deletes any "old" records, those whose ID is the name of any known config sourcer plugin, from Bolt DB, and creates new records with the ID correctly hashed. With this fix, users who had config sources prior to v0.10.3 may continue to interact with those config sources, whereas before this commit, they could not, and the config sources were permanently "stuck" in the database as they were before upgrading.
54bb172
to
abb4ca5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! The regex enhancement and notes make it super easy to understand why you added this. 🚀
This PR updates the Bolt DB implementation of config sources to "upgrade" a pre-v0.10.4 database record from the config_source table. Prior to v0.10.4, the unique identifier for each record in the table was the name of the plugin. This was changed in v0.10.4 with the addition of scoped config sources, and now the ID is a hashed value, whose hash structure is defined by the plugin name, scope, and workspace name.
This PR therefore deletes any "old" records, those whose ID is the name of any known config sourcer plugin, from Bolt DB, and creates new records with the ID correctly hashed. With this fix, users who had config sources prior to v0.10.3 may continue to interact with those config sources, whereas before this commit, they could not, and the config sources were permanently "stuck" in the database as they were before upgrading.
Fixes #4360.