Esempio n. 1
0
  def Run(self, args):
    """Yields the differences of packages between two images."""
    # If not specified, both base project and diff project are the user project.

    base_image_ref = args.CONCEPTS.base_image.Parse()
    diff_image_ref = args.CONCEPTS.diff_image.Parse()

    # Use GA to construct the compute API holder since the containeranalysis
    # API always call compute v1 API to refer the compute resources.
    holder = base_classes.ComputeApiHolder(base.ReleaseTrack.GA)
    resource_filter_base = filter_utils.GetFilter(base_image_ref, holder)
    resource_filter_diff = filter_utils.GetFilter(diff_image_ref, holder)

    image_packages_base = containeranalysis_util.MakeOccurrenceRequest(
        project_id=base_image_ref.project, resource_filter=resource_filter_base,
        occurrence_filter=None, resource_urls=None)

    image_packages_diff = containeranalysis_util.MakeOccurrenceRequest(
        project_id=diff_image_ref.project, resource_filter=resource_filter_diff,
        occurrence_filter=None, resource_urls=None)

    package_versions_base = self._GetVersions(image_packages_base,
                                              args.base_image)
    package_versions_diff = self._GetVersions(image_packages_diff,
                                              args.diff_image)

    return self._GetDiff(args, package_versions_base, package_versions_diff)
Esempio n. 2
0
  def Run(self, args):
    """Yields filtered packages."""
    project = properties.VALUES.core.project.Get()
    image_ref = args.CONCEPTS.image.Parse()

    # Use GA to construct the compute API holder since the containeranalysis
    # API always call compute v1 API to refer the compute resources.
    holder = base_classes.ComputeApiHolder(base.ReleaseTrack.GA)
    resource_filter = filter_utils.GetFilter(image_ref, holder)

    image_packages = containeranalysis_util.MakeOccurrenceRequest(
        project_id=project, resource_filter=resource_filter,
        occurrence_filter=None, resource_urls=None)

    return self._GetPackageVersions(image_packages, args.image)