Skip to content

Commit

Permalink
Make pull policy and env optional (#559)
Browse files Browse the repository at this point in the history
* Make pull policy and env optional

* make resource limits optional
  • Loading branch information
paulgb authored Jan 19, 2024
1 parent 8aa8415 commit 1314f72
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plane/plane-tests/tests/backend_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn backend_lifecycle(env: TestEnvironment) {
spawn_config: Some(SpawnConfig {
executable: ExecutorConfig {
image: "ghcr.io/drifting-in-space/demo-image-drop-four".to_string(),
pull_policy: PullPolicy::IfNotPresent,
pull_policy: Some(PullPolicy::IfNotPresent),
env: HashMap::default(),
resource_limits: ResourceLimits::default(),
credentials: None,
Expand Down
2 changes: 1 addition & 1 deletion plane/plane-tests/tests/backend_status_in_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn backend_status_in_response(env: TestEnvironment) {
spawn_config: Some(SpawnConfig {
executable: ExecutorConfig {
image: "ghcr.io/drifting-in-space/demo-image-drop-four".to_string(),
pull_policy: PullPolicy::IfNotPresent,
pull_policy: Some(PullPolicy::IfNotPresent),
env: HashMap::default(),
resource_limits: ResourceLimits::default(),
credentials: None,
Expand Down
2 changes: 1 addition & 1 deletion plane/plane-tests/tests/reuse_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn reuse_key(env: TestEnvironment) {
spawn_config: Some(SpawnConfig {
executable: ExecutorConfig {
image: "ghcr.io/drifting-in-space/demo-image-drop-four".to_string(),
pull_policy: PullPolicy::IfNotPresent,
pull_policy: Some(PullPolicy::IfNotPresent),
env: HashMap::default(),
resource_limits: ResourceLimits::default(),
credentials: None,
Expand Down
2 changes: 1 addition & 1 deletion plane/src/drone/backend_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl BackendManager {
match state.status {
BackendStatus::Scheduled => StepStatusResult::SetState(state.to_loading()),
BackendStatus::Loading => {
let force_pull = match self.executor_config.pull_policy {
let force_pull = match self.executor_config.pull_policy.unwrap_or_default() {
PullPolicy::IfNotPresent => false,
PullPolicy::Always => true,
PullPolicy::Never => {
Expand Down
8 changes: 5 additions & 3 deletions plane/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl Display for BackendStatus {
}
}

#[derive(Clone, Serialize, Deserialize, Debug, Default)]
#[derive(Clone, Copy, Serialize, Deserialize, Debug, Default)]
pub enum PullPolicy {
#[default]
IfNotPresent,
Expand Down Expand Up @@ -263,17 +263,19 @@ impl From<DockerRegistryAuth> for DockerCredentials {
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct ExecutorConfig {
pub image: String,
pub pull_policy: PullPolicy,
pub pull_policy: Option<PullPolicy>,
pub credentials: Option<DockerRegistryAuth>,
#[serde(default)]
pub env: HashMap<String, String>,
#[serde(default)]
pub resource_limits: ResourceLimits,
}

impl ExecutorConfig {
pub fn from_image_with_defaults<T: Into<String>>(image: T) -> Self {
Self {
image: image.into(),
pull_policy: PullPolicy::default(),
pull_policy: None,
env: HashMap::default(),
resource_limits: ResourceLimits::default(),
credentials: None,
Expand Down

0 comments on commit 1314f72

Please sign in to comment.