Skip to content

Commit

Permalink
Supports all valid protos for remote sources
Browse files Browse the repository at this point in the history
Fixes #13971
  • Loading branch information
lorengordon committed Dec 21, 2019
1 parent d04f97a commit 13738d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions salt/modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import absolute_import, print_function, unicode_literals
import copy
import fnmatch
import re
import os
import logging

Expand Down Expand Up @@ -129,10 +128,10 @@ def valid_fileproto(uri):
salt '*' config.valid_fileproto salt://path/to/file
'''
try:
return bool(re.match('^(?:salt|https?|ftp)://', uri))
except Exception:
return False
return (
six.moves.urllib.parse.urlparse(uri).scheme in
salt.utils.files.VALID_PROTOS
)


def option(
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def cache_file(path, saltenv='base', source_hash=None):

contextkey = '{0}_|-{1}_|-{2}'.format('cp.cache_file', path, saltenv)

path_is_remote = _urlparse(path).scheme in ('http', 'https', 'ftp')
path_is_remote = _urlparse(path).scheme in salt.utils.files.REMOTE_PROTOS
try:
if path_is_remote and contextkey in __context__:
# Prevent multiple caches in the same salt run. Affects remote URLs
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/win_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
continue

# Is the installer in a location that requires caching
if installer.startswith(('salt:', 'http:', 'https:', 'ftp:')):
if __salt__['config.valid_fileproto'](installer):

# Check for the 'cache_dir' parameter in the .sls file
# If true, the entire directory will be cached instead of the
Expand Down

0 comments on commit 13738d1

Please sign in to comment.