Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage conf paths #33

Merged
merged 2 commits into from
Dec 23, 2024
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
4 changes: 3 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ tackler-core = "0.6.0"
New features:

* Git Backend: Add support for `revspecs` with `--input.git.ref`

* Add support for new storage keys
** `input.fs.path`, path to top level fs-storage location
** `input.git.repo`, alias for `input.git.repository`

==== Fixes

Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ link:https://tackler.e257.fi/[Tackler] is fast, reliable bookkeeping engine
with native GIT SCM support for plain text accounting, written in Rust.

```bash
~/tackler-ng $ cat example/simle/journal.txn
~/tackler-ng $ cat examples/simple/txns/journal.txn

2024-12-01 'Sweet'n Sour Candies
Expenses:Sweets:Candy 2.50
Expand Down
2 changes: 1 addition & 1 deletion examples/audit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ strict = true
audit = { mode = true, hash = "SHA-256" }
timestamp = { default-time = 00:00:00, timezone = { name = "UTC" } }

input = { storage = "git", git = { repository = "../suite/audit/audit-repo.git", dir = "txns", ref = "txns-1E1", suffix = "txn" } }
input = { storage = "git", git = { repo = "../suite/audit/audit-repo.git", dir = "txns", ref = "txns-1E1", suffix = "txn" } }

[transaction]
accounts = { path = "audit/accounts.toml" }
Expand Down
4 changes: 2 additions & 2 deletions examples/simple.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ strict = false
audit = { mode = false, hash = "SHA-256" }
timestamp = { default-time = 00:00:00, timezone = { name = "UTC" } }

input = { storage = "fs", fs = { dir = "simple", suffix = "txn" } }
input = { storage = "fs", fs = { path = "simple", dir = "txns", suffix = "txn" } }

[transaction]
accounts = { path = "none" }
Expand All @@ -35,4 +35,4 @@ register = { title = "Register Report", accounts = [ "Assets:.*", "Expenses
### Export Configuration
[export]
targets = [ ]
equity = { accounts = [ "^Assets:", ], equity-account = "Equity:Balance" }
equity = { accounts = [ "Assets:.*", ], equity-account = "Equity:Balance" }
File renamed without changes.
14 changes: 7 additions & 7 deletions examples/tackler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ storage = "fs"

### Filesystem based input storage
[kernel.input.fs]
### Top-level directory of storage tree
###
### This is the top level location of txn shard structure,
### the scanning is started from here.
### Path to the FS-storage
###
### If the directory path is relative, then it's based on this file.
### In case of CLI option, it's relative to the current working directory.
### When CLI --input.fs.dir is supplied, this option is ignored.
path = "tackler"
###
### This is root directory of txn shard structure,
### the scanning starts from here.
### CLI: --input.fs.dir
dir = "tackler/txns"
dir = "txns"
### Filename suffix
###
### This is transaction file extension, e.g. all files with
Expand All @@ -116,7 +116,7 @@ suffix = "txn"
### selected by 'kernel.input.storage'
###
### CLI: --input.git.repo
repository = "tackler-data.git"
repo = "tackler-data.git"
### Git reference name
###
### This is git reference name (ref or symbolic ref). It is used
Expand Down
1 change: 1 addition & 0 deletions perf/bin/perf-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ done
done
done

(cd $data_dir; git checkout txns-1E3)
4 changes: 2 additions & 2 deletions perf/perf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ timestamp = { default-time = 00:00:00, timezone = { name = "UTC" } }

[kernel.input]
storage = "git"
fs = { dir = "data/perf-data", suffix = "txn" }
git = { repository = "data/perf-data/.git", dir = "txns", ref = "txns-1E5", suffix = "txn" }
fs = { path = "../../perf/data/perf-data", dir = "txns", suffix = "txn" }
git = { repo = "../../perf/data/perf-data/.git", dir = "txns", suffix = "txn", ref = "txns-1E3" }

[transaction]
accounts = { path = "perf-accounts.toml" }
Expand Down
4 changes: 1 addition & 3 deletions perf/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ Content of `perf-test` directory, next to the `tackler`'s toplevel directory:
----
bin -> ../tackler-ng/perf/bin/
perf.toml -> ../tackler-ng/perf/perf.toml
perf-accounts.toml -> ../tackler-ng/perf/perf-accounts.toml
perf-commodities.toml -> ../tackler-ng/perf/perf-commodities.toml
results -> ../tackler-ng/perf/results
results -> ../tackler-ng/perf/results/
data == perf data
----

10 changes: 7 additions & 3 deletions tackler-cli/CRATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,19 @@ This setup doesn't have any checks enabled and it uses plain filesystem as trans
#### Journal

````
2024-12-01 'Sweet'n Sour Candies
2024-03-20 'Lucky Day!
Assets:Bank:Acme_Inc 420
Income:Lottery

2024-06-20 'Sweet'n Sour Candies
Expenses:Sweets:Candy 2.50
Assets:Cash

2024-12-22 'Hot dogs
2024-09-22 'Hot dogs
Expenses:Food:FastFood 12
Assets:Visa:4012_8888_8888_1881

2024-12-22 'Strawberry ice cream
2024-12-21 'Strawberry ice cream
Expenses:Sweets:Ice·Cream 3
Assets:Cash
````
Expand Down
18 changes: 16 additions & 2 deletions tackler-core/src/config/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,12 @@ pub struct FS {
}
impl FS {
fn from(fs_raw: &FsRaw) -> Result<FS, Box<dyn Error>> {
let dir = match &fs_raw.path {
Some(path) => format!("{}/{}", path, fs_raw.dir),
None => fs_raw.dir.clone(),
};
Ok(FS {
dir: fs_raw.dir.clone(),
dir,
suffix: fs_raw.suffix.clone(),
})
}
Expand All @@ -274,8 +278,18 @@ pub struct Git {
}
impl Git {
fn from(git_raw: &GitRaw) -> Result<Git, Box<dyn Error>> {
let repo = match &git_raw.repo {
Some(repo) => repo.clone(),
None => match &git_raw.repository {
Some(repo) => repo.clone(),
None => {
let msg = "Git is missing 'repo' key";
return Err(msg.into());
}
},
};
Ok(Git {
repo: git_raw.repo.clone(),
repo,
git_ref: git_raw.git_ref.clone(),
dir: git_raw.dir.clone(),
suffix: git_raw.suffix.clone(),
Expand Down
8 changes: 6 additions & 2 deletions tackler-core/src/config/raw_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ pub(super) struct InputRaw {

#[derive(Debug, Clone, Deserialize)]
pub(super) struct FsRaw {
// new key
pub(super) path: Option<String>,
pub(super) dir: String,
pub(super) suffix: String,
}

#[allow(dead_code)]
#[derive(Debug, Clone, Deserialize)]
pub(super) struct GitRaw {
#[serde(rename = "repository")]
pub(super) repo: String,
// old key
pub(super) repository: Option<String>,
// new key
pub(super) repo: Option<String>,
#[serde(rename = "ref")]
pub(super) git_ref: String,
pub(super) dir: String,
Expand Down
Loading