-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
40 lines (30 loc) · 1.09 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use std::fs;
use std::path::Path;
use kube::CustomResourceExt;
// Although build scripts aren't supposed to write files outside of the OUT_DIR environment variable
// we want to store the generated manifests in a more convenient location.
const OUT_DIR: &str = "manifests";
fn main() {
// Add any new CRDs to this list to generate the CRD manifests
let crd_list = vec![
crd::SecretMap::crd(),
];
// Add any examples to write
let example_list: Vec<_> = vec![
crd::SecretMap::examples()
].into_iter().flatten().collect();
for crd in crd_list {
let dest_path = Path::new(&OUT_DIR).join(format!("crds/{}.crd.yml", crd.spec.names.kind));
fs::write(
&dest_path,
serde_yaml::to_string(&crd).unwrap()
).unwrap();
}
for example in example_list {
let dest_path = Path::new(&OUT_DIR).join(format!("examples/{}.yml", example.clone().metadata.name.expect("named example resource")));
fs::write(
&dest_path,
serde_yaml::to_string(&example).unwrap()
).unwrap();
}
}