Skip to content

Commit

Permalink
feat: pass env to Image resource
Browse files Browse the repository at this point in the history
  • Loading branch information
wangeguo committed Feb 9, 2024
1 parent da57a20 commit 9fb4560
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.8.14"
version = "0.8.15"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/amphitheatre-app/amphitheatre"
Expand Down
14 changes: 11 additions & 3 deletions resources/src/kpack/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,26 @@ fn new(actor: &Actor) -> Result<DynamicObject> {
})
};

let mut build = json!({});

// Set environment variables if build.env is not empty
if let Some(env) = actor.spec.character.build.as_ref().and_then(|build| build.env.as_ref()) {
build["env"] = env.iter().map(|(name, value)| json!({"name": name, "value": value})).collect();
}

let resource = from_value(json!({
"apiVersion": "kpack.io/v1alpha2",
"kind": "Image",
"metadata": {
"name": name.clone(),
"ownerReferences": vec![owner_reference],
"labels": {
"amphitheatre.app/character": actor.spec.name.clone(),
"app.kubernetes.io/managed-by": "Amphitheatre",
},
"name": name.clone(),
"ownerReferences": vec![owner_reference],
},
"spec": {
"tag": actor.spec.image,
"build": build,
"builder": {
"name": actor.spec.character.builder_name(),
"kind": "ClusterBuilder",
Expand All @@ -113,6 +120,7 @@ fn new(actor: &Actor) -> Result<DynamicObject> {
"volume": {}
},
"source": source,
"tag": actor.spec.image,
}
}))
.map_err(Error::SerializationError)?;
Expand Down

0 comments on commit 9fb4560

Please sign in to comment.