Tidy up collect output file names for cloned repos
This patch set tidies up collect output file names for cloned
repos. As an example, previously the output file could be named
something like tmp5ak7409aic-clcp-security-manifests.yaml -- after
this change it will be aic-clcp-security-manifests.yaml instead
which is much cleaner.
Pegleg "collect" looks at the last piece in a file path to
determine the filename to write to: [0]
This means that changing the clone path here from something like:
/tmp/tmp54d13yairship-pegleg (which will result in collection
output to tmp54d13yairship-pegleg.yaml)
To:
/tmp/tmp54d13y/airship-pegleg (which will result in collection
output to airship-pegleg.yaml)
[0] 2ea1a55a2d/pegleg/engine/site.py (L71)
Change-Id: I2198e299d392e24d376ccfa53bef57fcabf0d41b
This commit is contained in:
parent
fde70e9218
commit
ba1842c02e
@ -157,7 +157,11 @@ def _try_git_clone(repo_url, ref=None, proxy_server=None, auth_key=None):
|
|||||||
|
|
||||||
# the name here is important as it bubbles back up to the output filename
|
# the name here is important as it bubbles back up to the output filename
|
||||||
# and ensure we handle url/foo.git/ cases. prefix is 'tmp' by default.
|
# and ensure we handle url/foo.git/ cases. prefix is 'tmp' by default.
|
||||||
temp_dir = tempfile.mkdtemp(suffix=repo_url.rstrip('/').split('/')[-1])
|
root_temp_dir = tempfile.mkdtemp()
|
||||||
|
repo_name = repo_url.rstrip('/').split('/')[-1]
|
||||||
|
temp_dir = os.path.join(root_temp_dir, repo_name)
|
||||||
|
os.makedirs(temp_dir)
|
||||||
|
|
||||||
env_vars = _get_clone_env_vars(repo_url, ref, auth_key)
|
env_vars = _get_clone_env_vars(repo_url, ref, auth_key)
|
||||||
ssh_cmd = env_vars.get('GIT_SSH_COMMAND')
|
ssh_cmd = env_vars.get('GIT_SSH_COMMAND')
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class TestSiteCliActions(object):
|
|||||||
assert len(collected_files) == 1
|
assert len(collected_files) == 1
|
||||||
# Validates that site manifests collected from cloned repositories
|
# Validates that site manifests collected from cloned repositories
|
||||||
# are written out to sensibly named files like airship-treasuremap.yaml
|
# are written out to sensibly named files like airship-treasuremap.yaml
|
||||||
assert collected_files[0].endswith("%s.yaml" % self.repo_name)
|
assert collected_files[0] == ("%s.yaml" % self.repo_name)
|
||||||
|
|
||||||
def test_collect_using_local_path(self):
|
def test_collect_using_local_path(self):
|
||||||
"""Validates collect action using a path to a local repo."""
|
"""Validates collect action using a path to a local repo."""
|
||||||
@ -103,4 +103,4 @@ class TestSiteCliActions(object):
|
|||||||
assert len(collected_files) == 1
|
assert len(collected_files) == 1
|
||||||
# Validates that site manifests collected from cloned repositories
|
# Validates that site manifests collected from cloned repositories
|
||||||
# are written out to sensibly named files like airship-treasuremap.yaml
|
# are written out to sensibly named files like airship-treasuremap.yaml
|
||||||
assert collected_files[0].endswith("%s.yaml" % self.repo_name)
|
assert collected_files[0] == ("%s.yaml" % self.repo_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user