From 7407b14ed2bedb2ad72366b95e00ee9ba727b4cf Mon Sep 17 00:00:00 2001 From: mcarrolle Date: Wed, 1 May 2024 16:14:18 +0200 Subject: [PATCH] Allow ssh transport protocol for a git module spec !bug * **Allow ssh transport protocol** ([#3237](https://github.com/puppetlabs/bolt/issues/3237)) Fix regression introduced by commit [0a09069](https://github.com/puppetlabs/bolt/commit/0a090696cb5807640e894fdbc0d6158edf70184f). Allow install module from git private repository with SSH transport URI (e.g ssh://git@mygitlabserver:12345/namespace/myprivatemod.git) --- lib/bolt/module_installer/specs/git_spec.rb | 4 ++-- spec/unit/module_installer/specs/git_spec_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/bolt/module_installer/specs/git_spec.rb b/lib/bolt/module_installer/specs/git_spec.rb index 72c395d132..e4543f3bf2 100644 --- a/lib/bolt/module_installer/specs/git_spec.rb +++ b/lib/bolt/module_installer/specs/git_spec.rb @@ -45,7 +45,7 @@ def initialize(init_hash, config = {}) unless valid_url?(@git) raise Bolt::ValidationError, - "Invalid URI #{@git}. Valid URIs must begin with 'git@', 'http://', or 'https://'." + "Invalid URI #{@git}. Valid URIs must begin with 'git@', 'http://', 'https://' or 'ssh://'." end end @@ -140,7 +140,7 @@ def sha return true if url.start_with?('git@') uri = URI.parse(url) - uri.is_a?(URI::HTTP) && uri.host + (uri.is_a?(URI::HTTP) || uri.scheme == "ssh") && uri.host rescue URI::InvalidURIError false end diff --git a/spec/unit/module_installer/specs/git_spec_spec.rb b/spec/unit/module_installer/specs/git_spec_spec.rb index 41674aca09..23f8d2cae3 100644 --- a/spec/unit/module_installer/specs/git_spec_spec.rb +++ b/spec/unit/module_installer/specs/git_spec_spec.rb @@ -61,6 +61,11 @@ /Option 'resolve'.*must be a Boolean/ ) end + + it 'allow ssh URI' do + init_hash['git'] = 'ssh://myuser@github.com:12345/puppetlabs/puppetlabs-yaml' + expect { spec }.not_to raise_error + end end context '#to_hash' do