mirror of https://github.com/hashicorp/terraform
Merge pull request #16406 from hashicorp/jbardin/version-package
Add a standalone version package for all of terraformpull/16415/head
commit
47c45788bc
@ -1,31 +1,10 @@
|
||||
package terraform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/go-version"
|
||||
"github.com/hashicorp/terraform/version"
|
||||
)
|
||||
|
||||
// The main version number that is being run at the moment.
|
||||
const Version = "0.10.8"
|
||||
|
||||
// A pre-release marker for the version. If this is "" (empty string)
|
||||
// then it means that it is a final release. Otherwise, this is a pre-release
|
||||
// such as "dev" (in development), "beta", "rc1", etc.
|
||||
var VersionPrerelease = "dev"
|
||||
|
||||
// SemVersion is an instance of version.Version. This has the secondary
|
||||
// benefit of verifying during tests and init time that our version is a
|
||||
// proper semantic version, which should always be the case.
|
||||
var SemVersion = version.Must(version.NewVersion(Version))
|
||||
|
||||
// VersionHeader is the header name used to send the current terraform version
|
||||
// in http requests.
|
||||
const VersionHeader = "Terraform-Version"
|
||||
|
||||
// TODO: update providers to use the version package directly
|
||||
func VersionString() string {
|
||||
if VersionPrerelease != "" {
|
||||
return fmt.Sprintf("%s-%s", Version, VersionPrerelease)
|
||||
}
|
||||
return Version
|
||||
return version.String()
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package main
|
||||
|
||||
import "github.com/hashicorp/terraform/terraform"
|
||||
import (
|
||||
"github.com/hashicorp/terraform/version"
|
||||
)
|
||||
|
||||
// The git commit that was compiled. This will be filled in by the compiler.
|
||||
var GitCommit string
|
||||
|
||||
const Version = terraform.Version
|
||||
const Version = version.Version
|
||||
|
||||
var VersionPrerelease = terraform.VersionPrerelease
|
||||
var VersionPrerelease = version.Prerelease
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
// The version package provides a location to set the release versions for all
|
||||
// packages to consume, without creating import cycles.
|
||||
//
|
||||
// This pckage should not import any other terraform packages.
|
||||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
version "github.com/hashicorp/go-version"
|
||||
)
|
||||
|
||||
// The main version number that is being run at the moment.
|
||||
const Version = "0.10.8"
|
||||
|
||||
// A pre-release marker for the version. If this is "" (empty string)
|
||||
// then it means that it is a final release. Otherwise, this is a pre-release
|
||||
// such as "dev" (in development), "beta", "rc1", etc.
|
||||
var Prerelease = "dev"
|
||||
|
||||
// SemVer is an instance of version.Version. This has the secondary
|
||||
// benefit of verifying during tests and init time that our version is a
|
||||
// proper semantic version, which should always be the case.
|
||||
var SemVer = version.Must(version.NewVersion(Version))
|
||||
|
||||
// Header is the header name used to send the current terraform version
|
||||
// in http requests.
|
||||
const Header = "Terraform-Version"
|
||||
|
||||
// String returns the complete version string, including prerelease
|
||||
func String() string {
|
||||
if Prerelease != "" {
|
||||
return fmt.Sprintf("%s-%s", Version, Prerelease)
|
||||
}
|
||||
return Version
|
||||
}
|
||||
Loading…
Reference in new issue