Skip to content

Commit

Permalink
make sure that origin url is trimmed not only for github
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Devyatkin <[email protected]>
  • Loading branch information
Andrey9kin committed Jul 12, 2021
1 parent 4d1cf34 commit 36831c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ override.tf.json
# example: *tfplan*

/.idea/
.terraform.lock.hcl
10 changes: 9 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ locals {
gc_ttl = "${local.main_prefix}${var.separator}garbage-collector${var.separator}time-to-live"
gc_other = "${local.main_prefix}${var.separator}garbage-collector${var.separator}other"

git_origin_url = trimprefix(trimprefix(trimsuffix(lower(data.external.git_origin_url.result["Result"]), ".git"), "[email protected]:"), "https://github.com/")
# We are dealing with situation when url will be one of those two
# [email protected]:fivexl/terraform-aws-tag-generator.git
# https://github.com/fivexl/terraform-aws-tag-generator.git
# So what we do is we trim off possible prefixes - git@ and https://
# as well as suffix .git
# final step we replace : in case of git based url to / so the result will be the same string
# no matter what type of download is being used
git_origin_url = replace(trimprefix(trimprefix(trimsuffix(lower(data.external.git_origin_url.result["Result"]), ".git"), "git@"), "https://"), ":", "/")

git_module_source = lower(data.external.git_module_source.result["Result"])

git_remote_value = local.git_origin_url != "" ? { (local.git_remote) = local.git_origin_url } : {}
Expand Down

0 comments on commit 36831c9

Please sign in to comment.