4 releases (breaking)
0.4.0 | Mar 20, 2023 |
---|---|
0.3.0 | Mar 20, 2023 |
0.2.0 | Mar 14, 2023 |
0.1.0 | Feb 28, 2023 |
#822 in Development tools
130 downloads per month
15KB
215 lines
terraform-version
terraform-version
is a short parser and match calculator for terraform version constraint syntax.
It follows the terraform semantic constraints.
[dependencies]
terraform-version = "0.4"
Compiler support: requires rustc 1.67+
Example
use terraform_version::{Version, VersionRequirement, NumericIdentifiers};
fn main() {
let version_req = VersionRequirement::parse("< 5.4.3, >= 1.2.3").unwrap();
let version = Version::parse("1.2.3").unwrap();
assert!(version.matches(&version_req));
let version = Version::parse("5.4.4").unwrap();
assert!(!version.matches(&version_req));
let version_req = VersionRequirement::parse("= 1.2.3-beta").unwrap();
let version = Version::parse("1.2.3-beta").unwrap();
assert!(version.matches(&version_req));
let version = Version {
numeric_identifiers: NumericIdentifiers::new(vec![1, 2, 3]),
suffix: None
};
assert!(!version.matches(&version_req));
}
License
terraform-version
is provided under the MIT license. See LICENSE.
Dependencies
~1–1.5MB
~26K SLoC