Exemplo n.º 1
0
def component_diff_since_last_release(
    component_name,
    component_version,
    component_descriptor,
    cfg_factory,
):
    component = ci.util.not_none(
        component_descriptor.component((component_name, component_version)))

    resolver = ComponentResolver(cfg_factory=cfg_factory)
    last_release_version = resolver.greatest_release_before(
        component_name=component_name, version=component_version)

    if not last_release_version:
        ci.util.warning('could not determine last release version')
        return None
    last_release_version = str(last_release_version)
    ci.util.info('last released version: ' + str(last_release_version))

    descriptor_resolver = ComponentDescriptorResolver(cfg_factory=cfg_factory)
    last_released_component_descriptor = descriptor_resolver.retrieve_descriptor(
        (component_name, last_release_version))
    last_released_component = last_released_component_descriptor.component(
        (component_name, last_release_version))

    if not last_released_component:
        ci.util.fail(
            f"Component '{component_name}' not found in the component "
            f"descriptor of the last release ({last_release_version}).")

    diff = diff_components(
        left_components=component.dependencies().components(),
        right_components=last_released_component.dependencies().components(),
    )
    return diff
Exemplo n.º 2
0
def resolve_component_descriptor(
        component_descriptor_file: CliHints.existing_file(), ):
    cfg_factory = ctx().cfg_factory()

    resolver = ComponentDescriptorResolver(cfg_factory=cfg_factory, )

    with open(component_descriptor_file) as f:
        component_descriptor = Product.from_dict(yaml.load(f))

    resolved_descriptor = resolver.resolve_component_references(
        product=component_descriptor)

    print(yaml.dump(resolved_descriptor.raw))
Exemplo n.º 3
0
def resolve_component_descriptor(
        component_descriptor: CliHints.existing_file(), ):
    cfg_factory = ctx().cfg_factory()

    resolver = ComponentDescriptorResolver(cfg_factory=cfg_factory, )

    component_descriptor = ComponentDescriptor.from_dict(
        parse_yaml_file(component_descriptor))

    resolved_descriptor = resolver.resolve_component_references(
        product=component_descriptor)

    print(yaml.dump(resolved_descriptor.raw))
Exemplo n.º 4
0
def retrieve_component_descriptor(
    name: str,
    version: str,
):
    cfg_factory = ctx().cfg_factory()

    resolver = ComponentDescriptorResolver(
        cfg_factory=cfg_factory,
    )

    component_reference = ComponentReference.create(name=name, version=version)
    try:
        resolved_descriptor = resolver.retrieve_raw_descriptor(component_reference)
    except github3.exceptions.NotFoundError:
        fail('no component descriptor found: {n}:{v}'.format(n=name, v=version))

    print(resolved_descriptor)