Example #1
0
def main(factory: str, sha: str, targets_json: str, machines: [],
         platforms: [], app_root_dir: str, publish_tool: str,
         apps_version: str, target_tag: str, target_version: str,
         new_targets_file: str):
    convert_docker_apps()
    status('Searching for Compose Apps in {}'.format(app_root_dir))
    apps = ComposeApps(app_root_dir)
    status('Found Compose Apps: {}'.format(apps.str))

    status('Compose Apps has been validated: {}'.format(apps.str))

    apps_to_add_to_target = AppsPublisher(
        factory, publish_tool,
        ','.join(platforms) if platforms else '').publish(apps, apps_version)

    status(
        'Creating Targets that refer to the published Apps; tag: {}, version: {}, machines: {}, platforms: {} '
        .format(target_tag, target_version,
                ','.join(machines) if machines else '[]',
                ','.join(platforms) if platforms else '[]'))
    new_targets = create_target(targets_json, apps_to_add_to_target,
                                target_tag, sha, machines, platforms,
                                target_version, new_targets_file)
    if len(new_targets) == 0:
        logger.error('Failed to create Targets for the published Apps')
        return 1

    return 0
Example #2
0
 def test_compose_apps_app_images(self):
     app = ComposeApps(self.apps_root_dir)[0]
     expected_images = [
         'hub.foundries.io/test_factory/nginx', 'nginx:1.19.2-alpine',
         'hub.foundries.io/test_factory/app-07:latest'
     ]
     for image in app.images():
         self.assertIn(image, expected_images)
Example #3
0
    def setUp(self):
        self.apps_root_dir = tempfile.mkdtemp()
        self.app_name = 'app1'
        os.mkdir(os.path.join(self.apps_root_dir, self.app_name))
        with open(os.path.join(self.apps_root_dir, self.app_name, ComposeApps.App.ComposeFile), 'w') as compose_file:
            yaml_data = yaml.safe_load(self.ComposeAppDesc)
            yaml.dump(yaml_data, compose_file)

        self.apps = ComposeApps(self.apps_root_dir)
Example #4
0
    def setUp(self):
        self.apps_root_dir = tempfile.mkdtemp()
        self.app_name = 'app1'
        self.factory = 'test_factory'
        self.publish_tool = 'some-fake-publish-tool'

        os.mkdir(os.path.join(self.apps_root_dir, self.app_name))
        with open(os.path.join(self.apps_root_dir, self.app_name, ComposeApps.App.ComposeFile), 'w') as compose_file:
            yaml_data = yaml.safe_load(self.ComposeAppDesc)
            yaml.dump(yaml_data, compose_file)

        self.apps = ComposeApps(self.apps_root_dir)
        self.publisher = AppsPublisher(self.factory, self.publish_tool)
Example #5
0
    def _fetch_apps(self, target, apps_shortlist=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))
                continue

            app_dir = os.path.join(self.apps_dir(target.name), app_name)
            if not os.path.exists(app_dir) or force:
                os.makedirs(app_dir, exist_ok=True)
                logger.info('Downloading App; Target: {}, App: {}, Uri: {} '.format(target.name, app_name, app_uri))
                self._registry_client.download_compose_app(app_uri, app_dir)
            else:
                logger.info('App has been already fetched; Target: {}, App: {}'.format(target.name, app_name))
        return ComposeApps(self.apps_dir(target.name))
Example #6
0
 def test_compose_apps_app_init(self):
     app = ComposeApps(self.apps_root_dir)[0]
     self.assertEqual(len(app.services()), 3)
Example #7
0
 def test_compose_apps_init(self):
     apps = ComposeApps(self.apps_root_dir)
     self.assertEqual(len(apps), 1)
     self.assertEqual(apps.str, self.app_name)
     self.assertEqual(len(apps), 1)