Watch
0
0
Fork
You've already forked hyperhive
0

seed a hyperhive/hyperhive mirror so update_meta finds it on a fresh swarm

This commit is contained in:
atlas 2026-11-09 12:19:46 +01:00
commit a6b5bafa83

View file

@ -311,6 +311,8 @@ struct TeamState {
struct RepoState {
private: bool,
empty: bool,
/// A pull-mirror. A plain repo at a mirror's `dest` is left as it is.
mirror: bool,
mirror_interval: Option<String>,
}
@ -485,7 +487,9 @@ fn plan(desired: &Desired, observed: &Observed) -> Vec<Action> {
repo: m.repo.clone(),
upstream: m.upstream.clone(),
}),
Seen::Present(s) if s.mirror_interval.as_deref() != Some(MIRROR_INTERVAL) => {
Seen::Present(s)
if s.mirror && s.mirror_interval.as_deref() != Some(MIRROR_INTERVAL) =>
{
actions.push(Action::SetMirrorInterval {
owner: m.owner.clone(),
repo: m.repo.clone(),
@ -697,6 +701,7 @@ impl Client {
|r| RepoState {
private: r.private.unwrap_or(false),
empty: r.empty.unwrap_or(false),
mirror: r.mirror.unwrap_or(false),
mirror_interval: r.mirror_interval,
},
);
@ -1191,10 +1196,18 @@ mod tests {
RepoState {
private,
empty,
mirror: false,
mirror_interval: interval.map(str::to_owned),
}
}
fn mirror_state(interval: Option<&str>) -> RepoState {
RepoState {
mirror: true,
..repo_state(false, false, interval)
}
}
/// Every object of [`desired`] present with its desired settings.
fn converged() -> Observed {
let mut o = Observed::default();
@ -1218,7 +1231,7 @@ mod tests {
);
o.repos.insert(
key("actions", "checkout"),
Seen::Present(repo_state(false, false, Some(MIRROR_INTERVAL))),
Seen::Present(mirror_state(Some(MIRROR_INTERVAL))),
);
o.avatar_set = true;
o
@ -1299,7 +1312,7 @@ mod tests {
);
o.repos.insert(
(s("actions"), s("checkout")),
Seen::Present(repo_state(false, false, None)),
Seen::Present(mirror_state(None)),
);
o.avatar_set = false;
assert_eq!(
@ -1329,6 +1342,28 @@ mod tests {
);
}
#[test]
fn a_plain_repo_at_a_mirror_dest_is_left_alone() {
let mut o = converged();
o.repos.insert(
(s("actions"), s("checkout")),
Seen::Present(repo_state(false, false, None)),
);
assert_eq!(plan(&desired(), &o), Vec::new());
// Control: the same repo as a mirror with no interval is patched.
o.repos.insert(
(s("actions"), s("checkout")),
Seen::Present(mirror_state(None)),
);
assert_eq!(
plan(&desired(), &o),
vec![Action::SetMirrorInterval {
owner: s("actions"),
repo: s("checkout"),
}]
);
}
#[test]
fn an_unreadable_object_gets_no_write() {
let mut o = nothing();