oliver006 / drone-gcf Goto Github PK
View Code? Open in Web Editor NEWDrone Plugin for deploying Google Cloud Functions
Drone Plugin for deploying Google Cloud Functions
Hi there,
Could you by any chance add support for "--security-level=secure-always" for http trigger.
Cheers,
Marc
Hello,
I would like to use the --allow-unauthenticated
flag that is available in the CLI (docs here).
If it were like the other flags currently support, which require a key and value, I would know what needs to change.
However, this flag doesn't take in any value. As such, I'm not sure what the best way to approach this is (I'm not terribly well versed in go).
allow-unauthenticated
as a setting--clear-max-instances
and --clear-vpc-connector
In either case, that comes to the question of how to support flags that don't accept any value.
These two options are relatively frictionless:
inputless_args
(or preferably something better) that takes in an array of strings that will be added as flags.1 functions:
- myAwesomeFunction:
- trigger: http
allow-unauthenticated: true
clear-max-instances: true
2 functions:
- myAwesomeFunction:
- trigger: http
inputless_args:
- [allow-unauthenticated, clear-max-instances]
Let me know your thoughts!
Thanks so much for sharing project with the world!
Hi, me again, I have this case in which I'm attempting to set an env variable in the CF which contains comma (",") characters.
This is what comes up in the log:
2020/07/15 20:11:49 Drone-GCF Plugin version: [not-tagged] hash: date: 2020-07-10-16:51:55
2020/07/15 20:11:49 Using project ID: xxxxxxxxxxx
Google Cloud SDK 290.0.1
alpha 2020.04.24
beta 2020.04.24
bq 2.0.56
core 2020.04.24
gsutil 4.49
kubectl 2020.04.24
Activated service account credentials for: [[email protected]]
ERROR: (gcloud.functions.deploy) argument --set-env-vars: Bad syntax for dict arg: [XNuWskz]. Please see `gcloud topic flags-file` or `gcloud topic escaping` for information on providing list or dictionary flag values with special characters.
Usage: gcloud functions deploy (NAME : --region=REGION) [optional flags]
optional flags may be --allow-unauthenticated | --clear-env-vars |
--clear-labels | --clear-max-instances |
--clear-vpc-connector | --egress-settings |
--entry-point | --env-vars-file | --help |
--ignore-file | --ingress-settings | --max-instances |
--memory | --region | --remove-env-vars |
--remove-labels | --retry | --runtime |
--service-account | --set-env-vars | --source |
--stage-bucket | --timeout | --trigger-bucket |
--trigger-event | --trigger-http | --trigger-resource |
--trigger-topic | --update-env-vars | --update-labels |
--vpc-connector
For detailed information on this command and its flags, run:
gcloud functions deploy --help
2020/07/15 20:11:50 runConfig() err: error: exit status 2
if you go and check those gcloud topic flags-file
or gcloud topic escaping
, you'll find two posibilities to allow the use of commas and other special characters in the values for a "dictionary flag", which happens to be the case for ---set-env-vars
.
To sum up, what needs to happen is that when the command is building it's flags, it should allow to build it like this:
--set-env-vars=^DELIM^
, maybe pass that DELIM in a environment_delimiter
setting?
That would allow us to have commas (and any other character) in the values for our environment variables. like so:
- name: deploy-cloud-functions
image: oliver006/drone-gcf
settings:
action: deploy
project: xxxxxx
token:
from_secret: token
functions:
- MyFunction:
- trigger: http
runtime: nodejs10
memory: 2048MB
environment_delimiter: ";"
environment:
- SOME_ENV: "some,value,with,commas"
SOME_OTHER_ENV: "someValueWithoutCommas"
which should result in this flag:
--set-env-vars=^;^SOME_ENV=some,value,with,commas;SOME_OTHER_ENV=someValueWithoutCommas
- name: deploy-cloud-func
image: oliver006/drone-gcf:v1.6.0
settings:
action: deploy
project: my-cloud-function-testing
token:
from_secret: google_credentials_dev
runtime: nodejs10
functions:
- slack:
- trigger: http
environment:
- firstkey: firstvalue
- secondkey: secondvalue
When I use the above, only the first environment variable is deployed.
I believe it's because of these lines.
According to the docs, the flag should be used as --set-env-vars=[KEY=VALUE,โฆ]
but it seems we are using :|:
as a separator.
It seems like it might be as simple as switching out the separator but maybe there's a reason that separator was being used in the first place?
Hi, I'd like to provide PR directly but I'm a total golang newbie so I probably won't succeed. It would be nice to have support for Function's environment variables though, are you planning on doing that?
Hi @oliver006 ,
I am trying to use this plugin to deploy cloud functions in drone, however I keep receiving the following error in drone:
parseConfig() err: Missing action
even though action is set. Please see my .drone.yml file below:
deploy_cf_stg:
image: oliver006/drone-gcf
settings:
action: deploy
project: nyt-dssor-stg
token:
from_secret: gcf_credentials_stg
runtime: python37
functions:
- status_check:
- trigger: http
source: cloud_functions
entry_point: run_status_check
function_name: status_check
runtime: python37
verbosity: info
Thanks in advance for your help!
Hi @oliver006 ,
Thanks for providing this plugin!
I wanted to know how to set the runtime service account for a cloud function that I deployed using your plugin?
`kind: pipeline
name: default
steps:
The service account for the token specified here is not the one that shows up in the Google Cloud Function UI. It routes to the default service account for runtime. Is there any way to specify here the service account it uses while running?
Thanks in advance!
Google Functions 2nd generation was GA'd on Aug 9, 2022. To use this, the gcloud functions deploy
command needs a --gen2
parameter added.
Docs: https://cloud.google.com/sdk/gcloud/reference/functions/deploy#--gen2
Hello all, I'm trying to use this plugin, but I do not seam to get it correctly configured.
This is my .drone.yml:
---
kind: pipeline
name: deploy-staging
steps:
- name: restore_cache
image: plugins/s3-cache
settings:
pull: true
root: drone_cache
endpoint: https://storage.googleapis.com
access_key:
from_secret: gcs_access_key
secret_key:
from_secret: gcs_secret_key
restore: true
- name: npm_install
image: node:12-alpine
commands:
- npm install
depends_on:
- restore_cache
- name: rebuild_cache
image: plugins/s3-cache
settings:
pull: true
root: drone_cache
endpoint: https://storage.googleapis.com
access_key:
from_secret: gcs_access_key
secret_key:
from_secret: gcs_secret_key
rebuild: true
mount:
- node_modules
depends_on:
- npm_install
- name: npm_run_build
image: node:12-alpine
commands:
- npm run build
depends_on:
- npm_install
- name: deploy_cf
depends_on:
- npm_run_build
image: oliver006/drone-gcf
settings:
action: deploy
project: my-project-staging
token:
from_secret: token
runtime: nodejs10
env_secret_sql_user:
from_secret: sql_user_stg
env_secret_sql_password:
from_secret: sql_password_stg
env_secret_instance_connection_name:
from_secret: instance_connection_name_stg
env_secret_firestore_project_id:
from_secret: firestore_project_id_stg
env_secret_firestore_collection_name:
from_secret: firestore_collection_name_stg
functions:
- MyFunctionName:
- trigger: http
memory: 2048MB
runtime: nodejs10
region: us-east1
allow_unauthenticated: true
environment:
- LOGGING: true
NODE_ENV: production
trigger:
branch:
- develop
event:
- push
When I run this pipeline, the "deploy_cf" fails with this:
2020/07/14 19:34:27 Drone-GCF Plugin version: [not-tagged] hash: date: 2020-07-10-16:51:55
2020/07/14 19:34:27 Missing or invalid runtime [] for function: [{"MyFunctionName":[{"allow_unauthenticated":true
2020/07/14 19:34:27 Missing or invalid runtime [] for function: "environment":[{"LOGGING":true
2020/07/14 19:34:27 Missing or invalid runtime [] for function: "NODE_ENV":"production"}]
2020/07/14 19:34:27 Missing or invalid runtime [] for function: "memory":"2048MB"
2020/07/14 19:34:27 Missing or invalid runtime [] for function: "region":"us-east1"
2020/07/14 19:34:27 Missing or invalid runtime [] for function: "runtime":"nodejs10"
2020/07/14 19:34:27 Missing or invalid runtime [] for function: "trigger":"http"}]}]
2020/07/14 19:34:27 parseConfig() err: Didn't find any functions
It seams to mess up when parsing the yaml? It's not recognizing the "runtime" field, and doesn't even seam to recognize that there are any functions.
I'm sorry if this is a dumb syntax error from my part, but I don't see it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.