swarm: set an agent's config repo avatar from its icon
The agent module exposes the PNG nix renders from the agent's icon as the read-only option services.hyperhive.agent.iconPng, which the forge and matrix avatar syncs now share. When the builder reads an icon it builds that one attribute with nix build and sends the file, base64, next to the SVG in the meta build reply, so the builder runs no renderer of its own. After recording the icon, the controller sets the avatar of agent-configs/<agent> from the PNG as the forge admin, removes the avatar when the icon is removed, and leaves it alone when the builder sent no PNG. A marker per repo holds the image's fingerprint, so a build whose icon did not change makes no forge call; a forge that refuses the avatar does not fail the build. An old builder sends no PNG, so it changes nothing.
This commit is contained in:
parent
8a0615ccfc
commit
1a31a4cd5a
1 changed files with 499 additions and 25 deletions
|
|
@ -141,8 +141,15 @@ pub struct BuildFromMeta {
|
|||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(tag = "state", rename_all = "kebab-case")]
|
||||
pub enum IconRead {
|
||||
/// The option names an SVG file; `svg` is its text.
|
||||
Set { svg: String },
|
||||
/// The option names an SVG file; `svg` is its text, and `png` is the
|
||||
/// builder's rendering of it, base64, for the forge, whose avatars are
|
||||
/// bitmaps. `png` is absent when the builder could not render it, and from a
|
||||
/// builder that predates it; neither removes an avatar.
|
||||
Set {
|
||||
svg: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
png: Option<String>,
|
||||
},
|
||||
/// The option is not set: the agent has no icon, and an icon it had is
|
||||
/// removed.
|
||||
Unset,
|
||||
|
|
@ -294,6 +301,7 @@ mod tests {
|
|||
nix_builds: Some(NixBuilds::Disabled),
|
||||
icon: Some(IconRead::Set {
|
||||
svg: "<svg/>".to_owned(),
|
||||
png: None,
|
||||
}),
|
||||
},
|
||||
json!({
|
||||
|
|
|
|||
Loading…
Reference in a new issue