Skip to content

Commit

Permalink
cosabuild/build.py: Tweak variable names
Browse files Browse the repository at this point in the history
Use `builds_dir` instead of `build_dir` to refer to `builds/`, and
`build_dir` instead of `build_root` to refer to `builds/$id/`. This
matches the convention used in the rest of the codebase.
  • Loading branch information
jlebon committed Jul 3, 2019
1 parent 2a00a23 commit 18464d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/cmd-koji-upload
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class Build(_Build):
"""
# locate all the build artifacts in the build directory.
files = []
for ffile in os.listdir(self.build_root):
files.append(os.path.join(self.build_root, ffile))
for ffile in os.listdir(self.build_dir):
files.append(os.path.join(self.build_dir, ffile))
if os.path.islink(ffile):
log.debug(" * EXCLUDING symlink '%s'", ffile)
log.debug(" * target '%s'", os.path.realpath(ffile))
Expand Down
22 changes: 11 additions & 11 deletions src/cosalib/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def write_json(path, data):
os.fchmod(f.file.fileno(), 0o644)
os.rename(f.name, path)


class _Build:
"""
The Build Class handles the reading in and return of build JSON emitted
Expand All @@ -64,13 +65,13 @@ class _Build:
- _build_artifacts(*args, **kwargs)
"""

def __init__(self, build_dir, build="latest", workdir=None):
def __init__(self, builds_dir, build="latest", workdir=None):
"""
init loads the builds.json which lists the builds, loads the relevant
meta-data from JSON and finally, locates the build artifacts.
:param build_dir: name of directory to find the builds
:type build_dir: str
:param builds_dir: name of directory to find the builds
:type builds_dir: str
:param build: build id or "latest" to parse
:type build: str
:param workdir: Temporary directory to ensure exists and is clean
Expand All @@ -83,15 +84,15 @@ def __init__(self, build_dir, build="latest", workdir=None):
If workdir is None then no temporary work directory is created.
"""
log.info('Evaluating builds.json')
builds = load_json('%s/builds.json' % build_dir)
builds = load_json('%s/builds.json' % builds_dir)
if build != "latest":
if build not in builds['builds']:
raise BuildError("Build was not found in builds.json")
else:
build = builds['builds'][0]

log.info("Targeting build: %s", build)
self._build_root = os.path.abspath("%s/%s" % (build_dir, build))
self._build_dir = os.path.abspath("%s/%s" % (builds_dir, build))

self._build_json = {
"commit": None,
Expand Down Expand Up @@ -155,9 +156,9 @@ def build_id(self):
return self.get_meta_key("meta", "buildid")

@property
def build_root(self):
def build_dir(self):
""" return the actual path for the build root """
return self._build_root
return self._build_dir

@property
def build_name(self):
Expand Down Expand Up @@ -220,11 +221,10 @@ def __file(self, var):
:raises: KeyError
"""
lookup = {
"commit": "%s/commitmeta.json" % self.build_root,
"config": ("%s/coreos-assembler-config-git.json" %
self.build_root),
"commit": "%s/commitmeta.json" % self.build_dir,
"config": ("%s/coreos-assembler-config-git.json" % self.build_dir),
"image": "/cosa/coreos-assembler-git.json",
"meta": "%s/meta.json" % self.build_root,
"meta": "%s/meta.json" % self.build_dir,
}
return lookup[var]

Expand Down

0 comments on commit 18464d6

Please sign in to comment.