diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2022-05-04 17:06:36 +0100 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2022-05-11 13:20:39 +0100 |
commit | 8602a1d2dfa02a97074b04f5f47ed2e585f650a6 (patch) | |
tree | 96652891303baaaf48cfc16aa9219a0bd5e9517f | |
parent | fc322436a5f54d5772dbf04a589a97ed2eff0854 (diff) | |
download | libvirt-ci-8602a1d2dfa02a97074b04f5f47ed2e585f650a6.zip libvirt-ci-8602a1d2dfa02a97074b04f5f47ed2e585f650a6.tar.gz libvirt-ci-8602a1d2dfa02a97074b04f5f47ed2e585f650a6.tar.bz2 |
lcitool/manifest: delay combining of cidir and basedir paths
The _generate_gitlab method is going to need access to paths
relative to basedir, so that it can generate the include
statements for the gitlab config. The includes must contain
cidir, but not contain basedir.
In order to achieve this, we don't want to combine cidir and
basedir in the constructor, but instead delay it until time
comes to write out the files / create the dirs.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r-- | guests/lcitool/lcitool/manifest.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/guests/lcitool/lcitool/manifest.py b/guests/lcitool/lcitool/manifest.py index 5ac4f10..07b011d 100644 --- a/guests/lcitool/lcitool/manifest.py +++ b/guests/lcitool/lcitool/manifest.py @@ -27,9 +27,9 @@ class Manifest: self.quiet = quiet self.cidir = cidir if basedir is None: - self.outdir = cidir + self.basedir = Path() else: - self.outdir = Path(basedir, cidir) + self.basedir = basedir # Fully expand any shorthand / syntax sugar in the config # so that later stages have a consistent view of the @@ -166,7 +166,7 @@ class Manifest: raise ManifestError(f"Failed to generate configuration: {ex}") def _generate_formatter(self, dryrun, subdir, suffix, formatter, targettype): - outdir = Path(self.outdir, subdir) + outdir = Path(self.basedir, self.cidir, subdir) if not dryrun: outdir.mkdir(parents=True, exist_ok=True) @@ -217,7 +217,7 @@ class Manifest: formatter, "cirrus") def _clean_files(self, generated, dryrun, subdir, suffix): - outdir = Path(self.outdir, subdir) + outdir = Path(self.basedir, self.cidir, subdir) if not outdir.exists(): return @@ -235,6 +235,7 @@ class Manifest: self._clean_files(generated, dryrun, "cirrus", "vars") def _replace_file(self, content, path, dryrun): + path = Path(self.basedir, path) if len(content) == 0: if not self.quiet: print(f"Deleting {path}") @@ -250,10 +251,11 @@ class Manifest: util.atomic_write(path, lines) def _generate_gitlab(self, dryrun): + outdir = Path(self.basedir, self.cidir) if not dryrun: - self.outdir.mkdir(parents=True, exist_ok=True) + outdir.mkdir(parents=True, exist_ok=True) - gitlabfile = Path(self.outdir, "gitlab.yml") + gitlabfile = Path(self.cidir, "gitlab.yml") have_native = False have_cross = False |