Skip to content

Commit

Permalink
Change app schema to support multiple container images in an app
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin committed Jan 22, 2025
1 parent 999578a commit 604cc12
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
46 changes: 27 additions & 19 deletions src/backend/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl AppControllerBackend for KubernetesBackend {
"app-controller-interaction-model".to_string(),
config.interaction_model.to_string(),
),
("app-controller-image".to_string(), config.image.to_string()),
("app-controller-images".to_string(), config.images.join(",")),
]);

let service = Service {
Expand Down Expand Up @@ -132,16 +132,20 @@ impl AppControllerBackend for KubernetesBackend {
}),
..Default::default()
}]),
containers: vec![Container {
name: name.clone(),
image: Some(config.image.clone()),
env: Some(vec![EnvVar {
name: "DISPLAY".to_string(),
value: Some(":0.0".to_string()),
containers: config
.images
.iter()
.map(|image| Container {
name: image.clone(),
image: Some(image.clone()),
env: Some(vec![EnvVar {
name: "DISPLAY".to_string(),
value: Some(":0.0".to_string()),
..Default::default()
}]),
..Default::default()
}]),
..Default::default()
}],
})
.collect(),
..Default::default()
}),
},
Expand Down Expand Up @@ -240,12 +244,14 @@ impl AppControllerBackend for KubernetesBackend {
)?,
)
.map_err(|e| BackendError::InternalError(e.to_string()))?,
image: annotations
.get("app-controller-image")
images: annotations
.get("app-controller-images")
.ok_or(BackendError::InternalError(
"Missing app-controller-image annotation in deployment".to_string(),
))
.map(|s| s.to_string())?,
"Missing app-controller-images annotation in deployment".to_string(),
))?
.split(',')
.map(|s| s.to_string())
.collect(),
};

Ok(App { id, config })
Expand Down Expand Up @@ -291,13 +297,15 @@ impl AppControllerBackend for KubernetesBackend {
)),
)?,
)?,
image: annotations
.get("app-controller-image")
images: annotations
.get("app-controller-images")
.ok_or(BackendError::InternalError(format!(
"Missing app-controller-image annotation for deployment {}",
"Missing app-controller-images annotation for deployment {}",
name
)))?
.to_string(),
.split(',')
.map(|s| s.to_string())
.collect(),
};
Ok::<App, BackendError>(App {
id: id.into(),
Expand Down
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub struct AppConfig {
pub name: String,
/// Interaction model to use for the app.
pub interaction_model: InteractionModel,
/// Container image to use for the app.
pub image: String,
/// Container images to use for the app.
pub images: Vec<String>,
}

/// Status of a app.
Expand Down

0 comments on commit 604cc12

Please sign in to comment.