Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Handle google-cloud restructure for auto_prepend_file path #425

Merged
merged 9 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ steps:
- 'E2E_PROJECT_ID=${_E2E_PROJECT_ID}'
- 'RUNTIME_BUILDER_ROOT=${_RUNTIME_BUILDER_ROOT}'
- 'TEST_VM_IMAGE=${_TEST_VM_IMAGE}'

# build_pipeline_stackdriver test
- name: gcr.io/${_GOOGLE_PROJECT_ID}/php-test-runner:$_TAG
args: ['/workspace/testapps/build_pipeline_std/tests']
waitFor: ['test-runner']
id: build_pipeline_stackdriver
env:
- 'SERVICE_ACCOUNT_JSON=${_SERVICE_ACCOUNT_JSON}'
- 'TAG=${_TAG}-build-pipeline-std'
- 'E2E_PROJECT_ID=${_E2E_PROJECT_ID}'
- 'RUNTIME_BUILDER_ROOT=${_RUNTIME_BUILDER_ROOT}'
- 'TEST_VM_IMAGE=${_TEST_VM_IMAGE}'
17 changes: 11 additions & 6 deletions php-base/stackdriver-files/enable_stackdriver_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ echo "Enabling stackdriver integration..."
# To start the batch daemon
cp /stackdriver-files/batch-daemon.conf /etc/supervisor/conf.d

if [ "${1}" = "--individual" ]; then
# For enabling automatic error reporting for google/cloud-error-reporting
cp /stackdriver-files/stackdriver-errorreporting-individual.ini ${PHP_DIR}/lib/conf.d
else
# For enabling automatic error reporting for google/cloud
cp /stackdriver-files/stackdriver-errorreporting.ini ${PHP_DIR}/lib/conf.d
# Detect the stackdriver prepend path
set +e
PREPEND_PATH=`php /stackdriver-files/locate_stackdriver_prepend.php`
set -e
if [ $? -ne 0 ]; then
if [ "${1}" = "--individual" ]; then
PREPEND_PATH="/app/vendor/google/cloud-error-reporting/prepend.php"
else
PREPEND_PATH="/app/vendor/google/cloud/src/ErrorReporting/prepend.php"
fi
fi
echo "auto_prepend_file=$PREPEND_PATH" > ${PHP_DIR}/lib/conf.d/stackdriver-prepend.ini
36 changes: 36 additions & 0 deletions php-base/stackdriver-files/locate_stackdriver_prepend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

$appDir = getenv('APP_DIR');
$appDir = $appDir ?: '/app';

// Use the application's vendor/autoload.php
require_once $appDir . '/vendor/autoload.php';

use Google\Cloud\ErrorReporting\Bootstrap;

if (class_exists(Bootstrap::class)) {
$reflection = new \ReflectionClass(Bootstrap::class);
if ($reflection->hasMethod('prependFileLocation')) {
echo Bootstrap::prependFileLocation() . PHP_EOL;
} else {
// default to same directory as the Bootstrap.php
echo realpath(dirname($reflection->getFileName()) . '/prepend.php') . PHP_EOL;
}
} else {
die('cannot find ErrorReporting\Bootstrap class');
}

This file was deleted.

2 changes: 0 additions & 2 deletions php-base/stackdriver-files/stackdriver-errorreporting.ini

This file was deleted.

2 changes: 2 additions & 0 deletions testapps/build_pipeline_std/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cloudbuild.yaml
Dockerfile
7 changes: 7 additions & 0 deletions testapps/build_pipeline_std/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
runtime: php
env: flex

runtime_config:
document_root: web
whitelist_functions: phpinfo,exec
enable_stackdriver_integration: true
21 changes: 21 additions & 0 deletions testapps/build_pipeline_std/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"require": {
"php": "7.1.*",
"ext-grpc": "*",
"ext-mailparse": "*",
"ext-mbstring": "*",
"ext-opencensus": "*",
"ext-pdo_sqlite": "*",
"google/cloud": "^0.39.2",
"grpc/grpc": "*",
"silex/silex": "^1.3"
},
"scripts": {
"post-install-cmd": [
"php logging-client.php"
]
},
"autoload": {
"classmap": ["web"]
}
}
Loading