GCP Cloud Function source_repository syntax:

For GCP Cloud function can someone give me an example of what the url should look like for “source_repository” ?

I believe I need to use the following format to read from Github (from the docs)

To refer to a moveable alias (branch): 

https://source.developers.google.com/projects/*/repos/*/moveable-aliases/*/paths/*. 

To refer to HEAD, use the master moveable alias.

Exactly what needs to be replaced here?

Do the keywords “projects”, “repos”, “paths” remain or are replaced.

What am I suppose to do with the “*” in the example syntax?

I have something like the following url displayed in Google Cloud Repositories pointing the function source folder:

https://source.cloud.google.com/my-project-ref-ff4b617b/github_my_project-ref/+/master:cloud-functions/training_data/

I’ve used this as the url and I get an error

Error: Error applying plan:

1 error(s) occurred:

* google_cloudfunctions_function.cloud_function_training_data: 1 error(s) occurred:

* google_cloudfunctions_function.cloud_function_training_data: googleapi: Error 400: The request has errors, badRequest

Also it seems to me the url in the docs:

https://source.developers.google.com

is outdated as it gets redirected to:

https://source.cloud.google.com

I’ve also tried to use the format specified in the doc, which also reports an error?

https://source.developers.google.com/my-project-ref-ff4b617b/github_my-project-ref/master/cloud-functions/training_data/

Confused with how to get this working?

1 Like

Anyone on this? I totally agree with @rajinder-yadav !

Came across the same issue. I fixed this by setting the source_repository_url in the following format:

https://source.developers.google.com/projects/{{project_name}}/repos/{{repository_name}}/moveable-aliases/master/paths/functions/{{function_name}}

  1. {{project_name}} is the name of your project
  2. {{repository_name}} is the name your cloud source repository
  3. The code of the function was located inside functions/{{function_name}} so this will probably be different for you.

If this still doesn’t work you can do the other approach. Create a demo function and set the repository there. After that manually get it by running the following gcloud command for example.

gcloud functions describe demo --region=europe-west2