def fetch_apps(self, targets: dict, apps_shortlist=None): for target_name, target_json in targets.items(): target = FactoryClient.Target(target_name, target_json, shortlist=apps_shortlist) self.target_apps[target] = self._fetch_apps( target, apps_shortlist=apps_shortlist)
def setUp(self): self._repo_dir_tmp = tempfile.TemporaryDirectory('repo') self._repo_dir = self._repo_dir_tmp.name self._app_tree = OSTreeRepo(self._repo_dir, create=True) self._app_tree_store = OSTreeTargetAppsStore(self._repo_dir, factory='factory-01') self._target = FactoryClient.Target( 'target-01', OSTreeTargetAppsStoreTest.DefaultTarget)
def main(args: argparse.Namespace): exit_code = os.EX_OK try: target_list = args.targets.split(',') factory_client = FactoryClient(args.factory, args.token) targets = factory_client.get_targets(target_list) apps_fetcher = SkopeAppFetcher(args.token, args.dst_dir) for target in targets: target.shortlist = args.apps_shortlist apps_fetcher.fetch_target(target, force=True) except Exception as exc: logging.error('Failed to pull Target apps and images: {}\n{}'.format( exc, traceback.format_exc())) exit_code = os.EX_SOFTWARE return exit_code
if args.app_shortlist: args.app_shortlist = args.app_shortlist.split(',') return args if __name__ == '__main__': exit_code = 0 try: logging.basicConfig( format='%(asctime)s %(levelname)s: %(module)s: %(message)s', level=logging.INFO) args = get_args() factory_client = FactoryClient(args.factory, args.token) if args.targets: logger.info('Getting Targets for {}'.format(args.targets)) targets = factory_client.get_targets(args.targets) err_msg = 'No Targets found; Factory: {}, input Target list: {}'.format( args.factory, args.targets) else: logger.info('Getting Targets of version {}'.format( args.target_version)) targets = factory_client.get_targets_by_version( args.target_version) err_msg = 'No Targets found; Factory: {}, Version/Build Number: {}'.format( args.factory, args.target_version) found_targets_number = len(targets) if found_targets_number == 0:
args = parser.parse_args() return args if __name__ == '__main__': exit_code = 0 try: logging.basicConfig( format= '%(asctime)s %(levelname)s: Apps Fetcher: %(module)s: %(message)s', level=logging.INFO) args = get_args() target_names = args.targets.split(',') factory_client = FactoryClient(args.factory, args.token) targets = factory_client.get_targets(target_names) app_store = ArchOSTreeTargetAppsStore(args.factory, args.ostree_repo_archive_dir, args.repo_dir) publisher = TargetPublisher(args.factory, args.token, args.cred_arch, targets, app_store, args.fetch_dir, args.treehub_repo_dir) publisher.fetch_targets() publisher.publish_targets() app_store.store_archive() for target in targets:
def __init__(self, token, work_dir, factory=None): if factory: self._factory_client = FactoryClient(factory, token) self._registry_client = DockerRegistryClient(token) self._work_dir = work_dir self.target_apps = {}
if __name__ == '__main__': exit_code = 0 try: logging.basicConfig( format='%(asctime)s %(levelname)s: %(module)s: %(message)s', level=logging.INFO) args = get_args() with open(args.targets_to_publish_file) as f: targets_json = json.load(f) targets_to_publish = [] for target_name, target_json in targets_json.items(): targets_to_publish.append( FactoryClient.Target(target_name, target_json)) app_store = ArchOSTreeTargetAppsStore(args.factory, args.ostree_repo_archive_dir, args.repo_dir) publisher = TargetPublisher(args.factory, args.token, args.cred_arch, targets_to_publish, app_store, args.fetch_dir, args.treehub_repo_dir) publisher.fetch_targets() publisher.publish_targets() app_store.store_archive() # Update targets-created.json (hash of a commit into an ostree repo was added) with open(args.targets_to_publish_file, 'w') as f: json.dump(targets_json, f, indent=2)