File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
lib/puppet/parser/functions Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -28,21 +28,22 @@ module Puppet::Parser::Functions
28
28
require 'open-uri'
29
29
begin
30
30
if args [ 0 ] . start_with? ( 'http://' , 'https://' )
31
- username = ''
32
- password = ''
31
+ http_options = { }
33
32
if ( match = args [ 0 ] . match ( %r{(http\: //|https\: //)(.*):(.*)@(.*)} ) )
34
33
# If URL is in the format of https://username:password@example.local/my_hash.yaml
35
34
protocol , username , password , path = match . captures
36
35
url = "#{ protocol } #{ path } "
36
+ http_options [ :http_basic_authentication ] = [ username , password ]
37
37
elsif ( match = args [ 0 ] . match ( %r{(http\: \/ \/ |https\: \/ \/ )(.*)@(.*)} ) )
38
38
# If URL is in the format of https://username@example.local/my_hash.yaml
39
39
protocol , username , path = match . captures
40
40
url = "#{ protocol } #{ path } "
41
+ http_options [ :http_basic_authentication ] = [ username , password ]
41
42
else
42
43
url = args [ 0 ]
43
44
end
44
45
begin
45
- contents = OpenURI . open_uri ( url , http_basic_authentication : [ username , password ] )
46
+ contents = OpenURI . open_uri ( url , ** http_options )
46
47
rescue OpenURI ::HTTPError => err
47
48
res = err . io
48
49
warning ( "Can't load '#{ url } ' HTTP Error Code: '#{ res . status [ 0 ] } '" )
You can’t perform that action at this time.
0 commit comments