-
Notifications
You must be signed in to change notification settings - Fork 6
add bootstrap kubernetes labels and validator management structs #9
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f025ae7
add bootstrap validator selector
gregcusack 9596709
address chido: hard code startup scripts
gregcusack 8d5f9a3
add library and validator structs
gregcusack d5a071a
upgrade rustls
gregcusack 68ac58f
address Jon comments from PR #7
gregcusack 565c8f0
Jon nit from PR #8. rm build_path
gregcusack 146a546
chido. change up secret handling to be more flexible
gregcusack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
chido. change up secret handling to be more flexible
- Loading branch information
commit 146a54689d68e5b05e8f394f25f33d365196b779
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,19 @@ | ||
| use { | ||
| k8s_openapi::{api::core::v1::Secret, ByteString}, | ||
| kube::api::ObjectMeta, | ||
| std::{collections::BTreeMap, error::Error, path::PathBuf}, | ||
| std::{ | ||
| collections::{BTreeMap, HashMap}, | ||
| error::Error, | ||
| path::PathBuf, | ||
| }, | ||
| }; | ||
|
|
||
| fn create_secret(name: &str, data: BTreeMap<String, ByteString>) -> Secret { | ||
| pub enum SecretType { | ||
| Value { v: String }, | ||
| File { path: PathBuf }, | ||
| } | ||
|
|
||
| fn build_secret(name: &str, data: BTreeMap<String, ByteString>) -> Secret { | ||
| Secret { | ||
| metadata: ObjectMeta { | ||
| name: Some(name.to_string()), | ||
|
|
@@ -15,18 +24,24 @@ fn create_secret(name: &str, data: BTreeMap<String, ByteString>) -> Secret { | |
| } | ||
| } | ||
|
|
||
| pub fn create_secret_from_files( | ||
| pub fn create_secret( | ||
| secret_name: &str, | ||
| key_files: &[(PathBuf, &str)], //[pathbuf, key type] | ||
| secrets: HashMap<String, SecretType>, | ||
| ) -> Result<Secret, Box<dyn Error>> { | ||
| let mut data = BTreeMap::new(); | ||
| for (file_path, key_type) in key_files { | ||
| let file_content = std::fs::read(file_path) | ||
| .map_err(|err| format!("Failed to read file '{:?}': {}", file_path, err))?; | ||
| data.insert(format!("{key_type}.json"), ByteString(file_content)); | ||
| let mut data: BTreeMap<String, ByteString> = BTreeMap::new(); | ||
| for (label, value) in secrets { | ||
| match value { | ||
| SecretType::Value { v } => { | ||
| data.insert(label, ByteString(v.into_bytes())); | ||
| } | ||
| SecretType::File { path } => { | ||
| let file_content = std::fs::read(&path) | ||
| .map_err(|err| format!("Failed to read file '{:?}': {}", path, err))?; | ||
| data.insert(label, ByteString(file_content)); | ||
| } | ||
| } | ||
|
Comment on lines
+31
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: you might be able to do this in one statement by collecting into a |
||
| } | ||
|
|
||
| Ok(create_secret(secret_name, data)) | ||
| Ok(build_secret(secret_name, data)) | ||
| } | ||
|
|
||
| pub fn create_selector(key: &str, value: &str) -> BTreeMap<String, String> { | ||
|
|
||
This file contains hidden or 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
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.
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: Since
Secrettakes aBTreeMap, you could just pass one in here directly