record whether an agent's config sets privateUsers in its closure record
This commit is contained in:
parent
7412a0f1bd
commit
3ca660e558
2 changed files with 178 additions and 6 deletions
|
|
@ -36,6 +36,12 @@ pub struct AgentClosure {
|
|||
/// written before the field existed reads as false.
|
||||
#[serde(default)]
|
||||
pub cached: bool,
|
||||
/// Whether the agent's evaluated config sets
|
||||
/// `services.hyperhive.agent.user.privateUsers`: the agent runs in its own
|
||||
/// user namespace. A record written before the field existed reads as
|
||||
/// false, which keeps the agent out of one.
|
||||
#[serde(default)]
|
||||
pub private_users: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -56,6 +62,7 @@ mod tests {
|
|||
system: "x86_64-linux".to_owned(),
|
||||
built_unix: 7,
|
||||
cached: true,
|
||||
private_users: true,
|
||||
};
|
||||
let wire = serde_json::json!({
|
||||
"meta_rev": "abc",
|
||||
|
|
@ -63,6 +70,7 @@ mod tests {
|
|||
"system": "x86_64-linux",
|
||||
"built_unix": 7,
|
||||
"cached": true,
|
||||
"private_users": true,
|
||||
});
|
||||
assert_eq!(serde_json::to_value(&value).expect("encodes"), wire);
|
||||
assert_eq!(
|
||||
|
|
@ -72,7 +80,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn a_record_without_the_field_reads_as_not_cached() {
|
||||
fn a_record_without_the_fields_reads_as_not_cached_and_not_namespaced() {
|
||||
let old = serde_json::json!({
|
||||
"meta_rev": "abc",
|
||||
"store_path": "/nix/store/x",
|
||||
|
|
@ -81,5 +89,6 @@ mod tests {
|
|||
});
|
||||
let record = serde_json::from_value::<AgentClosure>(old).expect("decodes");
|
||||
assert!(!record.cached);
|
||||
assert!(!record.private_users);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,6 +149,11 @@ pub enum FromMetaReply {
|
|||
system: String,
|
||||
#[serde(default)]
|
||||
cached: bool,
|
||||
/// Whether the agent's evaluated config sets
|
||||
/// `services.hyperhive.agent.user.privateUsers`. A builder that
|
||||
/// predates the field answers without it, which reads as false.
|
||||
#[serde(default)]
|
||||
private_users: bool,
|
||||
},
|
||||
/// The build did not succeed: the last lines `nix` printed, or why it
|
||||
/// stopped (it timed out, or could not start). The controller holds the
|
||||
|
|
@ -262,12 +267,14 @@ mod tests {
|
|||
out_path: "/nix/store/x".to_owned(),
|
||||
system: "x86_64-linux".to_owned(),
|
||||
cached: true,
|
||||
private_users: true,
|
||||
},
|
||||
json!({
|
||||
"state": "built",
|
||||
"out_path": "/nix/store/x",
|
||||
"system": "x86_64-linux",
|
||||
"cached": true,
|
||||
"private_users": true,
|
||||
}),
|
||||
),
|
||||
(
|
||||
|
|
@ -292,7 +299,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn a_built_reply_from_a_builder_without_the_field_reads_as_not_cached() {
|
||||
fn a_built_reply_from_a_builder_without_the_fields_reads_as_not_cached_and_not_namespaced() {
|
||||
let old = json!({"state": "built", "out_path": "/nix/store/x", "system": "s"});
|
||||
assert_eq!(
|
||||
serde_json::from_value::<FromMetaReply>(old).expect("decodes"),
|
||||
|
|
@ -300,6 +307,7 @@ mod tests {
|
|||
out_path: "/nix/store/x".to_owned(),
|
||||
system: "s".to_owned(),
|
||||
cached: false,
|
||||
private_users: false,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue