-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Create secrets manager API against Google Secrets store, feature flag #6113
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
jrhizor
approved these changes
Sep 17, 2021
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.
We'll touch this up a bit but let's merge it now to unblock you.
This was referenced Sep 18, 2021
cgardens
reviewed
Sep 20, 2021
Comment on lines
+54
to
+79
/** | ||
* Manual test fixture to make sure you've got your project id set in env and have appropriate creds | ||
* to reach/write the secret store. | ||
*/ | ||
public static void main(String[] args) throws Exception { | ||
// Check that we're configured to a usable GCP project. | ||
EnvConfigs envConfig = new EnvConfigs(); | ||
String projectId = envConfig.getSecretStoreGcpProjectId(); | ||
Preconditions.checkNotNull(projectId, "Project ID must not be empty"); | ||
Preconditions.checkNotNull(Long.parseLong(projectId), "Project ID must be purely numeric, not %s".format(projectId)); | ||
|
||
// Check that we can read an existing one from that project / have permissions etc. | ||
Preconditions.checkArgument(existsSecret("zzzzzz") == false, "Secret doesn't exist, should return false."); | ||
Preconditions.checkArgument(existsSecret("dev_practice_sample_secret"), "Secret already exists, should return true."); | ||
String content = readSecret("dev_practice_sample_secret"); | ||
Preconditions.checkArgument("ThisIsMyTest".equals(content)); | ||
|
||
// Try creating a new one and reading it back. | ||
String rand = UUID.randomUUID().toString(); | ||
String key = "dev_practice_sample_" + rand; | ||
saveSecret(key, rand); | ||
String rand2 = readSecret(key); | ||
Preconditions.checkArgument(rand.equals(rand2), "Values should have matched after writing and re-reading a new key."); | ||
saveSecret(key, "foo"); | ||
deleteSecret(key); | ||
} |
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.
should this be in src/test
instead? i think it's a test.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Create secrets manager API against Google Secrets store, plus feature flag on use.
What
Adds an api for retrieving/storing secrets in google secrets. Adds a feature flag for whether configs are stored with secrets in google secrets, versus prior behavior of storing the whole config in the database.
How
This provides just the core of the secrets manager API, but not the full implementation for moving configs. That's pending in another PR. This is being moved ahead to support development of per-secret separated storage.
Recommended reading order
GoogleSecretsManager.java