From 03faa29bdb2169332b0dfa97c72383c43ed73351 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Thu, 17 Mar 2022 14:23:25 +0000 Subject: [PATCH 1/5] doc: examples use declarative configuration 1/N This is the first in a series of PRs to convert all examples to use declarative configuration for the signature type. --- ci/build-examples.yaml | 9 --- ci/generate-build-examples.sh | 18 +++--- examples/cloud_event_examples_test.cc | 57 +++++++++++-------- .../hello_cloud_event/hello_cloud_event.cc | 16 +++--- .../hello_from_namespace.cc | 18 +++--- .../hello_from_nested_namespace.cc | 18 +++--- .../hello_multiple_sources.cc | 18 +++--- .../hello_with_third_party.cc | 18 +++--- examples/hello_world/hello_world.cc | 18 +++--- .../howto_use_legacy_code.cc | 18 +++--- examples/http_examples_test.cc | 40 +++++++------ 11 files changed, 118 insertions(+), 130 deletions(-) diff --git a/ci/build-examples.yaml b/ci/build-examples.yaml index 0e70f824..b65ec1c9 100644 --- a/ci/build-examples.yaml +++ b/ci/build-examples.yaml @@ -62,7 +62,6 @@ steps: waitFor: ['gcf-builder-ready'] id: 'hello-cloud-event' args: ['build', - '--env', 'GOOGLE_FUNCTION_SIGNATURE_TYPE=cloudevent', '--env', 'GOOGLE_FUNCTION_TARGET=HelloCloudEvent', '--path', 'examples/hello_cloud_event', 'hello-cloud-event', @@ -72,7 +71,6 @@ steps: waitFor: ['gcf-builder-ready'] id: 'hello-from-namespace' args: ['build', - '--env', 'GOOGLE_FUNCTION_SIGNATURE_TYPE=http', '--env', 'GOOGLE_FUNCTION_TARGET=hello_from_namespace::HelloWorld', '--path', 'examples/hello_from_namespace', 'hello-from-namespace', @@ -82,7 +80,6 @@ steps: waitFor: ['gcf-builder-ready'] id: 'hello-from-namespace-rooted' args: ['build', - '--env', 'GOOGLE_FUNCTION_SIGNATURE_TYPE=http', '--env', 'GOOGLE_FUNCTION_TARGET=::hello_from_namespace::HelloWorld', '--path', 'examples/hello_from_namespace', 'hello-from-namespace-rooted', @@ -92,7 +89,6 @@ steps: waitFor: ['gcf-builder-ready'] id: 'hello-from-nested-namespace' args: ['build', - '--env', 'GOOGLE_FUNCTION_SIGNATURE_TYPE=http', '--env', 'GOOGLE_FUNCTION_TARGET=hello_from_nested_namespace::ns0::ns1::HelloWorld', '--path', 'examples/hello_from_nested_namespace', 'hello-from-nested-namespace', @@ -102,7 +98,6 @@ steps: waitFor: ['gcf-builder-ready'] id: 'hello-multiple-sources' args: ['build', - '--env', 'GOOGLE_FUNCTION_SIGNATURE_TYPE=http', '--env', 'GOOGLE_FUNCTION_TARGET=HelloMultipleSources', '--path', 'examples/hello_multiple_sources', 'hello-multiple-sources', @@ -121,7 +116,6 @@ steps: waitFor: ['gcf-builder-ready'] id: 'hello-with-third-party' args: ['build', - '--env', 'GOOGLE_FUNCTION_SIGNATURE_TYPE=http', '--env', 'GOOGLE_FUNCTION_TARGET=HelloWithThirdParty', '--path', 'examples/hello_with_third_party', 'hello-with-third-party', @@ -131,7 +125,6 @@ steps: waitFor: ['gcf-builder-ready'] id: 'hello-world' args: ['build', - '--env', 'GOOGLE_FUNCTION_SIGNATURE_TYPE=http', '--env', 'GOOGLE_FUNCTION_TARGET=HelloWorld', '--path', 'examples/hello_world', 'hello-world', @@ -141,7 +134,6 @@ steps: waitFor: ['gcf-builder-ready'] id: 'hello-world-rooted' args: ['build', - '--env', 'GOOGLE_FUNCTION_SIGNATURE_TYPE=http', '--env', 'GOOGLE_FUNCTION_TARGET=::HelloWorld', '--path', 'examples/hello_world', 'hello-world-rooted', @@ -151,7 +143,6 @@ steps: waitFor: ['gcf-builder-ready'] id: 'howto-use-legacy-code' args: ['build', - '--env', 'GOOGLE_FUNCTION_SIGNATURE_TYPE=http', '--env', 'GOOGLE_FUNCTION_TARGET=HowtoUseLegacyCode', '--path', 'examples/howto_use_legacy_code', 'howto-use-legacy-code', diff --git a/ci/generate-build-examples.sh b/ci/generate-build-examples.sh index 160ac666..1849601b 100755 --- a/ci/generate-build-examples.sh +++ b/ci/generate-build-examples.sh @@ -132,16 +132,16 @@ _EOF_ _EOF_ } -generic_example hello_cloud_event HelloCloudEvent cloudevent -generic_example hello_from_namespace hello_from_namespace::HelloWorld http -generic_example hello_from_namespace ::hello_from_namespace::HelloWorld http hello-from-namespace-rooted -generic_example hello_from_nested_namespace hello_from_nested_namespace::ns0::ns1::HelloWorld http -generic_example hello_multiple_sources HelloMultipleSources http +generic_example hello_cloud_event HelloCloudEvent declarative +generic_example hello_from_namespace hello_from_namespace::HelloWorld declarative +generic_example hello_from_namespace ::hello_from_namespace::HelloWorld declarative hello-from-namespace-rooted +generic_example hello_from_nested_namespace hello_from_nested_namespace::ns0::ns1::HelloWorld declarative +generic_example hello_multiple_sources HelloMultipleSources declarative generic_example hello_gcs HelloGcs declarative -generic_example hello_with_third_party HelloWithThirdParty http -generic_example hello_world HelloWorld http -generic_example hello_world ::HelloWorld http hello-world-rooted -generic_example howto_use_legacy_code HowtoUseLegacyCode http howto-use-legacy-code +generic_example hello_with_third_party HelloWithThirdParty declarative +generic_example hello_world HelloWorld declarative +generic_example hello_world ::HelloWorld declarative hello-world-rooted +generic_example howto_use_legacy_code HowtoUseLegacyCode declarative howto-use-legacy-code cat <<_EOF_ # Build the cloud site examples. diff --git a/examples/cloud_event_examples_test.cc b/examples/cloud_event_examples_test.cc index 7b4729f5..e47c3539 100644 --- a/examples/cloud_event_examples_test.cc +++ b/examples/cloud_event_examples_test.cc @@ -12,37 +12,48 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "google/cloud/functions/internal/parse_cloud_event_json.h" -#include "google/cloud/functions/cloud_event.h" +#include "google/cloud/functions/internal/function_impl.h" +#include "google/cloud/functions/function.h" #include namespace gcf = ::google::cloud::functions; +namespace gcf_internal = ::google::cloud::functions_internal; -void HelloCloudEvent(gcf::CloudEvent event); +gcf::Function HelloCloudEvent(); namespace { -TEST(HttpExamplesTest, HelloCloudEvent) { - EXPECT_NO_THROW(HelloCloudEvent( - google::cloud::functions_internal::ParseCloudEventJson(R"js({ - "specversion": "1.0", - "type": "google.cloud.pubsub.topic.v1.messagePublished", - "source": "//pubsub.googleapis.com/projects/sample-project/topics/gcf-test", - "id": "aaaaaa-1111-bbbb-2222-cccccccccccc", - "subject": "test-only", - "time": "2020-09-29T11:32:00.000Z", - "datacontenttype": "application/json", - "data": { - "subscription": "projects/sample-project/subscriptions/sample-subscription", - "message": { - "@type": "type.googleapis.com/google.pubsub.v1.PubsubMessage", - "attributes": { - "attr1":"attr1-value" - }, - "data": "" - } +auto constexpr kBody = R"js({ + "specversion": "1.0", + "type": "google.cloud.pubsub.topic.v1.messagePublished", + "source": "//pubsub.googleapis.com/projects/sample-project/topics/gcf-test", + "id": "aaaaaa-1111-bbbb-2222-cccccccccccc", + "subject": "test-only", + "time": "2020-09-29T11:32:00.000Z", + "datacontenttype": "application/json", + "data": { + "subscription": "projects/sample-project/subscriptions/sample-subscription", + "message": { + "@type": "type.googleapis.com/google.pubsub.v1.PubsubMessage", + "attributes": { + "attr1":"attr1-value" + }, + "data": "" } - })js"))); + } +})js"; + +TEST(HttpExamplesTest, HelloCloudEvent) { + auto function = HelloCloudEvent(); + gcf_internal::BeastRequest request; + request.insert("ce-type", "com.example.someevent"); + request.insert("ce-source", "/mycontext"); + request.insert("ce-id", "A234-1234-1234"); + request.body() = kBody; + auto handler = + gcf_internal::FunctionImpl::GetImpl(function)->GetHandler("unused"); + auto const response = handler(std::move(request)); + EXPECT_EQ(response.result_int(), 200); } } // namespace diff --git a/examples/hello_cloud_event/hello_cloud_event.cc b/examples/hello_cloud_event/hello_cloud_event.cc index 0e1141d0..648debae 100644 --- a/examples/hello_cloud_event/hello_cloud_event.cc +++ b/examples/hello_cloud_event/hello_cloud_event.cc @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include #include -using ::google::cloud::functions::CloudEvent; +namespace gcf = ::google::cloud::functions; -// Though not used in this function, `event` is passed by value to support -// applications that move-out its data. -void HelloCloudEvent(CloudEvent event) { // NOLINT - std::cout << "Received event" - << "\n id: " << event.id() - << "\n subject: " << event.subject().value_or("") << std::endl; +gcf::Function HelloCloudEvent() { + return gcf::MakeFunction([](gcf::CloudEvent const& event) { + std::cout << "Received event" + << "\n id: " << event.id() + << "\n subject: " << event.subject().value_or("") << std::endl; + }); } diff --git a/examples/hello_from_namespace/hello_from_namespace.cc b/examples/hello_from_namespace/hello_from_namespace.cc index f51831ae..afcde960 100644 --- a/examples/hello_from_namespace/hello_from_namespace.cc +++ b/examples/hello_from_namespace/hello_from_namespace.cc @@ -12,20 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include namespace hello_from_namespace { -using ::google::cloud::functions::HttpRequest; -using ::google::cloud::functions::HttpResponse; +namespace gcf = ::google::cloud::functions; -// Though not used in this example, the request is passed by value to support -// applications that move-out its data. -HttpResponse HelloWorld(HttpRequest) { // NOLINT - return HttpResponse{} - .set_header("Content-Type", "text/plain") - .set_payload("Hello from a C++ namespace!\n"); +gcf::Function HelloWorld() { + return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::HttpResponse{} + .set_header("Content-Type", "text/plain") + .set_payload("Hello from a C++ namespace!\n"); + }); } } // namespace hello_from_namespace diff --git a/examples/hello_from_nested_namespace/hello_from_nested_namespace.cc b/examples/hello_from_nested_namespace/hello_from_nested_namespace.cc index 28ac80f8..6979ddd6 100644 --- a/examples/hello_from_nested_namespace/hello_from_nested_namespace.cc +++ b/examples/hello_from_nested_namespace/hello_from_nested_namespace.cc @@ -12,20 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include namespace hello_from_nested_namespace::ns0::ns1 { -using ::google::cloud::functions::HttpRequest; -using ::google::cloud::functions::HttpResponse; +namespace gcf = ::google::cloud::functions; -// Though not used in this example, the request is passed by value to support -// applications that move-out its data. -HttpResponse HelloWorld(HttpRequest) { // NOLINT - return HttpResponse{} - .set_header("Content-Type", "text/plain") - .set_payload("Hello from a nested C++ namespace!\n"); +gcf::Function HelloWorld() { + return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::HttpResponse{} + .set_header("Content-Type", "text/plain") + .set_payload("Hello from a nested C++ namespace!\n"); + }); } } // namespace hello_from_nested_namespace::ns0::ns1 diff --git a/examples/hello_multiple_sources/hello_multiple_sources.cc b/examples/hello_multiple_sources/hello_multiple_sources.cc index 99bc70b1..1c79fcd2 100644 --- a/examples/hello_multiple_sources/hello_multiple_sources.cc +++ b/examples/hello_multiple_sources/hello_multiple_sources.cc @@ -13,16 +13,14 @@ // limitations under the License. #include "greeting.h" -#include -#include +#include -using ::google::cloud::functions::HttpRequest; -using ::google::cloud::functions::HttpResponse; +namespace gcf = ::google::cloud::functions; -// Though not used in this example, the request is passed by value to support -// applications that move-out its data. -HttpResponse HelloMultipleSources(HttpRequest) { // NOLINT - return HttpResponse{} - .set_header("Content-Type", "text/plain") - .set_payload(Greeting()); +gcf::Function HelloMultipleSources() { + return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::HttpResponse{} + .set_header("Content-Type", "text/plain") + .set_payload(Greeting()); + }); } diff --git a/examples/hello_with_third_party/hello_with_third_party.cc b/examples/hello_with_third_party/hello_with_third_party.cc index 3907e1a9..975520b2 100644 --- a/examples/hello_with_third_party/hello_with_third_party.cc +++ b/examples/hello_with_third_party/hello_with_third_party.cc @@ -12,17 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include #include -using ::google::cloud::functions::HttpRequest; -using ::google::cloud::functions::HttpResponse; +namespace gcf = ::google::cloud::functions; -// Though not used in this example, the request is passed by value to support -// applications that move-out its data. -HttpResponse HelloWithThirdParty(HttpRequest request) { // NOLINT - return HttpResponse{} - .set_header("Content-Type", "text/plain") - .set_payload(fmt::format("Hello at {}\n", request.target())); +gcf::Function HelloWithThirdParty() { + return gcf::MakeFunction([](gcf::HttpRequest const& request) { + return gcf::HttpResponse{} + .set_header("Content-Type", "text/plain") + .set_payload(fmt::format("Hello at {}\n", request.target())); + }); } diff --git a/examples/hello_world/hello_world.cc b/examples/hello_world/hello_world.cc index 4dbe0a5d..51d00e3c 100644 --- a/examples/hello_world/hello_world.cc +++ b/examples/hello_world/hello_world.cc @@ -12,16 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include -using ::google::cloud::functions::HttpRequest; -using ::google::cloud::functions::HttpResponse; +namespace gcf = ::google::cloud::functions; -// Though not used in this example, the request is passed by value to support -// applications that move-out its data. -HttpResponse HelloWorld(HttpRequest) { // NOLINT - return HttpResponse{} - .set_header("Content-Type", "text/plain") - .set_payload("Hello World\n"); +gcf::Function HelloWorld() { + return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::HttpResponse{} + .set_header("Content-Type", "text/plain") + .set_payload("Hello World\n"); + }); } diff --git a/examples/howto_use_legacy_code/howto_use_legacy_code.cc b/examples/howto_use_legacy_code/howto_use_legacy_code.cc index 9ff6e155..ea6ddad3 100644 --- a/examples/howto_use_legacy_code/howto_use_legacy_code.cc +++ b/examples/howto_use_legacy_code/howto_use_legacy_code.cc @@ -13,16 +13,14 @@ // limitations under the License. #include "legacy/legacy.h" -#include -#include +#include -using ::google::cloud::functions::HttpRequest; -using ::google::cloud::functions::HttpResponse; +namespace gcf = ::google::cloud::functions; -// Though not used in this example, the request is passed by value to support -// applications that move-out its data. -HttpResponse HowtoUseLegacyCode(HttpRequest) { // NOLINT - return HttpResponse{} - .set_header("Content-Type", "text/plain") - .set_payload(legacy::LegacyMessage()); +gcf::Function HowtoUseLegacyCode() { + return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::HttpResponse{} + .set_header("Content-Type", "text/plain") + .set_payload(legacy::LegacyMessage()); + }); } diff --git a/examples/http_examples_test.cc b/examples/http_examples_test.cc index 23a7d31f..e17155ac 100644 --- a/examples/http_examples_test.cc +++ b/examples/http_examples_test.cc @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -22,17 +21,17 @@ namespace gcf = ::google::cloud::functions; namespace gcf_internal = ::google::cloud::functions_internal; gcf::Function HelloGcs(); -gcf::HttpResponse HelloMultipleSources(gcf::HttpRequest); -gcf::HttpResponse HelloWithThirdParty(gcf::HttpRequest request); -gcf::HttpResponse HelloWorld(gcf::HttpRequest); -gcf::HttpResponse HowtoUseLegacyCode(gcf::HttpRequest); +gcf::Function HelloMultipleSources(); +gcf::Function HelloWithThirdParty(); +gcf::Function HelloWorld(); +gcf::Function HowtoUseLegacyCode(); namespace hello_from_namespace { -gcf::HttpResponse HelloWorld(gcf::HttpRequest); +gcf::Function HelloWorld(); } // namespace hello_from_namespace namespace hello_from_nested_namespace::ns0::ns1 { -gcf::HttpResponse HelloWorld(gcf::HttpRequest); +gcf::Function HelloWorld(); } // namespace hello_from_nested_namespace::ns0::ns1 namespace { @@ -46,7 +45,7 @@ auto TriggerFunction(gcf::Function const& function, auto handler = gcf_internal::FunctionImpl::GetImpl(function)->GetHandler("unused"); - return handler(gcf_internal::BeastRequest{}); + return handler(std::move(request)); } TEST(HttpExamplesTest, HelloGcs) { @@ -55,35 +54,34 @@ TEST(HttpExamplesTest, HelloGcs) { } TEST(HttpExamplesTest, HelloMultipleSources) { - auto const actual = HelloMultipleSources(gcf::HttpRequest{}); - EXPECT_THAT(actual.payload(), HasSubstr("Hello World")); + auto const actual = TriggerFunction(HelloMultipleSources()); + EXPECT_THAT(actual.body(), HasSubstr("Hello World")); } TEST(HttpExamplesTest, HelloWithThirdParty) { - auto const actual = - HelloWithThirdParty(gcf::HttpRequest{}.set_target("/here")); - EXPECT_THAT(actual.payload(), HasSubstr("Hello at /here")); + auto const actual = TriggerFunction(HelloWithThirdParty(), "/here"); + EXPECT_THAT(actual.body(), HasSubstr("Hello at /here")); } TEST(HttpExamplesTest, HelloWorld) { - auto const actual = HelloWorld(gcf::HttpRequest{}); - EXPECT_THAT(actual.payload(), HasSubstr("Hello World")); + auto const actual = TriggerFunction(HelloWorld()); + EXPECT_THAT(actual.body(), HasSubstr("Hello World")); } TEST(HttpExamplesTest, HelloFromNamespace) { - auto const actual = hello_from_namespace::HelloWorld(gcf::HttpRequest{}); - EXPECT_THAT(actual.payload(), HasSubstr("C++ namespace")); + auto const actual = TriggerFunction(hello_from_namespace::HelloWorld()); + EXPECT_THAT(actual.body(), HasSubstr("C++ namespace")); } TEST(HttpExamplesTest, HelloFromNestedNamespace) { auto const actual = - hello_from_nested_namespace::ns0::ns1::HelloWorld(gcf::HttpRequest{}); - EXPECT_THAT(actual.payload(), HasSubstr("C++ namespace")); + TriggerFunction(hello_from_nested_namespace::ns0::ns1::HelloWorld()); + EXPECT_THAT(actual.body(), HasSubstr("C++ namespace")); } TEST(HttpExampleTest, HowtoUseLegacyCode) { - auto const actual = HowtoUseLegacyCode(gcf::HttpRequest{}); - EXPECT_THAT(actual.payload(), HasSubstr("C++")); + auto const actual = TriggerFunction(HowtoUseLegacyCode()); + EXPECT_THAT(actual.body(), HasSubstr("C++")); } } // namespace From b333ebc3adfdef9a4d4674db4a2a394c9feeec89 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Mon, 21 Mar 2022 17:38:01 +0000 Subject: [PATCH 2/5] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 507fcec3..d9b66cf3 100644 --- a/README.md +++ b/README.md @@ -60,16 +60,16 @@ The framework allows you to go [from][snippet source]: [snippet source]: /examples/hello_world/hello_world.cc ```cc -#include -#include +#include -using ::google::cloud::functions::HttpRequest; -using ::google::cloud::functions::HttpResponse; +namespace gcf = ::google::cloud::functions; -HttpResponse HelloWorld(HttpRequest) { - return HttpResponse{} - .set_header("Content-Type", "text/plain") - .set_payload("Hello World\n"); +gcf::Function HelloWorld() { + return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::HttpResponse{} + .set_header("Content-Type", "text/plain") + .set_payload("Hello World\n"); + }); } ``` From edf85efac187b878600ecb3d692e3d465083f840 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Mon, 21 Mar 2022 19:10:31 +0000 Subject: [PATCH 3/5] Fix clang-tidy problems --- README.md | 2 +- examples/hello_from_namespace/hello_from_namespace.cc | 2 +- .../hello_from_nested_namespace/hello_from_nested_namespace.cc | 2 +- examples/hello_multiple_sources/hello_multiple_sources.cc | 2 +- examples/hello_world/hello_world.cc | 2 +- examples/howto_use_legacy_code/howto_use_legacy_code.cc | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d9b66cf3..9f03778e 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ The framework allows you to go [from][snippet source]: namespace gcf = ::google::cloud::functions; gcf::Function HelloWorld() { - return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::MakeFunction([](gcf::HttpRequest const& /*request*/) { return gcf::HttpResponse{} .set_header("Content-Type", "text/plain") .set_payload("Hello World\n"); diff --git a/examples/hello_from_namespace/hello_from_namespace.cc b/examples/hello_from_namespace/hello_from_namespace.cc index afcde960..6852e967 100644 --- a/examples/hello_from_namespace/hello_from_namespace.cc +++ b/examples/hello_from_namespace/hello_from_namespace.cc @@ -19,7 +19,7 @@ namespace hello_from_namespace { namespace gcf = ::google::cloud::functions; gcf::Function HelloWorld() { - return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::MakeFunction([](gcf::HttpRequest const& /*request*/) { return gcf::HttpResponse{} .set_header("Content-Type", "text/plain") .set_payload("Hello from a C++ namespace!\n"); diff --git a/examples/hello_from_nested_namespace/hello_from_nested_namespace.cc b/examples/hello_from_nested_namespace/hello_from_nested_namespace.cc index 6979ddd6..d67ec52a 100644 --- a/examples/hello_from_nested_namespace/hello_from_nested_namespace.cc +++ b/examples/hello_from_nested_namespace/hello_from_nested_namespace.cc @@ -19,7 +19,7 @@ namespace hello_from_nested_namespace::ns0::ns1 { namespace gcf = ::google::cloud::functions; gcf::Function HelloWorld() { - return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::MakeFunction([](gcf::HttpRequest const& /*request*/) { return gcf::HttpResponse{} .set_header("Content-Type", "text/plain") .set_payload("Hello from a nested C++ namespace!\n"); diff --git a/examples/hello_multiple_sources/hello_multiple_sources.cc b/examples/hello_multiple_sources/hello_multiple_sources.cc index 1c79fcd2..5d394df4 100644 --- a/examples/hello_multiple_sources/hello_multiple_sources.cc +++ b/examples/hello_multiple_sources/hello_multiple_sources.cc @@ -18,7 +18,7 @@ namespace gcf = ::google::cloud::functions; gcf::Function HelloMultipleSources() { - return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::MakeFunction([](gcf::HttpRequest const& /*request*/) { return gcf::HttpResponse{} .set_header("Content-Type", "text/plain") .set_payload(Greeting()); diff --git a/examples/hello_world/hello_world.cc b/examples/hello_world/hello_world.cc index 51d00e3c..01ccaa81 100644 --- a/examples/hello_world/hello_world.cc +++ b/examples/hello_world/hello_world.cc @@ -17,7 +17,7 @@ namespace gcf = ::google::cloud::functions; gcf::Function HelloWorld() { - return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::MakeFunction([](gcf::HttpRequest const& /*request*/) { return gcf::HttpResponse{} .set_header("Content-Type", "text/plain") .set_payload("Hello World\n"); diff --git a/examples/howto_use_legacy_code/howto_use_legacy_code.cc b/examples/howto_use_legacy_code/howto_use_legacy_code.cc index ea6ddad3..a4cd3df5 100644 --- a/examples/howto_use_legacy_code/howto_use_legacy_code.cc +++ b/examples/howto_use_legacy_code/howto_use_legacy_code.cc @@ -18,7 +18,7 @@ namespace gcf = ::google::cloud::functions; gcf::Function HowtoUseLegacyCode() { - return gcf::MakeFunction([](gcf::HttpRequest const&) { + return gcf::MakeFunction([](gcf::HttpRequest const& /*request*/) { return gcf::HttpResponse{} .set_header("Content-Type", "text/plain") .set_payload(legacy::LegacyMessage()); From bf2eb6b8d633e5f0a469ded711335126ebb55aad Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Mon, 21 Mar 2022 20:51:20 +0000 Subject: [PATCH 4/5] Fix buildpack --- ci/pack/buildpack/bin/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/pack/buildpack/bin/build b/ci/pack/buildpack/bin/build index ec35f33a..61cb5103 100755 --- a/ci/pack/buildpack/bin/build +++ b/ci/pack/buildpack/bin/build @@ -195,7 +195,7 @@ int main(int argc, char* argv[]) { _EOF_ } -generate_cloud_event_main_with_namespace() { +generate_declarative_main_with_namespace() { local function="${1}" local namespace="${2}" From 287f17bcbfe200862c91bc333f76e7ee54b491ef Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Tue, 22 Mar 2022 13:36:59 +0000 Subject: [PATCH 5/5] Fix build --- examples/howto_use_legacy_code/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/howto_use_legacy_code/main.cc b/examples/howto_use_legacy_code/main.cc index 28197c0d..7e584ff5 100644 --- a/examples/howto_use_legacy_code/main.cc +++ b/examples/howto_use_legacy_code/main.cc @@ -17,8 +17,8 @@ namespace gcf = ::google::cloud::functions; -gcf::HttpResponse HowtoUseLegacyCode(gcf::HttpRequest); +gcf::Function HowtoUseLegacyCode(); int main(int argc, char* argv[]) { - return ::google::cloud::functions::Run(argc, argv, HowtoUseLegacyCode); + return ::google::cloud::functions::Run(argc, argv, HowtoUseLegacyCode()); }