コード例 #1
0
ファイル: util.py プロジェクト: Guliux10/bchacks_deepbreath
def AppendRepoDataToRequest(repo_ref, repo_args, request):
  """Adds repository data to CreateRepositoryRequest."""
  if not _IsValidRepoName(repo_ref.repositoriesId):
    raise cba_exceptions.InvalidInputValueError(_INVALID_REPO_NAME_ERROR)
  if not _IsValidLocation(repo_args.location):
    raise cba_exceptions.UnsupportedLocationError(
        "{} is not a valid location. Valid locations are [{}].".format(
            repo_args.location, ", ".join(_VALID_LOCATIONS)))
  messages = _GetMessagesForResource(repo_ref)
  repo = messages.Repository(
      name=repo_ref.RelativeName(),
      description=repo_args.description,
      format=messages.Repository.FormatValueValuesEnum(
          repo_args.repository_format.upper()),
      location=repo_args.location)
  request.repository = repo
  request.repositoryId = repo_ref.repositoriesId

  return request
コード例 #2
0
def GetNpmSettingsSnippet(args):
    """Forms an npm settings snippet to add to the .npmrc file.

  Args:
    args: an argparse namespace. All the arguments that were provided to this
      command invocation.

  Returns:
    An npm settings snippet.
  """
    repo_path = _GetRepoPath(args)
    registry = "registry=https://npm.pkg.dev/{}/".format(repo_path)
    if args.scope:
        if not args.scope.startswith("@") or len(args.scope) <= 1:
            raise cba_exceptions.InvalidInputValueError(
                "Scope name must start with '@' and be longer than 1 character."
            )
        registry = args.scope + ":" + registry

    npm_setting_template = """\
Please insert following snippet into your .npmrc

======================================================
{registry}
//npm.pkg.dev/{repo_path}/:_password=\"${{{password}}}\"
//npm.pkg.dev/{repo_path}/:username=oauth2accesstoken
//npm.pkg.dev/{repo_path}/:[email protected]
//npm.pkg.dev/{repo_path}/:always-auth=true
======================================================
"""

    data = {
        "registry": registry,
        "repo_path": repo_path,
        "password": "******"
    }
    return npm_setting_template.format(**data)
コード例 #3
0
def _GetRequiredRepoValue(args):
    if (not args.repository
            and not properties.VALUES.build_artifacts.repository.Get()):
        raise cba_exceptions.InvalidInputValueError(_REPO_NOT_FOUND_ERROR)
    return cba_util.GetRepo(args)
コード例 #4
0
def _GetRequiredProjectValue(args):
    if not args.project and not properties.VALUES.core.project.Get():
        raise cba_exceptions.InvalidInputValueError(_PROJECT_NOT_FOUND_ERROR)
    return cba_util.GetProject(args)