Example #1
0
def CommonFlags(parser):
    """Add common flags for local developement environments."""
    parser.add_argument('--dockerfile',
                        default='Dockerfile',
                        help='Dockerfile for the service image.')

    parser.add_argument('--service-name',
                        required=False,
                        help='Name of the service.')

    parser.add_argument('--image-name',
                        required=False,
                        help='Name for the built docker image.')

    parser.add_argument(
        '--build-context-directory',
        help='If set, use this as the context directory when building the '
        'container image. Otherwise, the directory of the Dockerfile will be '
        'used.')

    parser.add_argument(
        '--builder',
        help='Build with a given Cloud Native Computing Foundation Buildpack '
        'builder.')

    parser.add_argument(
        '--service-account',
        help='When connecting to Google Cloud Platform services, use a service '
        'account key.')

    parser.add_argument(
        '--local-port',
        type=int,
        help='Local port to which the service connection is forwarded. If this '
        'flag is not set, then a random port is chosen.')

    parser.add_argument(
        '--cloudsql-instances',
        type=arg_parsers.ArgList(),
        metavar='CLOUDSQL_INSTANCE',
        help='Cloud SQL instance connection strings. Must be in the form '
        '<project>:<region>:<instance>.')

    env_var_group = parser.add_mutually_exclusive_group(required=False)
    env_var_group.add_argument(
        '--env-vars',
        metavar='KEY=VALUE',
        action=arg_parsers.UpdateAction,
        type=arg_parsers.ArgDict(key_type=six.text_type,
                                 value_type=six.text_type),
        help='List of key-value pairs to set as environment variables.')

    env_var_group.add_argument(
        '--env-vars-file',
        metavar='FILE_PATH',
        type=map_util.ArgDictFile(key_type=six.text_type,
                                  value_type=six.text_type),
        help='Path to a local YAML file with definitions for all environment '
        'variables.')
Example #2
0
 def AddEnvVarsFile(self):
   self._AddFlag(
       '--env-vars-file',
       metavar='FILE_PATH',
       type=map_util.ArgDictFile(
           key_type=six.text_type, value_type=six.text_type),
       help='Path to a local YAML file with definitions for all environment '
       'variables.')
Example #3
0
def CommonFlags(parser):
  """Add common flags for local developement environments."""
  builder_group = parser.add_mutually_exclusive_group(required=False)
  builder_group.add_argument(
      '--dockerfile',
      default='Dockerfile',
      help='Dockerfile for the service image.')

  builder_group.add_argument(
      '--builder',
      help='Build with a given Cloud Native Computing Foundation Buildpack '
      'builder.')

  parser.add_argument(
      '--service-name', required=False, help='Name of the service.')

  parser.add_argument(
      '--image-name', required=False, help='Name for the built docker image.')

  parser.add_argument(
      '--build-context-directory',
      help='If set, use this as the context directory when building the '
      'container image. Otherwise, the directory of the Dockerfile will be '
      'used.')

  credential_group = parser.add_mutually_exclusive_group(required=False)
  credential_group.add_argument(
      '--service-account',
      help='When connecting to Google Cloud Platform services, use a service '
      'account key.')

  credential_group.add_argument(
      '--application-default-credential',
      action='store_true',
      default=False,
      help='When connecting to Google Cloud Platform services, use the '
      'application default credential.')

  parser.add_argument(
      '--local-port',
      type=int,
      help='Local port to which the service connection is forwarded. If this '
      'flag is not set, then a random port is chosen.')

  parser.add_argument(
      '--cloudsql-instances',
      type=arg_parsers.ArgList(),
      metavar='CLOUDSQL_INSTANCE',
      help='Cloud SQL instance connection strings. Must be in the form '
      '<project>:<region>:<instance>.')

  parser.add_argument(
      '--cpu-limit',
      type=arg_parsers.BoundedFloat(lower_bound=0.0),
      help='Container CPU limit. Limit is expressed as a number of CPUs. '
      'Fractional CPU limits are allowed (e.g. 1.5).')

  parser.add_argument(
      '--memory-limit',
      type=arg_parsers.BinarySize(default_unit='B'),
      help='Container memory limit. Limit is expressed either as an integer '
      'representing the number of bytes or an integer followed by a unit '
      'suffix. Valid unit suffixes are "B", "KB", "MB", "GB", "TB", "KiB", '
      '"MiB", "GiB", "TiB", or "PiB".')

  env_var_group = parser.add_mutually_exclusive_group(required=False)
  env_var_group.add_argument(
      '--env-vars',
      metavar='KEY=VALUE',
      action=arg_parsers.UpdateAction,
      type=arg_parsers.ArgDict(
          key_type=six.text_type, value_type=six.text_type),
      help='List of key-value pairs to set as environment variables.')

  env_var_group.add_argument(
      '--env-vars-file',
      metavar='FILE_PATH',
      type=map_util.ArgDictFile(
          key_type=six.text_type, value_type=six.text_type),
      help='Path to a local YAML file with definitions for all environment '
      'variables.')
Example #4
0
def CommonFlags(parser):
  """Add common flags for local developement environments."""
  builder_group = parser.add_mutually_exclusive_group(required=False)
  builder_group.add_argument(
      '--dockerfile',
      default='Dockerfile',
      help='Dockerfile for the service image.')

  builder_group.add_argument(
      '--builder',
      help='Build with a given Cloud Native Computing Foundation Buildpack '
      'builder.')

  builder_group.add_argument(
      '--appengine',
      action='store_true',
      default=False,
      help='Build with a Cloud Native Computing Foundation Buildpack builder '
      'selected from gcr.io/gae-runtimes/buildpacks, according to the App '
      'Engine runtime specified in app.yaml.')

  parser.add_argument(
      '--service-name', required=False, help='Name of the service.')

  parser.add_argument(
      '--image', required=False, help='Name for the built image.')

  parser.add_argument(
      '--source',
      help='The directory containing the source to build. '
      'If not specified, the current directory is used.')

  credential_group = parser.add_mutually_exclusive_group(required=False)
  credential_group.add_argument(
      '--service-account',
      help='When connecting to Google Cloud Platform services, use a service '
      'account key.')

  credential_group.add_argument(
      '--application-default-credential',
      action='store_true',
      default=False,
      help='When connecting to Google Cloud Platform services, use the '
      'application default credential.')

  parser.add_argument(
      '--local-port',
      type=int,
      help='Local port to which the service connection is forwarded. If this '
      'flag is not set, then a random port is chosen.')

  parser.add_argument(
      '--cloudsql-instances',
      type=arg_parsers.ArgList(),
      metavar='CLOUDSQL_INSTANCE',
      help='Cloud SQL instance connection strings. Must be in the form '
      '<project>:<region>:<instance>.')

  parser.add_argument(
      '--cpu',
      type=arg_parsers.BoundedFloat(lower_bound=0.0),
      help='Container CPU limit. Limit is expressed as a number of CPUs. '
      'Fractional CPU limits are allowed (e.g. 1.5).')

  parser.add_argument(
      '--memory',
      type=arg_parsers.BinarySize(default_unit='B'),
      help='Container memory limit. Limit is expressed either as an integer '
      'representing the number of bytes or an integer followed by a unit '
      'suffix. Valid unit suffixes are "B", "KB", "MB", "GB", "TB", "KiB", '
      '"MiB", "GiB", "TiB", or "PiB".')

  # This flag launches the readiness probe feature. It is currently
  # default off. It will be moved to default on when ready and then
  # the feature will be always on.
  parser.add_argument(
      '--readiness-probe',
      default=False,
      action='store_true',
      hidden=True,
      help='Add a readiness probe to the list of containers that delays '
      'deployment stabilization until the application app has bound to $PORT')

  env_var_group = parser.add_mutually_exclusive_group(required=False)
  env_var_group.add_argument(
      '--env-vars',
      metavar='KEY=VALUE',
      action=arg_parsers.UpdateAction,
      type=arg_parsers.ArgDict(
          key_type=six.text_type, value_type=six.text_type),
      help='List of key-value pairs to set as environment variables.')

  env_var_group.add_argument(
      '--env-vars-file',
      metavar='FILE_PATH',
      type=map_util.ArgDictFile(
          key_type=six.text_type, value_type=six.text_type),
      help='Path to a local YAML file with definitions for all environment '
      'variables.')