v0.1.2
This commit is contained in:
1 parent
6e57b9e1b8
commit
7b8c7e93fb
48 files changed
+1010
-116
No files matched your search
@@ -120,7 +120,7 @@ enum ConfigCmd {
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum ZonesCmd {
|
||||
/// Create a new primary zone with minimal records (SOA, NS, glue) in <data_dir>/zones/
|
||||
/// Create a new primary zone with minimal records (SOA, NS, glue) in <data_dir>/zones/primary/
|
||||
Create(zonecreate::CreateArgs),
|
||||
List,
|
||||
Show {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! `easydns zone create`: write a minimal, valid primary zone and its definition.
|
||||
//!
|
||||
//! Creates `<data_dir>/zones/<zone>.zone` (SOA, NS, glue for in-zone name servers and
|
||||
//! Creates `<data_dir>/zones/primary/<zone>.zone` (SOA, NS, glue for in-zone name servers and
|
||||
//! optional apex addresses) and `<config dir>/zones.d/<zone>.yaml`, which the default
|
||||
//! configuration includes. Nothing is overwritten without `--force`, and the zone is
|
||||
//! parsed and checked before anything is written.
|
||||
@@ -136,7 +136,7 @@ pub fn render(a: &CreateArgs, serial: u32) -> Result<(String, String), String> {
|
||||
}
|
||||
let _ = glue_used_apex;
|
||||
|
||||
let file = format!("zones/{bare}.zone");
|
||||
let file = format!("zones/primary/{bare}.zone");
|
||||
let mut def = format!("# {bare} – created by `easydns zone create`\n- name: {bare}\n type: primary\n file: {file}\n");
|
||||
let list = |v: &[String]| v.iter().map(|x| format!("\"{x}\"")).collect::<Vec<_>>().join(", ");
|
||||
if !a.allow_transfer.is_empty() {
|
||||
@@ -192,7 +192,7 @@ pub fn create(cfg: &Config, config_path: &Path, a: &CreateArgs) -> Result<Create
|
||||
let records = dns_core::zonefile::parse_str(&text, &zone, None).map_err(|e| format!("generated zone does not parse: {e}"))?;
|
||||
dns_authoritative::Zone::from_records(&zone, records).map_err(|e| format!("generated zone is invalid: {e}"))?;
|
||||
|
||||
let zone_file = cfg.data_dir().join("zones").join(format!("{bare}.zone"));
|
||||
let zone_file = cfg.data_dir().join("zones").join("primary").join(format!("{bare}.zone"));
|
||||
let conf_dir = config_path.parent().map(Path::to_path_buf).unwrap_or_default();
|
||||
let includes_zones_d = cfg.include.iter().any(|p| p.starts_with("zones.d/"));
|
||||
let definition_file = (!a.no_config && includes_zones_d).then(|| conf_dir.join("zones.d").join(format!("{bare}.yaml")));
|
||||
@@ -244,7 +244,7 @@ mod tests {
|
||||
assert!(t.contains("ns1\tIN A 192.0.2.1"));
|
||||
assert!(t.contains("@\tIN A 192.0.2.1"));
|
||||
assert_eq!(valid(&t, "example.com"), 4); // SOA, NS, glue, apex A
|
||||
assert!(def.contains("file: zones/example.com.zone"));
|
||||
assert!(def.contains("file: zones/primary/example.com.zone"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -279,7 +279,7 @@ mod tests {
|
||||
let mut a = args("example.com");
|
||||
a.ns = vec!["ns.example.net".into()];
|
||||
let c = create(&cfg, &cfgp, &a).unwrap();
|
||||
assert!(c.zone_file.ends_with("data/zones/example.com.zone") && c.zone_file.is_file());
|
||||
assert!(c.zone_file.ends_with("data/zones/primary/example.com.zone") && c.zone_file.is_file());
|
||||
assert!(d.join("zones.d/example.com.yaml").is_file());
|
||||
// the new definition is picked up and the zone loads
|
||||
let cfg2 = Config::load(&cfgp).unwrap();
|
||||
|
||||
Reference in new issue
Block a user