terraform-version

Parser and match calculator for terraform version constraint syntax

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
Download history 2/week @ 2024-09-23 4/week @ 2024-09-30

130 downloads per month

MIT license

15KB
215 lines

terraform-version

pipeline status MIT licensed Crates.io

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.7–2.4MB
~42K SLoC