Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions oper8/reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,16 @@ def __init__(
else:
self.home_dir = os.getcwd()

# Create an empty variable for VCS creation. This will be initialized
# during reconcile
self.vcs = None

# If enable_vcs is not provided than default to
# config
if enable_vcs is None:
enable_vcs = config.vcs.enabled

self.enable_vcs = enable_vcs
if enable_vcs:
assert_config(
config.vcs.repo,
Expand All @@ -153,8 +156,6 @@ def __init__(
f"VCS checkout method must be one of the following {vcs_checkout_methods}",
)

self.vcs = VCS(self.home_dir)

# Ensure config is setup correctly for strict_versioning
if config.strict_versioning:
assert_config(
Expand Down Expand Up @@ -219,6 +220,10 @@ def reconcile(
result = ReconciliationResult(requeue=False, requeue_params=RequeueParams())
return result

# If vcs is enabled then configure the repo
if self.enable_vcs:
self.vcs = VCS(self.home_dir)

# Check strict versioning before continuing
if config.strict_versioning:
self._check_strict_versioning(cr_manifest)
Expand Down Expand Up @@ -403,6 +408,11 @@ def setup_vcs(self, cr_manifest: aconfig.Config):
cr_manifest: aconfig.Config
The cr manifest to pull the requested version from.
"""
# If vcs still has not created then create it here. This
# is mainly used by tests
if not self.vcs:
self.vcs = VCS(self.home_dir)

version = get_manifest_version(cr_manifest)
if not version:
raise ValueError("CR Manifest has no version")
Expand Down Expand Up @@ -625,7 +635,11 @@ def _check_strict_versioning(self, cr_manifest: aconfig.Config):
)

# If VCS is enabled ensure the branch or tag exists
if self.vcs:
if self.enable_vcs:
# If vcs is not created then create it here
if not self.vcs:
self.vcs = VCS(self.home_dir)

repo_versions = self.vcs.list_refs()
assert_config(
version in repo_versions,
Expand Down