Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcloudignore doesn't allow standard wildcard whitelist

Gcloudignore works like gitignore in that you can exclude certain files from uploading to GCF. Sometimes when you have really large projects with lots of generated files, it can be useful to exclude all files except a few.

.gcloudignore

# Ignore everything
# Or /*
*

# Except the Cloud Function files we want to deploy
!/package.json
!/index.js

The following gcloudignore file gives us: File index.js or function.js that is expected to define function doesn't exist in the root directory. meaning index.js is ignored and can not be read.

However the following ignore file syntax works just fine to deploy:

# Ignore everything
/[!.]*
/.?*

# Except the Cloud Function files we want to deploy
!/package.json
!/index.js

I tried peering into the gcloud program code, but I was wondering if anyone knows why this is the case?

like image 614
yellowarchangel Avatar asked Oct 24 '18 19:10

yellowarchangel


2 Answers

I ran into this problem as well.

I found a workaround -- explicitly allow the current dir:

# Ignore everything by default
*

# Allow files explicitly
!foo.bar
!*.baz

# Explicitly allow current dir. `gcloud deploy` fails without it.
!.

Works for me. Don't know why.

like image 62
Arne Jørgensen Avatar answered Oct 20 '22 13:10

Arne Jørgensen


OperationError: code=13, message=Error setting up the execution environment for your function. Please try deploying again after a few minutes.

I just got this problem in recent. The error code 13 means, in my view point, the code/function failed to initialize (with in time).

In my case, the problem is mostly caused by either Provided module can't be loaded. (Dependencies failed) or Provided code is not a loadable module. (Main module is missing) after checking Stackdriver Logs, which point to the deploy isn't complete.

Below is how I got it to work:

# Ignore everything by default
/*

# Allow files explicitly
!config.js
!index.js

# Tried !app/ but does not work
!app/**

# Explicitly allow current folder, as Arne Jørgensen said.
!.

Be care the !app/ isn't enough. I have to use !app/** to including all files.

If it's your case, check the source tab from function console to see which files uploaded in actual.

like image 24
Pin Gu Avatar answered Oct 20 '22 13:10

Pin Gu