-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add and deploy bootstrap secrets (#8)
* add create and deploy bootstrap secrets * finish up rest of nits * fix nit and remove dependency on CARGO_MANIFEST_PATH
- Loading branch information
1 parent
e366862
commit 1a22c6c
Showing
9 changed files
with
130 additions
and
51 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use { | ||
k8s_openapi::{api::core::v1::Secret, ByteString}, | ||
kube::api::ObjectMeta, | ||
std::{collections::BTreeMap, error::Error, path::PathBuf}, | ||
}; | ||
|
||
fn create_secret(name: &str, data: BTreeMap<String, ByteString>) -> Secret { | ||
Secret { | ||
metadata: ObjectMeta { | ||
name: Some(name.to_string()), | ||
..Default::default() | ||
}, | ||
data: Some(data), | ||
..Default::default() | ||
} | ||
} | ||
|
||
pub fn create_secret_from_files( | ||
secret_name: &str, | ||
key_files: &[(PathBuf, &str)], //[pathbuf, key type] | ||
) -> 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!("{}.json", key_type), ByteString(file_content)); | ||
} | ||
|
||
Ok(create_secret(secret_name, data)) | ||
} |
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
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
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
Oops, something went wrong.