Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apps: Convert shortlist string to list #329

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from helpers import cmd


def fetch_target_apps(targets: dict, apps_shortlist: str, token: str, dst_dir: str):
def fetch_target_apps(targets: dict, apps_shortlist: [str], token: str, dst_dir: str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that syntax worked [str]. I guess this is a newer List[str].

apps_fetcher = SkopeAppFetcher(token, dst_dir)
for target_name, target_json in targets.items():
apps_fetcher.fetch_target(FactoryClient.Target(target_name, target_json),
Expand Down Expand Up @@ -45,6 +45,8 @@ def get_args():
help='TUF targets to be updated with URI to fetched app archive')

args = parser.parse_args()
if args.apps_shortlist:
args.apps_shortlist = [x.strip() for x in args.apps_shortlist.split(',') if x]
return args


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