This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 330
Scoped config sources - protobuf & Bolt DB state #4191
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paladin-devops
added
the
pr/no-changelog
No automatic changelog entry required for this pull request
label
Nov 10, 2022
paladin-devops
force-pushed
the
f-scoped-config-sources
branch
from
November 15, 2022 00:12
b30ce19
to
ce52971
Compare
paladin-devops
force-pushed
the
f-scoped-config-sources
branch
from
November 15, 2022 19:47
ce52971
to
95bf18d
Compare
evanphx
approved these changes
Nov 15, 2022
Comment on lines
+75
to
+86
// The scope and type of a config source is used to establish a unique record | ||
// in the config sources table. | ||
idHash, err := hashstructure.Hash(map[string]interface{}{ | ||
"scope": value.Scope, | ||
"type": value.Type, | ||
"workspace": value.Workspace, | ||
}, hashstructure.FormatV2, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
id := s.configSourceId(idHash) |
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.
Note for later readers, there is a note on configSourceId that it's only used for in memory indexes, so we aren't invalidating anything by changing the hash calculate algorithm.
…s scoped by application, project, or workspace, and continues support of the global scope. This commit also updates the Bolt DB state implementation to support these new scopes. The config source index table was updated in this commit to include additional indexes, for project and application, and adds an index dedicated to global config sources.
The config sources for the global scoped are merged with those from the project scope as well as the app scope. The config sources for the project scope are merged with those of the app scope.
The unique ID of a record in the config source "table" is no longer the "type" of config source. Instead, it is now the hash of the config source's type, scope, and configuration. This makes each entry that is added to the table unique, and thusly not overwritten by other config sources of the same type or scope. This commit also adds another test, and fixes the ordering of params for require.Equal throughout the config source tests.
…ype. The previous commit made the unique ID of a config source the hash of a config source's type, scope and configuration. This commit removes the configuration from that hash, because a change to a config source's configuration should not result in the creation of a new record, but the updation of an existing one for a specific "type" of plugin in the same "scope". To accommodate this, the config source project index schema was also updated to include an indicator that a config source was specifically for the project level. This is because app-scoped config sources also have the project set, so the project index was matching on project-scoped AND app-scoped config sources - it now will only match on project-scoped config sources.
This commit updates the addition or update of a config source to consider the workspace scope that is set for the config source. This fixes an issue where setting the config source for a different workspace but at the same scope "level" as another config source of the same type would overwrite the existing entry.
Update the config sources returned by the server to be returned in such a way that the least-specific scope is first in the slice of config sources, and more-specific config sources are in ascending order.
paladin-devops
force-pushed
the
f-scoped-config-sources
branch
from
November 21, 2022 16:14
95bf18d
to
e0212cc
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the protobuf and the Bolt DB state implementation to support scoped configuration sources. Waypoint runners, the entrypoint, as well as the CLI continue to exclusively use the global scope, which continues to be the de facto scope in use with this PR. However, the changes in this PR lay the groundwork for forthcoming changes to the aforementioned "clients" of configuration sources. Some tests were also added for the config source Bolt DB state implementation.
The
pr/no-changelog
label is on this PR because there are no user-facing changes.