Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform-module provider unable to parse some git url #15467

Closed
jrevillard opened this issue May 5, 2022 · 8 comments · Fixed by #15773
Closed

Terraform-module provider unable to parse some git url #15467

jrevillard opened this issue May 5, 2022 · 8 comments · Fixed by #15773
Assignees
Labels
manager:terraform Terraform package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality

Comments

@jrevillard
Copy link

jrevillard commented May 5, 2022

How are you running Renovate?

Self-hosted

If you're self-hosting Renovate, tell us what version of Renovate you run.

32.41.2

Please select which platform you are using if self-hosting.

GitLab self-hosted

If you're self-hosting Renovate, tell us what version of the platform you run.

14.9.4

Was this something which used to work for you, and then stopped?

I never saw this working

Describe the bug

Hello,

I'm trying to make terraform module updates using renovate on our self hosted gitlab instance. Actually, renovate reports 'invalid-version' for this kind of git url:

module "test" {
  source   = "git@my-gitlab-instance.local:devops/terraform/instance.git?ref=v5.0.0"
...
}

If I switch to https://my-gitlab-instance.local/devops/terraform/instance.git?ref=v5.0.0 it works but renovate cannot authenticate properly.

This is already working for instance for the ansible-galaxy so I think that this should also be supported here.

The problem is the regex here.

Best,
Jerome

Relevant debug logs

Logs
{"packageFile":"main.tf","deps":[{"depType":"module","depName":"git@my-gitlab-instance.local:devops/terraform/instance.git?ref=v5.0.0","datasource":"terraform-module","depIndex":0,"updates":[],"warnings":[],"versioning":"hashicorp","skipReason":"invalid-value"},{"depType":"module","depName":"git@my-gitlab-instance.local:devops/terraform/instance.git?ref=v5.0.0","datasource":"terraform-module","depIndex":1,"updates":[],"warnings":[],"versioning":"hashicorp","skipReason":"invalid-value"}

Have you created a minimal reproduction repository?

No reproduction repository

@jrevillard jrevillard added priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality labels May 5, 2022
@rarkins rarkins added manager:terraform Terraform package manager auto:reproduction A minimal reproduction is necessary to proceed labels May 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2022

Hi there,

Help us by making a minimal reproduction repository.

Before we can start work on your issue we first need to know exactly what's causing the current behavior. A minimal reproduction helps us with this.

To get started, please read our guide on creating a minimal reproduction to understand what is needed.

We may close the issue if you (or someone else) have not provided a minimal reproduction within two weeks. If you need more time, or are stuck, please ask for help or more time in a comment.

Good luck,

The Renovate team

@jrevillard
Copy link
Author

jrevillard commented May 5, 2022

If I specify the url using this format it works: ssh://git@my-gitlab-instance.local/devops/terraform/instance.git?ref=v5.0.0

@MaronHatoum
Copy link
Contributor

Hi
I changed this regex:
/(?:git::)?(?<url>(?:http|https|ssh):\/\/(?:.*@)?(?<path>.*.*\/(?<project>.*\/.*)))\?ref=(?<tag>.*)$/
To:
(?:git::)?((?<url>(?:http|https|ssh)(:\/\/))?(?:.*@)?(?<path>.*.*\/(?<project>.*\/.*)))\?ref=(?<tag>.*)$

after this change, the regex matched the problematic URL successfully.
git@my-gitlab-instance.local:devops/terraform/instance.git?ref=v5.0.0

image

@mcfedr
Copy link
Contributor

mcfedr commented May 16, 2022

For authentication to gitlab terraform modules, using https, I use host rules.

I'm using renovate runner on gitlab, so it has the variables used, but you can replace these with the hard coded url and a private token that have access to the repo with modules

      "hostRules": [
        {
          "hostType": "terraform-module",
          "matchHost": "$CI_SERVER_HOST",
          "token": "$CI_JOB_TOKEN"
        }
      ],

@nabeelsaabna nabeelsaabna added priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others and removed priority-5-triage labels May 23, 2022
@MaronHatoum
Copy link
Contributor

minimal reproduction

@rarkins rarkins added reproduction:provided and removed auto:reproduction A minimal reproduction is necessary to proceed labels May 23, 2022
@MaronHatoum
Copy link
Contributor

MaronHatoum commented May 25, 2022

Hi @rarkins @viceice
please advise regarding the new regex I fixed, but it also captures azure devops URLs, please see this.
What should I do:

  1. change the regex to ignore the keyword azure.
  2. add some logic to the code to check azure before git url.

@rarkins
Copy link
Collaborator

rarkins commented May 26, 2022

I think when it's a git URL we can't be sure of what type of host it is, even though "if the host name contains gitlab then it's probably gitlab" is a sound guess.

Do you plan to treat these as git-tags deps? In which case the platform type is not important.

@MaronHatoum
Copy link
Contributor

Yes, Azure URLs are treated as git-tags, i will open a PR.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
manager:terraform Terraform package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others status:requirements Full requirements are not yet known, so implementation should not be started type:bug Bug fix of existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants