Example #1
0
 def _check_args(self):
     options = self.options
     check_options_set(options, ["swagger_codegen_cli_jar_path"])
     check_path_exists(
         options.swagger_codegen_cli_jar_path,
         why="options.swagger_codegen_cli_jar_path",
     )
Example #2
0
    def __init__(self, factory, options, *pos_args, **kwargs):
        super(BuildBomCommand, self).__init__(factory, options, *pos_args,
                                              **kwargs)

        if options.refresh_from_bom_path and options.refresh_from_bom_version:
            raise_and_log_error(
                ConfigError('Cannot specify both --refresh_from_bom_path="{0}"'
                            ' and --refresh_from_bom_version="{1}"'.format(
                                options.refresh_from_bom_path,
                                options.refresh_from_bom_version)))
        if options.refresh_from_bom_path:
            logging.debug('Using base bom from path "%s"',
                          options.refresh_from_bom_path)
            check_path_exists(options.refresh_from_bom_path,
                              "refresh_from_bom_path")
            with open(options.refresh_from_bom_path, 'r') as stream:
                base_bom = yaml.load(stream.read())
        elif options.refresh_from_bom_version:
            logging.debug('Using base bom version "%s"',
                          options.refresh_from_bom_version)
            base_bom = HalRunner(options).retrieve_bom_version(
                options.refresh_from_bom_version)
        else:
            base_bom = None
        if base_bom:
            logging.info('Creating new bom based on version "%s"',
                         base_bom.get('version', 'UNKNOWN'))
        self.__builder = BomBuilder(self.options, self.scm, base_bom=base_bom)
Example #3
0
  def __init__(self, factory, options, *pos_args, **kwargs):
    super(BuildBomCommand, self).__init__(factory, options, *pos_args, **kwargs)

    if options.refresh_from_bom_path and options.refresh_from_bom_version:
      raise_and_log_error(
          ConfigError('Cannot specify both --refresh_from_bom_path="{0}"'
                      ' and --refresh_from_bom_version="{1}"'
                      .format(options.refresh_from_bom_path,
                              options.refresh_from_bom_version)))
    if options.refresh_from_bom_path:
      logging.debug('Using base bom from path "%s"',
                    options.refresh_from_bom_path)
      check_path_exists(options.refresh_from_bom_path,
                        "refresh_from_bom_path")
      with open(options.refresh_from_bom_path, 'r') as stream:
        base_bom = yaml.safe_load(stream.read())
    elif options.refresh_from_bom_version:
      logging.debug('Using base bom version "%s"',
                    options.refresh_from_bom_version)
      base_bom = HalRunner(options).retrieve_bom_version(
          options.refresh_from_bom_version)
    else:
      base_bom = None
    if base_bom:
      logging.info('Creating new bom based on version "%s"',
                   base_bom.get('version', 'UNKNOWN'))
    self.__builder = BomBuilder(self.options, self.scm, self.metrics, base_bom=base_bom)
    def __init__(self, factory, options, **kwargs):
        super(PushChangelogCommand, self).__init__(factory, options, **kwargs)
        check_options_set(options, ['build_changelog_gist_url', 'git_branch'])

        if not options.changelog_path:
            options.changelog_path = os.path.join(
                self.get_output_dir(command=BUILD_CHANGELOG_COMMAND),
                'changelog.md')
        check_path_exists(options.changelog_path, why='changelog_path')

        self.__git = GitRunner(options)
  def __init__(self, factory, options, **kwargs):
    super(PushChangelogCommand, self).__init__(factory, options, **kwargs)
    check_options_set(
        options, ['build_changelog_gist_url', 'git_branch'])

    if not options.changelog_path:
      options.changelog_path = os.path.join(
          self.get_output_dir(command=BUILD_CHANGELOG_COMMAND), 'changelog.md')
    check_path_exists(options.changelog_path, why='changelog_path')

    self.__git = GitRunner(options)
Example #6
0
 def __init__(self, factory, options, **kwargs):
   super(PublishChangelogCommand, self).__init__(
       factory, make_options_with_fallback(options),
       source_repository_names=[SPINNAKER_GITHUB_IO_REPOSITORY_NAME],
       **kwargs)
   check_options_set(options, ['spinnaker_version'])
   self.__markdown_path = os.path.join(
       self.get_output_dir(command=BUILD_CHANGELOG_COMMAND),
       'changelog.md')
   check_path_exists(self.__markdown_path,
                     why='output from "%s"' % BUILD_CHANGELOG_COMMAND)
Example #7
0
  def __init__(self, factory, options, **kwargs):
    super(AuditArtifactVersions, self).__init__(factory, options, **kwargs)
    base_path = os.path.dirname(self.get_output_dir())
    self.__init_bintray_versions_helper(base_path)

    bom_data_dir = os.path.join(base_path, 'collect_bom_versions')
    path = os.path.join(bom_data_dir, 'released_bom_service_map.yml')
    check_path_exists(path, 'released bom analysis')
    with open(path, 'r') as stream:
      self.__released_boms = yaml.load(stream.read())

    path = os.path.join(bom_data_dir, 'unreleased_bom_service_map.yml')
    check_path_exists(path, 'unreleased bom analysis')
    with open(path, 'r') as stream:
      self.__unreleased_boms = yaml.load(stream.read())

    self.__only_bad_and_invalid_boms = False
    self.__all_bom_versions = self.__extract_all_bom_versions(
        self.__released_boms)
    self.__all_bom_versions.update(
        self.__extract_all_bom_versions(self.__unreleased_boms))

    self.__missing_debians = {}
    self.__missing_jars = {}
    self.__missing_containers = {}
    self.__missing_images = {}
    self.__found_debians = {}
    self.__found_jars = {}
    self.__found_containers = {}
    self.__found_images = {}
    self.__unused_jars = {}
    self.__unused_debians = {}
    self.__unused_containers = {}
    self.__unused_gce_images = {}
    self.__invalid_boms = {}
    self.__confirmed_boms = set([])
    self.__prune_boms = []
    self.__prune_jars = {}
    self.__prune_debians = {}
    self.__prune_containers = {}
    self.__prune_gce_images = {}
    self.__invalid_versions = {}
Example #8
0
  def __init__(self, options, scm, base_bom=None):
    """Construct new builder.

    Args:
      base_bom[dict]: If defined, this is a bom to start with.
                      It is intended to support a "refresh" use case where
                      only a subset of entires are updated within it.
    """
    self.__options = options
    self.__scm = scm
    self.__services = {}
    self.__repositories = {}
    self.__base_bom = base_bom or {}
    if not base_bom and not options.bom_dependencies_path:
      self.__bom_dependencies_path = os.path.join(
          os.path.dirname(__file__), 'bom_dependencies.yml')
    else:
      self.__bom_dependencies_path = options.bom_dependencies_path

    if self.__bom_dependencies_path:
      check_path_exists(self.__bom_dependencies_path, "bom_dependencies_path")
Example #9
0
  def load_bom(options):
    """Helper function for initializing the BOM if one was specified."""
    bom_path = options.bom_path if hasattr(options, 'bom_path') else None
    bom_version = (options.bom_version
                   if hasattr(options, 'bom_version')
                   else None)

    have_bom_path = 1 if bom_path else 0
    have_bom_version = 1 if bom_version else 0
    if have_bom_path + have_bom_version != 1:
      raise_and_log_error(
          ConfigError('Expected exactly one of: "bom_path", or "bom_version"'))

    if bom_path:
      check_path_exists(bom_path, why='options.bom_path')
      return BomSourceCodeManager.bom_from_path(bom_path)

    if bom_version:
      logging.debug('Retrieving bom version %s', bom_version)
      return HalRunner(options).retrieve_bom_version(bom_version)

    raise_and_log_error(UnexpectedError('Not reachable', cause='NotReachable'))
Example #10
0
  def __init__(self, options, scm, metrics, base_bom=None):
    """Construct new builder.

    Args:
      base_bom[dict]: If defined, this is a bom to start with.
                      It is intended to support a "refresh" use case where
                      only a subset of entires are updated within it.
    """
    self.__options = options
    self.__scm = scm
    self.__metrics = metrics
    self.__services = {}
    self.__repositories = {}
    self.__base_bom = base_bom or {}
    if not base_bom and not options.bom_dependencies_path:
      self.__bom_dependencies_path = os.path.join(
          os.path.dirname(__file__), 'bom_dependencies.yml')
    else:
      self.__bom_dependencies_path = options.bom_dependencies_path

    if self.__bom_dependencies_path:
      check_path_exists(self.__bom_dependencies_path, "bom_dependencies_path")
Example #11
0
  def load_bom(options):
    """Helper function for initializing the BOM if one was specified."""
    bom_path = options.bom_path if hasattr(options, 'bom_path') else None
    bom_version = (options.bom_version
                   if hasattr(options, 'bom_version')
                   else None)

    have_bom_path = 1 if bom_path else 0
    have_bom_version = 1 if bom_version else 0
    if have_bom_path + have_bom_version != 1:
      raise_and_log_error(
          ConfigError('Expected exactly one of: "bom_path", or "bom_version"'))

    if bom_path:
      check_path_exists(bom_path, why='options.bom_path')
      return BomSourceCodeManager.bom_from_path(bom_path)

    if not bom_version:
      raise_and_log_error(
          UnexpectedError('Not reachable', cause='NotReachable'))

    logging.debug('Retrieving bom version %s', bom_version)
    return HalRunner(options).retrieve_bom_version(bom_version)
Example #12
0
  def __init__(self, factory, options, **kwargs):
    if options.prune_min_buildnum_prefix is not None:
      # Typically numeric so is interpreted as number from yaml
      options.prune_min_buildnum_prefix = str(options.prune_min_buildnum_prefix)

    super(AuditArtifactVersions, self).__init__(factory, options, **kwargs)
    base_path = os.path.dirname(self.get_output_dir())
    self.__init_bintray_versions_helper(base_path)

    min_version = options.min_audit_bom_version or '0.0.0'
    min_parts = min_version.split('.')
    if len(min_parts) < 3:
      min_version += '.0' * (3 - len(min_parts))
    self.__min_semver = SemanticVersion.make('ignored-' + min_version)

    bom_data_dir = os.path.join(base_path, 'collect_bom_versions')
    path = os.path.join(bom_data_dir, 'released_bom_service_map.yml')
    check_path_exists(path, 'released bom analysis')
    with open(path, 'r') as stream:
      self.__all_released_boms = {}      # forever
      self.__current_released_boms = {}  # since min_version to audit
      for service, versions in yaml.load(stream.read()).items():
        if not versions:
          # e.g. this service has not yet been released.
          logging.info('No versions for service=%s', service)
          continue

        self.__all_released_boms[service] = versions
        self.__current_released_boms[service] = versions
        stripped_versions = self.__remove_old_bom_versions(
            self.__min_semver, versions)
        if stripped_versions:
          self.__current_released_boms[service] = stripped_versions

    path = os.path.join(bom_data_dir, 'unreleased_bom_service_map.yml')
    check_path_exists(path, 'unreleased bom analysis')
    with open(path, 'r') as stream:
      self.__unreleased_boms = yaml.load(stream.read())

    self.__only_bad_and_invalid_boms = False
    self.__all_bom_versions = self.__extract_all_bom_versions(
        self.__all_released_boms)
    self.__all_bom_versions.update(
        self.__extract_all_bom_versions(self.__unreleased_boms))

    self.__missing_debians = {}
    self.__missing_jars = {}
    self.__missing_containers = {}
    self.__missing_images = {}
    self.__found_debians = {}
    self.__found_jars = {}
    self.__found_containers = {}
    self.__found_images = {}
    self.__unused_jars = {}
    self.__unused_debians = {}
    self.__unused_containers = {}
    self.__unused_gce_images = {}
    self.__invalid_boms = {}
    self.__confirmed_boms = set([])
    self.__prune_boms = []
    self.__prune_jars = {}
    self.__prune_debians = {}
    self.__prune_containers = {}
    self.__prune_gce_images = {}
    self.__invalid_versions = {}
Example #13
0
 def _check_args(self):
     check_path_exists(self.__html_path,
                       why='output from running "build_apidocs"')
     check_options_set(self.options, ['spinnaker_version'])
Example #14
0
 def _check_args(self):
   options = self.options
   check_options_set(options, ['swagger_codegen_cli_jar_path'])
   check_path_exists(options.swagger_codegen_cli_jar_path,
                     why='options.swagger_codegen_cli_jar_path')
Example #15
0
 def _check_args(self):
   check_path_exists(self.__html_path,
                     why='output from running "build_apidocs"')
   check_options_set(self.options, ['spinnaker_version'])