Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(admission): fix admission reject request when serde failed (#32)
- Loading branch information
Showing
5 changed files
with
52 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pub mod mutate; | ||
pub mod validate; | ||
|
||
mod util; |
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,13 @@ | ||
use habitat_api::Job; | ||
use kube::core::DynamicObject; | ||
use lazy_static::lazy_static; | ||
use regex::Regex; | ||
|
||
pub fn try_cast_dynamic_obj_into_job(obj: &DynamicObject) -> Result<Job, String> { | ||
lazy_static! { | ||
static ref RE: Regex = Regex::new(r" at line \d+ column \d+").unwrap(); | ||
} | ||
|
||
let obj_json = serde_json::to_string(obj).unwrap(); | ||
serde_json::from_str(&obj_json).map_err(|e| RE.replace(&e.to_string(), "").to_string()) | ||
} |
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