in src/TestUtils/GcloudWrapper/CloudFunction.php [140:179]
public function deploy(array $flags = [], string $trigger = self::DEFAULT_TRIGGER, int $retries = 3, ?string $channel = null)
{
if ($this->deployed) {
$this->errorLog('The function has already been deployed.');
// If we've already deployed, assume the function is ready for use.
return true;
}
// Prepare deploy command.
$flags = array_merge([
'--runtime' => self::DEFAULT_RUNTIME,
], $flags);
$flattenedFlags = [];
foreach ($flags as $name => $value) {
$flattenedFlags[] = empty($value) ? $name : "$name=$value";
}
$args = array_merge([
'deploy',
$this->functionName,
'--entry-point=' . $this->entryPoint,
$trigger,
'--no-allow-unauthenticated',
], $flattenedFlags);
$cmd = $this->gcloudCommand($args, $channel);
$cmd->setTimeout(self::DEFAULT_TIMEOUT_SECONDS);
// Run deploy command.
try {
$this->runWithRetry($cmd, $retries);
} catch (ProcessFailedException $e) {
$this->errorLog($e->getMessage());
return false;
}
$this->deployed = true;
return true;
}