Skip to content

Commit a92b5ed

Browse files
committed
Add Helm and mows template functions with feature flags
- Add helm-functions feature: 152 Helm-compatible template functions - Add mows-functions feature: 3 mows-specific functions (mowsRandomString, mowsDigest, mowsJoindomain) - Add all-functions feature: combines both with all_functions() helper - Separate modules: helm_functions/, mows_functions/, all_functions.rs - Each feature can be enabled independently with minimal dependencies
1 parent 6fa5f26 commit a92b5ed

21 files changed

Lines changed: 5060 additions & 4 deletions

Cargo.toml

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
[package]
22
name = "gtmpl-ng"
3-
version = "0.7.2"
3+
version = "0.7.3"
44
authors = ["Florian Dieminger <me@fiji-flo.de>", "Paul Colin Hennig <8d_fvfmaa-o2wf_79aqig6g2ki6-09ffkeqmyo3d@vindelicum.eu>"]
5-
description = "The Golang Templating Language for Rust (fork with line number fix)"
5+
description = "The Golang Templating Language for Rust (fork with line number fix and Helm functions)"
66
license = "MIT"
77
repository = "https://github.com/firstdorsal/gtmpl-rust"
88
documentation = "https://docs.rs/crate/gtmpl-ng"
9-
keywords = ["golang", "template", "templating"]
9+
keywords = ["golang", "template", "templating", "helm"]
1010
categories = ["template-engine"]
1111
readme = "README.md"
1212
include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE"]
1313
edition = "2018"
1414

1515
[badges]
16-
maintenance = { status = "passively-maintained" }
16+
maintenance = { status = "actively-developed" }
1717

1818
[features]
1919
gtmpl_dynamic_template = []
20+
helm-functions = [
21+
"dep:sha1",
22+
"dep:sha2",
23+
"dep:md5",
24+
"dep:bcrypt",
25+
"dep:rand",
26+
"dep:rcgen",
27+
"dep:time",
28+
"dep:data-encoding",
29+
"dep:serde",
30+
"dep:serde_json",
31+
"dep:serde_yaml",
32+
"dep:regex",
33+
"dep:uuid",
34+
"dep:x509-parser",
35+
"dep:pem",
36+
]
37+
mows-functions = [
38+
"dep:sha1",
39+
"dep:sha2",
40+
"dep:md5",
41+
"dep:rand",
42+
]
43+
all-functions = ["helm-functions", "mows-functions"]
2044

2145
[dependencies]
2246
lazy_static = "1"
@@ -25,5 +49,22 @@ gtmpl_value = "0.5"
2549
anyhow = "1"
2650
thiserror = "1"
2751

52+
# Optional dependencies for helm-functions
53+
sha1 = { version = "0.10", optional = true }
54+
sha2 = { version = "0.10", optional = true }
55+
md5 = { version = "0.7", optional = true }
56+
bcrypt = { version = "0.15", optional = true }
57+
rand = { version = "0.9", optional = true }
58+
rcgen = { version = "0.13", optional = true }
59+
time = { version = "0.3", optional = true }
60+
data-encoding = { version = "2.6", optional = true }
61+
serde = { version = "1", features = ["derive"], optional = true }
62+
serde_json = { version = "1", optional = true }
63+
serde_yaml = { version = "0.9", optional = true }
64+
regex = { version = "1", optional = true }
65+
uuid = { version = "1", features = ["v4"], optional = true }
66+
x509-parser = { version = "0.16", optional = true }
67+
pem = { version = "3", optional = true }
68+
2869
[dev-dependencies]
2970
gtmpl_derive = "0.5"

src/all_functions.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//! Combined template functions module
2+
//!
3+
//! This module provides all template functions (Helm + mows) combined.
4+
//! Enable with the `all-functions` feature flag.
5+
6+
use crate::helm_functions::HELM_FUNCTIONS;
7+
use crate::mows_functions::MOWS_FUNCTIONS;
8+
use crate::Func;
9+
10+
/// Get all template functions (Helm + mows) as a Vec
11+
///
12+
/// This function returns all 155 template functions:
13+
/// - 152 Helm-compatible functions
14+
/// - 3 mows-specific functions
15+
pub fn all_functions() -> Vec<(&'static str, Func)> {
16+
let mut funcs = Vec::with_capacity(HELM_FUNCTIONS.len() + MOWS_FUNCTIONS.len());
17+
funcs.extend_from_slice(&HELM_FUNCTIONS);
18+
funcs.extend_from_slice(&MOWS_FUNCTIONS);
19+
funcs
20+
}
21+
22+
#[cfg(test)]
23+
mod tests {
24+
use super::*;
25+
26+
#[test]
27+
fn test_all_functions_count() {
28+
let funcs = all_functions();
29+
assert_eq!(funcs.len(), 155); // 152 helm + 3 mows
30+
}
31+
}

0 commit comments

Comments
 (0)