• Infrastructure
    • terraform
    • packer
  • Networking
    • consul
  • Security
    • vault
    • boundary
  • Applications
    • nomad
    • waypoint
    • vagrant
  • HashiCorp Cloud Platform

    A fully managed platform to automate infrastructure on any cloud with HashiCorp products.

    • consul
    • terraform
    • vault
    • packerbeta
    Visit cloud.hashicorp.com
Sentinel
  • Intro
  • Docs
Download
    • v0.19.x (latest)
    • v0.18.x
    • v0.17.x
    • v0.16.x
    • v0.15.x
    • v0.14.x
    • v0.13.x
  • Release Notes
    • Overview
    • Policy as Code
    • Policy Language
    • Imports
    • Enforcement Levels
    • Overview
    • Override Files
    • Remote Sources
    • Overview
    • apply
    • fmt
    • test
    • Overview
    • Basics
    • Rules
    • Traces
    • Testing
    • Imports
    • Debugging
    • Overview
    • Modules
    • Plugins
    • Static Imports
    • Internals

    • Overview
    • Variables
    • Values
    • Lists
    • Maps
    • Rules
    • Imports
    • Parameters
    • Boolean Expressions
    • Arithmetic
    • Slices
    • Conditionals
    • Loops
    • Collection Operations
    • Functions
    • Scope
    • Undefined
    • Logging and Errors
    • Specification
    • Overview
    • append
    • delete
    • error
    • keys
    • length
    • print
    • range
    • values
    • Overview
    • base64
    • decimal
    • http
    • json
    • runtime
    • sockaddr
    • strings
    • time
    • types
    • units
    • version

  • Consul
  • Nomad
  • Terraform
  • Vault
Type '/' to Search

»Import: version

The version import provides functions for parsing versions and version constraints, and verifying versions against a set of constraints.

Versions are created through the new function, which accepts a string type in dotted-tri format (i.e. 1.0.0-alpha.1+001) that can represent a version.

»version.new(v)

Constructs a version from string value.

version.new("1.0.0-alpha.1+001")

»version.major

An integer representation of the Major number for a given version .

version.new("1.0.0-alpha.1+001").major     // 1

»version.minor

An integer representation of the Minor number for a given version.

version.new("1.0.0-alpha.1+001").minor     // 0

»version.patch

An integer representation of the Patch number for a given version.

version.new("1.0.0-alpha.1+001").patch     // 0

»version.prerelease

A string representation of the Prerelease for a given version.

version.new("1.0.0-alpha.1+001").prerelease     // "alpha.1"

»version.metadata

A string representation of the Metadata for a given version.

version.new("1.0.0-alpha.1+001").metadata     // "001"

»version.version

A string representation of the version including pre-release and metadata information.

version.new("1.0.0-alpha.1+001").version     // "1.0.0-alpha.1+001"

»version.greater_than(v)

Tests that the version is greater than a given version.

version.new("1.0.0-alpha.1+001").greater_than("0.12.0-alpha.1+001")     // True
version.new("1.0.0-alpha.1+001").gt("1.0.1-alpha.1+001")                // False

»version.greater_than_or_equals(v)

Tests that the version is greater than or equal to a given version.

version.new("1.0.0-alpha.1+001").greater_than_or_equals("1.0.0-alpha.1+001")     // True
version.new("1.0.0-alpha.1+001").gte("1.0.1-alpha.1+001")                        // False

»version.less_than(v)

Tests that the version is less than a given version.

version.new("1.0.0-alpha.1+001").less_than("1.0.1-alpha.1+001")     // True
version.new("1.0.0-alpha.1+001").lt("0.12.0-alpha.1+001")           // False

»version.less_than_or_equals(v)

Tests that the version is less than or equal to a given version.

version.new("1.0.0-alpha.1+001").less_than_or_equals("1.0.0-alpha.1+001")     // True
version.new("1.0.0-alpha.1+001").lte("0.12.0-alpha.1+001")                    // False

»version.less_than_or_equals(v)

Tests that the version equals a given version.

version.new("1.0.0-alpha.1+001").equals("1.0.0-alpha.1+001")     // True
version.new("1.0.0-alpha.1+001").eq("0.12.0-alpha.1+001")        // False

»version.compare(v)

Compares one version with a given version. Compare returns -1, 0, or 1 if the version is less, equal, or greater than the other version, respectively.

version.new("1.0.0-alpha.1+001").compare("0.12.0-alpha.1+001")    // -1
version.new("1.0.0-alpha.1+001").compare("1.0.0-alpha.1+001")     // 0
version.new("0.12.0-alpha.1+001").cmp("1.0.0-alpha.1+001")        // 1

»version.satisfies(v, x)

Tests that a version adheres to one or more version constraints. Satisfies supports the following restriction operators:

  • =
  • !=
  • >
  • <
  • >=
  • <=
  • ~>

Satisfies supports the following usage scenarios:

  • A constraint with a pre-release can only match a pre-release version that contains the same major, minor and patch identifiers.
  • A constraint without a pre-release can only match a version without a pre-release.
version.new("1.0.0-alpha.1+001").satisfies("> 1.0.0-alpha.1+001")                       // false
version.new("1.0.0-alpha.1+001").satisfies(">= 1.0.0-alpha.1+001")                      // true
version.new("1.0.0-alpha.1+001").satisfies(">= 1.0.0-alpha.1+001, < 1.0.0-beta+001")    // true
version.new("1.0.0").sat("= 1.0.0")                                                     // true
version.new("0.12.7").sat("~> 0.12.0")                                                  // true
  • ProvisionMulti-Cloud Infrastructure
  • SecureMulti-Cloud Security
  • ConnectMulti-Cloud Networking
  • RunMulti-Cloud Orchestration
Products
  • Terraform
  • Vault
  • Consul
  • Nomad
  • Vagrant
  • Packer
  • Boundary NEW
  • Waypoint NEW
  • Sentinel
Resources
  • Blog
  • Tutorials
  • Community
  • Events
  • Integrations
  • Library
  • Partners
  • Podcast
  • Support
  • Training
Company
  • About Us
  • JobsWe're Hiring
  • Press Center
  • Brand
  • Contact Us
  • System Status
  • Cookie Manager
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
stdin: is not a tty