Skip to content

Commit

Permalink
cctld: initial impl using kairos-test-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
marijanp committed Mar 20, 2024
1 parent 4e3697e commit f04b4eb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@
cargoArtifacts = self'.packages.kairos-deps;
});

cctld = pkgs.runCommand "cctld-wrapped"
{
buildInputs = [ pkgs.makeWrapper ];
meta.mainProgram = "cctld";
}
''
mkdir -p $out/bin
makeWrapper ${self'.packages.kairos}/bin/cctld $out/bin/cctld \
--set PATH ${pkgs.lib.makeBinPath [inputs'.csprpkgs.packages.cctl ]}
'';

default = self'.packages.kairos;

kairos-docs = craneLib.cargoDoc (kairosNodeAttrs // {
Expand Down
8 changes: 8 additions & 0 deletions kairos-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ version.workspace = true
edition.workspace = true
license.workspace = true

[[bin]]
name = "cctld"
path = "bin/cctld.rs"
version.workspace = true
test = false
bench = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]

Expand All @@ -13,6 +20,7 @@ anyhow = "1"
backoff = { version = "0.4", features = ["tokio", "futures"]}
casper-client = "2"
nom = "7"
sd-notify = "0.4"
tokio = { version = "1", features = [ "full", "tracing", "macros" ] }
tempfile = "3"
tracing = "0.1"
Expand Down
14 changes: 14 additions & 0 deletions kairos-test-utils/bin/cctld.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use kairos_test_utils::cctl;
use sd_notify::NotifyState;
use tokio::signal;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let _network = cctl::CCTLNetwork::run()
.await
.expect("An error occured while starting the CCTL network");

let _ = sd_notify::notify(true, &[NotifyState::Ready]);
signal::ctrl_c().await?;
Ok(())
}

0 comments on commit f04b4eb

Please sign in to comment.