puppetlabs / bolt

Bolt is an open source orchestration tool that automates the manual work it takes to maintain your infrastructure on an as-needed basis or as part of a greater orchestration workflow. It can be installed on your local workstation and connects directly to remote nodes with SSH or WinRM, so you are not required to install any agent software.
https://puppet.com/docs/bolt/latest/bolt.html
Apache License 2.0
499 stars 225 forks source link

gitlab.rb url malformed splitting #3351

Open n1md4 opened 1 week ago

n1md4 commented 1 week ago

Describe the Bug

My git repo for module install is called gitlab.com.some.thing and because of that when running bolt module install the url is malformed when gitlab.rb is envoked, producing something like gitlab.com/gitlab.com.example.domain. This is obviously wrong and causes a resolving error.

Expected Behavior

When presented with an url that includes gitlab.com as part of the domain name, I would like gitlab.rb to handle the domain ensuring the produced result remains gitlab.com.example.domain.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Initiate a bolt project
  2. Add a custom module to your bolt-project.yaml file, ensure git: is set to gitlab.com.some.thing/team/project.git (for example).
  3. run bolt module install

Environment

Additional Context

I have a temporary work-around that bypasses this issue, but I'm statically defining the target gitlab url (in a few places), which is clearly wrong. I'm no coder though so not submitting an MR, just for notes.

In this file /opt/puppetlabs/bolt/lib/ruby/gems/2.7.0/gems/bolt-3.30.0/lib/bolt/module_installer/specs/id/gitlab.rb I changed these lines:

 26           private_class_method def self.parse_repo(git)
 27             domain = 'gitlab.com.some.thing'
 28 
 29             if git.start_with?("git@#{domain}:")
 30               git.split("git@#{domain}:").last.split('.git').first
 31             elsif git.start_with?("https://#{domain}")
 32               git.split("https://#{domain}/").last.split('.git').first
 33             end
 34           end
 43             metadata_url = "https://gitlab.com.some.thing/#{repo}/-/raw/#{ref}/metadata.json"
 65             url      = "https://gitlab.com.some.thing/api/v4/projects/#{CGI.escape(repo)}/repository/commits/#{ref}"
donoghuc commented 1 week ago

Thanks for the report. The current implementation does not handle custom gitlab domains. Adding support for that seems like a good addition.