terraform icon indicating copy to clipboard operation
terraform copied to clipboard

Urlparse function

Open Lucasjuv opened this issue 5 years ago • 5 comments

What was done?

  • Sorted the functions in the functions.go file.
  • Added a urlparse function that allows the user to access it parts.

The format of the parts are the defined in net/url package of go: [scheme:][//[userinfo@]host:port][/]path[?query][#fragment]

I believe this could be useful when parsing different urls from git, mongo db and etc. to get details that are usually passed by query or other formats. Please let me know if I need to write more tests or fix something.

Lucasjuv avatar Dec 03 '20 01:12 Lucasjuv

Codecov Report

Merging #27096 (31bb1c8) into master (2119510) will increase coverage by 0.01%. The diff coverage is 82.60%.

Impacted Files Coverage Δ
lang/functions.go 92.19% <60.00%> (-4.08%) :arrow_down:
lang/funcs/url.go 93.54% <93.54%> (ø)
terraform/node_resource_plan.go 96.11% <0.00%> (-1.95%) :arrow_down:
dag/marshal.go 61.90% <0.00%> (-1.59%) :arrow_down:
states/statefile/version4.go 57.96% <0.00%> (-0.24%) :arrow_down:
internal/providercache/dir.go 73.46% <0.00%> (+6.12%) :arrow_up:

codecov[bot] avatar Dec 03 '20 01:12 codecov[bot]

Hi @Lucasjuv! Thanks for working on this.

Was there an earlier feature request issue to discuss the use-cases and design for this?

apparentlymart avatar Dec 03 '20 17:12 apparentlymart

Hi @Lucasjuv! Thanks for working on this.

Was there an earlier feature request issue to discuss the use-cases and design for this?

No, there wasn't. I'm sorry I should have left this as a draft. We ca discuss it here though. I needed to parse a SRV for mongo db into a JSON for my application and it was getting cumbersome to parse query params. I hope It is useful for everyone. I would be glad to make any changes and improvements. I tried to use object with optional attributes but the diff wasn't working properly. I ended up making this PR on go-cty: https://github.com/zclconf/go-cty/pull/79.

Thanks for your time guys.

Lucasjuv avatar Dec 03 '20 19:12 Lucasjuv

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Lucas M Juviniano seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you already have a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

hashicorp-cla avatar Sep 08 '21 11:09 hashicorp-cla

Changelog Warning

Currently this PR would target a v1.13 release. Please add a changelog entry for in the .changes/v1.13 folder, or discuss which release you'd like to target with your reviewer. If you believe this change does not need a changelog entry, please add the 'no-changelog-needed' label.

github-actions[bot] avatar May 19 '25 14:05 github-actions[bot]