Skip to content

Commit 10edf40

Browse files
committed
Return created objects when applying kube manifest
Signed-off-by: Robert Detjens <[email protected]>
1 parent 5ff274d commit 10edf40

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/clients.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,17 @@ pub async fn kube_api_for(
174174
}
175175
}
176176

177-
/// Apply multi-document manifest file
178-
pub async fn apply_manifest_yaml(client: &kube::Client, manifest: &str) -> Result<()> {
177+
/// Apply multi-document manifest file, return created resources
178+
pub async fn apply_manifest_yaml(
179+
client: &kube::Client,
180+
manifest: &str,
181+
) -> Result<Vec<DynamicObject>> {
179182
// set ourself as the owner for managed fields
180183
// https://kubernetes.io/docs/reference/using-api/server-side-apply/#managers
181184
let pp = PatchParams::apply("beavercds").force();
182185

186+
let mut results = vec![];
187+
183188
// this manifest has multiple documents (crds, deployment)
184189
for yaml in multidoc_deserialize(manifest)? {
185190
let obj: DynamicObject = serde_yml::from_value(yaml)?;
@@ -195,7 +200,10 @@ pub async fn apply_manifest_yaml(client: &kube::Client, manifest: &str) -> Resul
195200
.patch(&obj.name_any(), &pp, &Patch::Apply(&obj))
196201
.await
197202
{
198-
Ok(d) => Ok(()),
203+
Ok(d) => {
204+
results.push(d);
205+
Ok(())
206+
}
199207
// if error is from cluster api, mark it as such
200208
Err(kube::Error::Api(ae)) => {
201209
// Err(kube::Error::Api(ae).into())
@@ -206,7 +214,7 @@ pub async fn apply_manifest_yaml(client: &kube::Client, manifest: &str) -> Resul
206214
}?;
207215
}
208216

209-
Ok(())
217+
Ok(results)
210218
}
211219

212220
/// Deserialize multi-document yaml string into a Vec of the documents

src/cluster_setup/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ pub async fn install_certmanager(profile: &config::ProfileConfig) -> Result<()>
6868
// letsencrypt and letsencrypt-staging
6969
const ISSUERS_YAML: &str =
7070
include_str!("../asset_files/setup_manifests/letsencrypt.issuers.yaml");
71-
apply_manifest_yaml(&client, ISSUERS_YAML).await
71+
apply_manifest_yaml(&client, ISSUERS_YAML).await?;
72+
73+
Ok(())
7274
}
7375

7476
pub async fn install_extdns(profile: &config::ProfileConfig) -> Result<()> {

0 commit comments

Comments
 (0)