コード例 #1
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

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

    Returns:
      The specified function with its description and configured filter.

    Raises:
      FunctionsError if command line parameters are not valid.
    """
        # TODO(b/24723761): This should be invoked as a hook method after arguments
        # are parsed, but unfortunately gcloud framework doesn't support such a
        # hook.
        processed_args = deploy_util.DeduceAndCheckArgs(args)

        project = properties.VALUES.core.project.Get(required=True)
        location = 'projects/{0}/locations/{1}'.format(project, args.region)
        name = 'projects/{0}/locations/{1}/functions/{2}'.format(
            project, args.region, args.name)

        function = self._GetExistingFunction(name)
        if function is None:
            return self._DeployFunction(name, location, args, processed_args,
                                        self._CreateFunction)
        else:
            return self._DeployFunction(name, location, args, processed_args,
                                        self._UpdateFunction)
コード例 #2
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

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

    Returns:
      The specified function with its description and configured filter.

    Raises:
      FunctionsError if command line parameters are not valid.
    """
        self._ValidateLabelsFlags(args)
        trigger_params = deploy_util.DeduceAndCheckArgs(args)
        project = properties.VALUES.core.project.Get(required=True)
        location_ref = resources.REGISTRY.Parse(
            properties.VALUES.functions.region.Get(),
            params={'projectsId': project},
            collection='cloudfunctions.projects.locations')
        location = location_ref.RelativeName()
        function_ref = resources.REGISTRY.Parse(
            args.name,
            params={
                'projectsId': project,
                'locationsId': properties.VALUES.functions.region.Get()
            },
            collection='cloudfunctions.projects.locations.functions')
        function_url = function_ref.RelativeName()

        function = self._GetExistingFunction(function_url)
        self._ValidateAfterCheckingFunctionsExistence(function, args)
        is_new_function = function is None
        if is_new_function:
            messages = util.GetApiMessagesModule()
            function = messages.CloudFunction()
        function, update_mask = self._ApplyArgsToFunction(
            function, is_new_function, trigger_params, function_ref, args,
            project)
        if is_new_function:
            return self._CreateFunction(location, function)
        else:
            if update_mask:
                return self._PatchFunction(function, update_mask)
            else:
                log.status.Print('Nothing to update.')
コード例 #3
0
ファイル: deploy.py プロジェクト: Silentsoul04/bias_crawler
    def Run(self, args):
        """This is what gets called when the user runs this command.

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

    Returns:
      The specified function with its description and configured filter.

    Raises:
      FunctionsError if command line parameters are not valid.
    """
        # TODO(b/24723761): This should be invoked as a hook method after arguments
        # are parsed, but unfortunately gcloud framework doesn't support such a
        # hook.
        trigger_params = deploy_util.DeduceAndCheckArgs(args)
        project = properties.VALUES.core.project.Get(required=True)
        registry = self.context['registry']
        location_ref = registry.Parse(
            args.region,
            params={'projectsId': project},
            collection='cloudfunctions.projects.locations')
        location = location_ref.RelativeName()
        function_ref = registry.Parse(
            args.name,
            params={
                'projectsId': project,
                'locationsId': args.region
            },
            collection='cloudfunctions.projects.locations.functions')
        function_url = function_ref.RelativeName()

        function = self._GetExistingFunction(function_url)
        if function is None:
            return self._DeployFunction(function_url, location, args,
                                        self._CreateFunction, trigger_params)
        else:
            return self._DeployFunction(function_url, location, args,
                                        self._UpdateFunction, trigger_params)
コード例 #4
0
    def Run(self, args):
        """This is what gets called when the user runs this command.

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

    Returns:
      The specified function with its description and configured filter.

    Raises:
      FunctionsError if command line parameters are not valid.
    """
        self._ValidateUnpackedSourceSize(args)
        trigger_params = deploy_util.DeduceAndCheckArgs(args)
        project = properties.VALUES.core.project.Get(required=True)
        location_ref = resources.REGISTRY.Parse(
            properties.VALUES.functions.region.Get(),
            params={'projectsId': project},
            collection='cloudfunctions.projects.locations')
        location = location_ref.RelativeName()
        function_ref = resources.REGISTRY.Parse(
            args.name,
            params={
                'projectsId': project,
                'locationsId': properties.VALUES.functions.region.Get()
            },
            collection='cloudfunctions.projects.locations.functions')
        function_url = function_ref.RelativeName()

        function = self._GetExistingFunction(function_url)
        if function is None:
            return self._DeployFunction(function_url, location, args,
                                        self._CreateFunction, trigger_params)
        else:
            return self._DeployFunction(function_url, location, args,
                                        self._UpdateFunction, trigger_params)