Skip to content

Commit

Permalink
Parse cccp.yaml and make sure the nulecule-file attribute gets respected
Browse files Browse the repository at this point in the history
  • Loading branch information
bkabrda committed Jul 27, 2015
1 parent 5988bdd commit 48c0a30
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
31 changes: 23 additions & 8 deletions atomicapp_builder/atomicapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@

class AtomicApp(object):
def __init__(self, app_path, cccp_index, local_registry_uri, tmpdir):
self.app_path = app_path
self.cccp_index = cccp_index
self.cccp_index_entry = None
self.local_registry_uri = local_registry_uri
self.tmpdir = tmpdir

if app_path.startswith('cccp:'):
self.appid = app_path[len('cccp:'):]
app_path = self.checkout()
# TODO: it's possible that this is named differently, read it from .cccp.yaml
self.nulecule_file = os.path.join(app_path, 'Nulecule')
if not os.path.exists(self.nulecule_file):
raise AtomicappBuilderException(
'Nulecule file "{0}" doesn\'t exist'.format(self.nulecule_file))
if self.app_path.startswith('cccp:'):
self.appid = self.app_path[len('cccp:'):]
self.app_path = self.checkout()

self.parse_cccp()
self.parse_nulecule()

self.appid = self.parsed_nulecule['id']
Expand Down Expand Up @@ -91,8 +89,25 @@ def checkout(self):
return os.path.join(self.local_path, entry['git-path'] or '')

def parse_nulecule(self):
self.nulecule_file = os.path.join(
self.app_path,
self.parsed_cccp.get('nulecule-file', 'Nulecule')
)
if not os.path.exists(self.nulecule_file):
raise AtomicappBuilderException(
'Nulecule file "{0}" doesn\'t exist'.format(self.nulecule_file))
self.parsed_nulecule = anymarkup.parse_file(self.nulecule_file)

def parse_cccp(self):
self.cccp_path = os.path.join(self.app_path, '.cccp.yml')
if not os.path.exists(self.cccp_path):
self.cccp_path = os.path.join(self.app_path, 'cccp.yml')
# if cccp file doesn't exist, just silently skip it
self.parsed_cccp = {}
if os.path.exists(self.cccp_path):
self.parsed_cccp = anymarkup.parse_file(self.cccp_path)
print(self.parsed_cccp)

def process_binary_images(self, graph_item):
images = graph_item['images']
for img in images:
Expand Down
6 changes: 6 additions & 0 deletions test/test_atomicapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ def test_process_deps(self, tmpdir):
assert list(sorted(
map(lambda a: str(a.meta_image.imagename), a.processed_deps)
)) == ['appfour', 'apptwo']

def test_cccp_and_different_Nulecule_name(self, tmpdir):
path = prep_app('appfour', tmpdir, 'stable')
a = AtomicApp(path, self.cccp_index, None, str(tmpdir))
assert a.parsed_cccp['nulecule-file'] == 'newlycool'
assert a.parsed_nulecule['id'] == 'appfour'

0 comments on commit 48c0a30

Please sign in to comment.