Skip to content

Commit

Permalink
apps: Convert shortlist string to list
Browse files Browse the repository at this point in the history
- Convert the comma-separated list of apps represented as a string and
  provided as an input parameter to a list of string.

- Define the app shortlist as a list of strings in each function of the
  app fetcher.

Signed-off-by: Mike Sul <[email protected]>
  • Loading branch information
mike-sul committed Mar 22, 2024
1 parent 711fa3a commit 8767f3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion apps/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def fetch_target_apps(targets: dict, apps_shortlist: str, token: str, dst_dir: s
apps_fetcher = SkopeAppFetcher(token, dst_dir)
for target_name, target_json in targets.items():
apps_fetcher.fetch_target(FactoryClient.Target(target_name, target_json),
apps_shortlist, force=True)
[x.strip() for x in apps_shortlist.split(',') if x]
if apps_shortlist else None, force=True)


def tar_fetched_apps(src_dir: str, out_file: str):
Expand Down
6 changes: 3 additions & 3 deletions apps/target_apps_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def apps_dir(self, target_name):
def images_dir(self, target_name):
return os.path.join(self.target_dir(target_name), self.ImagesDir)

def fetch_target(self, target: FactoryClient.Target, shortlist=None, force=False):
def fetch_target(self, target: FactoryClient.Target, shortlist: [str] = None, force=False):
self.target_apps.clear()
self.fetch_target_apps(target, apps_shortlist=target.shortlist or shortlist, force=force)
self.fetch_apps_images(force=force)

def fetch_target_apps(self, target: FactoryClient.Target, apps_shortlist=None, force=False):
def fetch_target_apps(self, target: FactoryClient.Target, apps_shortlist: [str] = None, force=False):
self.target_apps[target] = self._fetch_apps(target, apps_shortlist=apps_shortlist, force=force)

def fetch_apps_images(self, graphdriver='overlay2', force=False):
Expand All @@ -71,7 +71,7 @@ def _download_apps_images(apps: ComposeApps, app_images_dir, platform, graphdriv
for app in apps:
app.download_images(platform, dockerd.host)

def _fetch_apps(self, target, apps_shortlist=None, force=False):
def _fetch_apps(self, target, apps_shortlist: [str] = None, force=False):
for app_name, app_uri in target.apps():
if apps_shortlist and app_name not in apps_shortlist:
logger.info('{} is not in the shortlist, skipping it'.format(app_name))
Expand Down

0 comments on commit 8767f3a

Please sign in to comment.