forked from warrensbox/tgswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7971f22
commit 7c0ad45
Showing
13 changed files
with
160 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package lib | ||
|
||
import ( | ||
"fmt" | ||
"sort" | ||
|
||
semver "github.com/hashicorp/go-version" | ||
) | ||
|
||
// GetSemver : returns version that will be installed based on server constaint provided | ||
func GetSemver(tgconstraint *string, proxyUrl string) (string, error) { | ||
|
||
tglist := GetAppList(proxyUrl) //get list of versions | ||
fmt.Printf("Reading required version from constraint: %s\n", *tgconstraint) | ||
tfversion, err := SemVerParser(tgconstraint, tglist) | ||
return tfversion, err | ||
} | ||
|
||
// ValidateSemVer : Goes through the list of terragrunt version, return a valid tf version for contraint provided | ||
func SemVerParser(tfconstraint *string, tflist []string) (string, error) { | ||
tfversion := "" | ||
constraints, err := semver.NewConstraint(*tfconstraint) //NewConstraint returns a Constraints instance that a Version instance can be checked against | ||
if err != nil { | ||
return "", fmt.Errorf("error parsing constraint: %s", err) | ||
} | ||
versions := make([]*semver.Version, len(tflist)) | ||
//put tfversion into semver object | ||
for i, tfvals := range tflist { | ||
version, err := semver.NewVersion(tfvals) //NewVersion parses a given version and returns an instance of Version or an error if unable to parse the version. | ||
if err != nil { | ||
return "", fmt.Errorf("error parsing constraint: %s", err) | ||
} | ||
versions[i] = version | ||
} | ||
|
||
sort.Sort(sort.Reverse(semver.Collection(versions))) | ||
|
||
for _, element := range versions { | ||
if constraints.Check(element) { // Validate a version against a constraint | ||
tfversion = element.String() | ||
fmt.Printf("Matched version: %s\n", tfversion) | ||
if ValidVersionFormat(tfversion) { //check if version format is correct | ||
return tfversion, nil | ||
} | ||
} | ||
} | ||
|
||
PrintInvalidTFVersion() | ||
return "", fmt.Errorf("error parsing constraint: %s", *tfconstraint) | ||
} | ||
|
||
// Print invalid TF version | ||
func PrintInvalidTFVersion() { | ||
fmt.Println("Version does not exist or invalid terraform version format.\n Format should be #.#.# or #.#.#-@# where # are numbers and @ are word characters.\n For example, 0.11.7 and 0.11.9-beta1 are valid versions") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.34.5 | ||
0.37.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
include { | ||
path = "${find_in_parent_folders()}" | ||
} | ||
|
||
terraform { | ||
source = "..." | ||
|
||
extra_arguments "variables" { | ||
commands = get_terraform_commands_that_need_vars() | ||
} | ||
} | ||
inputs = merge( | ||
jsondecode(file("${find_in_parent_folders("general.tfvars")}")) | ||
) | ||
|
||
terragrunt_version_constraint=">= 0.37, < 0.38" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.37.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin = "/usr/local/bin/terragrunt" | ||
version = "0.37.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.31.11 | ||
0.37.4 |