From 8a1447491414dd3e2ac339d6a7b1adb8dc9aedf6 Mon Sep 17 00:00:00 2001 From: kanekv Date: Wed, 19 Feb 2020 01:14:21 -0800 Subject: [PATCH 1/3] add --host command line argument --- src/functions_framework/cli.py | 4 ++-- tests/test_cli.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/functions_framework/cli.py b/src/functions_framework/cli.py index 98b1b569..9bab270c 100644 --- a/src/functions_framework/cli.py +++ b/src/functions_framework/cli.py @@ -28,11 +28,11 @@ type=click.Choice(["http", "event"]), default="http", ) +@click.option("--host", envvar="HOST", type=click.STRING, default="0.0.0.0") @click.option("--port", envvar="PORT", type=click.INT, default=8080) @click.option("--debug", envvar="DEBUG", is_flag=True) @click.option("--dry-run", envvar="DRY_RUN", is_flag=True) -def cli(target, source, signature_type, port, debug, dry_run): - host = "0.0.0.0" +def cli(target, source, signature_type, host, port, debug, dry_run): app = create_app(target, source, signature_type) if dry_run: click.echo("Function: {}".format(target)) diff --git a/tests/test_cli.py b/tests/test_cli.py index d07f1b00..ec990864 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -88,6 +88,12 @@ def test_cli_no_arguments(): [pretend.call("foo", None, "http")], [], ), + ( + ["--target", "foo", "--host", "127.0.0.1"], + {}, + [pretend.call("foo", None, "http")], + [pretend.call("127.0.0.1", 8080, False)], + ), ], ) def test_cli_arguments(create_app, run, args, env, create_app_calls, run_calls): From ad567fd98f30f70b21bce6648c41862c25c5f793 Mon Sep 17 00:00:00 2001 From: kanekv Date: Thu, 20 Feb 2020 09:27:17 -0800 Subject: [PATCH 2/3] update readme and changelog --- CHANGELOG.md | 4 ++++ README.md | 15 ++++++++------- setup.py | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3bde547..77b3d0ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.2] - 2020-02-20 +### Added +- Add support for `--host` flag ([#20]) + ## [1.1.1] - 2020-02-06 ### Added - Add support for `--dry-run` flag ([#14]) diff --git a/README.md b/README.md index 02b78793..c4253959 100644 --- a/README.md +++ b/README.md @@ -124,13 +124,14 @@ Cloud Run and Cloud Run on GKE both implement the [Knative Serving API](https:// You can configure the Functions Framework using command-line flags or environment variables. If you specify both, the environment variable will be ignored. -Command-line flag | Environment variable | Description -------------------------- | ------------------------- | ----------- -`--port` | `PORT` | The port on which the Functions Framework listens for requests. Default: `8080` -`--target` | `FUNCTION_TARGET` | The name of the exported function to be invoked in response to requests. Default: `function` -`--signature-type` | `FUNCTION_SIGNATURE_TYPE` | The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: `http`; accepted values: `http` or `event` -`--source` | `FUNCTION_SOURCE` | The path to the file containing your function. Default: `main.py` (in the current working directory) -`--debug` | `DEBUG` | A flag that allows to run functions-framework to run in debug mode, including live reloading. Default: `False` +| Command-line flag | Environment variable | Description | +| ------------------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `--host` | `HOST` | The host on which the Functions Framework listens for requests. Default: `0.0.0.0` | +| `--port` | `PORT` | The port on which the Functions Framework listens for requests. Default: `8080` | +| `--target` | `FUNCTION_TARGET` | The name of the exported function to be invoked in response to requests. Default: `function` | +| `--signature-type` | `FUNCTION_SIGNATURE_TYPE` | The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: `http`; accepted values: `http` or `event` | +| `--source` | `FUNCTION_SOURCE` | The path to the file containing your function. Default: `main.py` (in the current working directory) | +| `--debug` | `DEBUG` | A flag that allows to run functions-framework to run in debug mode, including live reloading. Default: `False` | # Enable CloudEvents diff --git a/setup.py b/setup.py index c11c99ea..ab7ca48d 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ setup( name="functions-framework", - version="1.1.1", + version="1.1.2", description="An open source FaaS (Function as a service) framework for writing portable Python functions -- brought to you by the Google Cloud Functions team.", long_description=long_description, long_description_content_type="text/markdown", From 0ddbc2a2dd978c2ca8265c4a05bb1d05cecacbd7 Mon Sep 17 00:00:00 2001 From: kanekv Date: Thu, 20 Feb 2020 10:46:37 -0800 Subject: [PATCH 3/3] fix version and changelog --- CHANGELOG.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77b3d0ee..cb447ff4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [1.1.2] - 2020-02-20 ### Added - Add support for `--host` flag ([#20]) @@ -40,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [1.0.1]: https://github.com/GoogleCloudPlatform/functions-framework-python/releases/tag/v1.0.1 [1.0.0]: https://github.com/GoogleCloudPlatform/functions-framework-python/releases/tag/v1.0.0 +[#20]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/20 [#14]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/14 [#12]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/12 [#8]: https://github.com/GoogleCloudPlatform/functions-framework-python/pull/8 diff --git a/setup.py b/setup.py index ab7ca48d..c11c99ea 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ setup( name="functions-framework", - version="1.1.2", + version="1.1.1", description="An open source FaaS (Function as a service) framework for writing portable Python functions -- brought to you by the Google Cloud Functions team.", long_description=long_description, long_description_content_type="text/markdown",