Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Items marked [*] are breaking changes.

### Commands

- Remove `show` command. [*]
- Remove `-L` option from `apply` and `compile` commands. [*]
- Add `doers` command, which dumps a list of doers to stdout.
- Add `repl` command, which opens a Janet REPL with the Gurp library loaded into
the root environment.
- Add `--destroy-everything-you-touch` to `apply` command.
- Add `--as-json` option to client mode, for old compile-on-server behaviour.
- Removed `-L` option from `apply` and `compile` commands. [*]
- Removed `show` command. [*]
- `describe` command gives more information, and its layout adjusts for the
terminal width.
- `describe` and `doers` will not use ANSI colouring if `gurp` is part of a
Expand All @@ -29,13 +29,14 @@ Items marked [*] are breaking changes.

### Doers

- Replace `symlink` doer with `link`, which also handles hard links. [*]
- Helpers like `zone-fs` or `smf-method` are now referred to as `zone/fs`
and `smf/method`. [*]
- Add `network-flow` doer.
- Add `vlan` doer.
- Add `ipnat` doer.
- Add `ipfilter` doer.
- Add `limitpriv`, `hostid`, `ip-type`, `pool` to `zone` doer.
- Helpers like `zone-fs` or `smf-method` are now referred to as `zone/fs`
and `smf/method`. [*]
- Changed syntax of `ip-address/ensure`, `ip-properties/ensure`, and
`ip-interface/ensure` to make them all consistent.
- Doer documentation is machine-generated from definition files.
Expand Down
1 change: 1 addition & 0 deletions build_helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ blake3 = "1.8.3"
camino = "1.2.2"
indoc = "2.0.7"
janetrs = "0.8.0"
walkdir = "2.5.0"
21 changes: 15 additions & 6 deletions build_helper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ pub struct ImageHelper {
impl ImageHelper {
pub fn new(src_files: Vec<&str>, img_name: &str) -> Self {
let repo_root = ImageHelper::repo_root();
let src_dir = repo_root.join("janet").join("src");

// Emit rerun directives for all source files
for src_file in &src_files {
println!("cargo:rerun-if-changed=../janet/src/{}", src_file);
for entry in walkdir::WalkDir::new(&src_dir) {
let entry = entry.unwrap();
if entry.path().extension().is_some_and(|e| e == "janet") {
println!("cargo:rerun-if-changed={}", entry.path().display());
}
}

Self {
Expand Down Expand Up @@ -126,9 +129,15 @@ impl ImageHelper {

fn source_hash(&self) -> Hash {
let mut hasher = blake3::Hasher::new();
for src_file in &self.src_files {
let mut fh =
fs::File::open(src_file).expect(&format!("cannot read source file {}", src_file));
let src_dir = self.repo_root.join("janet").join("src");
let mut entries: Vec<_> = walkdir::WalkDir::new(&src_dir)
.into_iter()
.filter_map(|e| e.ok())
.filter(|e| e.path().extension().is_some_and(|x| x == "janet"))
.collect();
entries.sort_by_key(|e| e.path().to_owned()); // stable order
for entry in entries {
let mut fh = fs::File::open(entry.path()).expect("cannot read source file");
std::io::copy(&mut fh, &mut hasher).expect("cannot hash source file");
}
hasher.finalize()
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ camino-tempfile = "1.4.1"
camino-tempfile-ext = "0.3.3"
predicates = "3.1.3"
pretty_assertions = "1.4.1"
serde_json = "1.0.149"
tester = { path = "../tester" }
11 changes: 8 additions & 3 deletions cli/tests/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ mod test {
let canonical_json = load_fixture(&format!("compile/outputs/{host}.json"));
let expected_json = canonical_json.replace(canonical_test_dir, &test_dir);

cargo_bin_cmd!("gurp")
let output = cargo_bin_cmd!("gurp")
.arg("compile")
.arg(fixture(&format!("compile/inputs/{host}.janet")))
.arg("--format=json")
.assert()
.success()
.stdout(expected_json);
.success();

let actual: serde_json::Value =
serde_json::from_slice(&output.get_output().stdout).unwrap();
let expected: serde_json::Value = serde_json::from_str(&expected_json).unwrap();

assert_eq!(actual, expected);
}
}

Expand Down
2 changes: 1 addition & 1 deletion cli/tests/resources/compile/inputs/roles/file-store.janet
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
:compression "lz4"}))

(role file-store
(symlink/ensure "/home" :source home-root)
(link/ensure "/home" :source home-root)

(section users
(zfs/ensure (zfscat globals/fast-pool "export/home/rob")
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/resources/compile/inputs/roles/grafana.janet
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
:content zfs-mount-script
:mode "0755")

(symlink/ensure "/etc/runlevels/boot/zfs-mount"
:source zfs-mounter))
(link/ensure "/etc/runlevels/boot/zfs-mount"
:source zfs-mounter))

(section configure-grafana
(def grafana-config
Expand All @@ -80,8 +80,8 @@
:match "contains"
:pattern "need net")

(symlink/ensure "/etc/runlevels/default/grafana"
:source grafana-init)
(link/ensure "/etc/runlevels/default/grafana"
:source grafana-init)

(file-line/ensure "/etc/conf.d/grafana"
:replace "127.0.0.1" :with "0.0.0.0")
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/resources/compile/inputs/roles/remover.janet
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

# svcprop/remove

(symlink/remove "/var/ld/64")
(symlink/remove "/never/existed")
(link/remove "/var/ld/64")
(link/remove "/never/existed")

# (user/remove "sys") # Protected user
(user/remove "zfssnap")
Expand Down
Loading
Loading