File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,9 @@ pod_name: ""
140140# Version Control System Config
141141vcs :
142142 enabled : false
143+ # If kind_regex is provided then only Kind's that match that regex will be checked out.
144+ # The default regex ignores temporary patches since they are unversioned
145+ kind_regex : " ^((?!TemporaryPatch).*)$"
143146
144147 # Source and destination directories
145148 repo : null
Original file line number Diff line number Diff line change @@ -168,6 +168,8 @@ def __init__(
168168 "Must provide vcs.field with strict_versioning=True" ,
169169 )
170170
171+ self .vcs_kind_regex = re .compile (config .vcs .kind_regex or ".*" )
172+
171173 self .deploy_manager = deploy_manager
172174 self .reimport_controller = reimport_controller
173175
@@ -407,6 +409,10 @@ def setup_vcs(self, cr_manifest: aconfig.Config):
407409 cr_manifest: aconfig.Config
408410 The cr manifest to pull the requested version from.
409411 """
412+ if not self .vcs_kind_regex .match (cr_manifest .get ("kind" , "" )):
413+ log .debug ("Skipping vcs checkout due to kind regex" )
414+ return
415+
410416 version = get_manifest_version (cr_manifest )
411417 if not version :
412418 raise ValueError ("CR Manifest has no version" )
Original file line number Diff line number Diff line change @@ -389,6 +389,31 @@ def test_setup_vcs_invalid_module_dir():
389389 rm .setup_vcs (cr )
390390
391391
392+ def test_setup_vcs_default_skip_path (cleanup_vcs ):
393+ """Test that setup_vcs correctly skips kind regex matches"""
394+
395+ # Setup required variables
396+ with tempfile .TemporaryDirectory () as vcs_directory :
397+ rm = ReconcileManager ()
398+
399+ # Capture current path/cwd for checks
400+ current_cwd = os .getcwd ()
401+ current_path = copy .deepcopy (sys .path )
402+
403+ # Create a TemporaryPatch CR which should be skipped
404+ cr = setup_cr ("TemporaryPatch" )
405+
406+ # Patch setup_directory as that's tested separately and manually create
407+ # the module directory
408+ with library_config ():
409+ create_module_dir (vcs_directory )
410+ rm .setup_vcs (cr )
411+
412+ # Assert that the cwd is unaffected
413+ assert os .getcwd () == current_cwd
414+ assert sys .path == current_path
415+
416+
392417######################
393418## setup_controller ##
394419######################
You can’t perform that action at this time.
0 commit comments