terraform-version

Crates.ioterraform-version
lib.rsterraform-version
version0.4.0
sourcesrc
created_at2023-02-28 17:17:03.335978
updated_at2023-03-20 18:16:47.742464
descriptionParser and match calculator for terraform version constraint syntax
homepage
repositoryhttps://gitlab.com/vigigloo/libs/terraform-version
max_upload_size
id797273
size25,095
(Nainterceptor)

documentation

README

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.

Commit count: 5

cargo fmt