Skip to content

Commit 8dd711f

Browse files
committed
rename all references of key_agent to agent for consistency
Unifying the key agent with the magic rollback feature soon to be implemented
1 parent 9e2d3a8 commit 8dd711f

File tree

13 files changed

+37
-37
lines changed

13 files changed

+37
-37
lines changed

Cargo.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["wire/key_agent", "wire/lib", "wire/cli"]
2+
members = ["wire/agent", "wire/lib", "wire/cli"]
33
resolver = "2"
44
package.edition = "2021"
55
package.version = "0.1.0"

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
./nix/shells.nix
3030
./nix/checks.nix
3131
./wire/cli
32-
./wire/key_agent
32+
./wire/agent
3333
./doc
3434
./tests/nix
3535
];

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ build-dhat:
44
cargo build --profile profiling --features dhat-heap
55
@echo 'dhat binaries in target/profiling'
66
@echo 'Example:'
7-
@echo 'WIRE_RUNTIME=/nix/store/...-runtime WIRE_KEY_AGENT=/nix/store/...-key_agent-0.1.0 PROJECT/target/profiling/wire apply ...'
7+
@echo 'WIRE_RUNTIME=/nix/store/...-runtime WIRE_AGENT=/nix/store/...-agent-0.1.0 PROJECT/target/profiling/wire apply ...'

wire/key_agent/Cargo.toml renamed to wire/agent/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "key_agent"
2+
name = "agent"
33
edition.workspace = true
44
version.workspace = true
55

File renamed without changes.

wire/key_agent/default.nix renamed to wire/agent/default.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
{
88
packages = {
99
agent = buildRustProgram {
10-
name = "key_agent";
11-
pname = "key_agent";
12-
cargoExtraArgs = "-p key_agent";
10+
name = "agent";
11+
pname = "agent";
12+
cargoExtraArgs = "-p agent";
1313
};
1414
};
1515
};
File renamed without changes.
File renamed without changes.

wire/key_agent/src/main.rs renamed to wire/agent/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
use tokio::fs::File;
1212
use tokio::io::AsyncWriteExt;
1313

14-
use key_agent::keys::Keys;
14+
use agent::keys::Keys;
1515

1616
fn create_path(key_path: &Path) -> Result<(), anyhow::Error> {
1717
let prefix = key_path.parent().unwrap();

wire/lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ thiserror = "1.0.62"
1919
serde_repr = "0.1.20"
2020
regex = "1.11.1"
2121
derive_more = "0.99.18"
22-
key_agent = { path = "../key_agent" }
22+
agent = { path = "../agent" }
2323
futures = "0.3.31"
2424
prost = { workspace = true }
2525
gethostname = "1.0.1"

wire/lib/src/hive/key.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ async fn copy_buffers<T: AsyncWriteExt + Unpin>(
128128
Ok(())
129129
}
130130

131-
async fn process_key(key: &Key) -> Result<(key_agent::keys::Key, Vec<u8>), Error> {
131+
async fn process_key(key: &Key) -> Result<(agent::keys::Key, Vec<u8>), Error> {
132132
let mut reader = create_reader(&key.source).await?;
133133

134134
let mut buf = Vec::new();
@@ -146,7 +146,7 @@ async fn process_key(key: &Key) -> Result<(key_agent::keys::Key, Vec<u8>), Error
146146
);
147147

148148
Ok((
149-
key_agent::keys::Key {
149+
agent::keys::Key {
150150
length: buf
151151
.len()
152152
.try_into()
@@ -164,17 +164,17 @@ async fn process_key(key: &Key) -> Result<(key_agent::keys::Key, Vec<u8>), Error
164164
pub struct UploadKeyStep {
165165
pub moment: UploadKeyAt,
166166
}
167-
pub struct PushKeyAgentStep;
167+
pub struct PushAgentStep;
168168

169169
impl Display for UploadKeyStep {
170170
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
171171
write!(f, "Upload key @ {:?}", self.moment)
172172
}
173173
}
174174

175-
impl Display for PushKeyAgentStep {
175+
impl Display for PushAgentStep {
176176
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
177-
write!(f, "Push the key agent")
177+
write!(f, "Push the agent")
178178
}
179179
}
180180

@@ -207,7 +207,7 @@ impl ExecuteStep for UploadKeyStep {
207207
}
208208

209209
async fn execute(&self, ctx: &mut Context<'_>) -> Result<(), HiveLibError> {
210-
let agent_directory = ctx.state.key_agent_directory.as_ref().unwrap();
210+
let agent_directory = ctx.state.agent_directory.as_ref().unwrap();
211211

212212
let futures = ctx
213213
.node
@@ -219,15 +219,15 @@ impl ExecuteStep for UploadKeyStep {
219219
})
220220
.map(|key| async move { process_key(key).await });
221221

222-
let (keys, bufs): (Vec<key_agent::keys::Key>, Vec<Vec<u8>>) = join_all(futures)
222+
let (keys, bufs): (Vec<agent::keys::Key>, Vec<Vec<u8>>) = join_all(futures)
223223
.await
224224
.into_iter()
225225
.collect::<Result<Vec<_>, Error>>()
226226
.map_err(HiveLibError::KeyError)?
227227
.into_iter()
228228
.unzip();
229229

230-
let msg = key_agent::keys::Keys { keys };
230+
let msg = agent::keys::Keys { keys };
231231

232232
trace!("Sending message {msg:?}");
233233

@@ -237,7 +237,7 @@ impl ExecuteStep for UploadKeyStep {
237237

238238
let mut child = command
239239
.args([
240-
format!("{agent_directory}/bin/key_agent"),
240+
format!("{agent_directory}/bin/agent"),
241241
buf.len().to_string(),
242242
])
243243
.stdout(Stdio::piped())
@@ -278,20 +278,20 @@ impl ExecuteStep for UploadKeyStep {
278278
}
279279

280280
#[async_trait]
281-
impl ExecuteStep for PushKeyAgentStep {
281+
impl ExecuteStep for PushAgentStep {
282282
fn should_execute(&self, ctx: &Context) -> bool {
283283
should_execute(&UploadKeyAt::AnyOpportunity, ctx)
284284
}
285285

286286
async fn execute(&self, ctx: &mut Context<'_>) -> Result<(), HiveLibError> {
287-
let agent_directory = match env::var_os("WIRE_KEY_AGENT") {
287+
let agent_directory = match env::var_os("WIRE_AGENT") {
288288
Some(agent) => agent.into_string().unwrap(),
289-
None => panic!("WIRE_KEY_AGENT environment variable not set"),
289+
None => panic!("WIRE_AGENT environment variable not set"),
290290
};
291291

292292
push(ctx.node, ctx.name, Push::Path(&agent_directory)).await?;
293293

294-
ctx.state.key_agent_directory = Some(agent_directory);
294+
ctx.state.agent_directory = Some(agent_directory);
295295

296296
Ok(())
297297
}

wire/lib/src/hive/node.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tracing_indicatif::span_ext::IndicatifSpanExt;
1212
use crate::nix::StreamTracing;
1313
use crate::SubCommandModifiers;
1414

15-
use super::key::{Key, PushKeyAgentStep, UploadKeyAt, UploadKeyStep};
15+
use super::key::{Key, PushAgentStep, UploadKeyAt, UploadKeyStep};
1616
use super::steps::activate::SwitchToConfigurationStep;
1717
use super::HiveLibError;
1818

@@ -117,7 +117,7 @@ pub trait ExecuteStep: Send + Sync + Display {
117117
pub struct StepState {
118118
pub evaluation: Option<Derivation>,
119119
pub build: Option<String>,
120-
pub key_agent_directory: Option<String>,
120+
pub agent_directory: Option<String>,
121121
}
122122

123123
pub struct Context<'a> {
@@ -139,7 +139,7 @@ impl<'a> GoalExecutor<'a> {
139139
pub fn new(context: Context<'a>) -> Self {
140140
Self {
141141
steps: vec![
142-
Box::new(PushKeyAgentStep),
142+
Box::new(PushAgentStep),
143143
Box::new(UploadKeyStep {
144144
moment: UploadKeyAt::AnyOpportunity,
145145
}),

0 commit comments

Comments
 (0)