Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add flags to CloudFunction delete function #123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions src/TestUtils/GcloudWrapper/CloudFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,29 @@ public function deploy(array $flags = [], string $trigger = self::DEFAULT_TRIGGE
/**
* Delete the deployed function.
*
* @param array $flags optional flags to inject into the deploy command
* @param int $retries optional The number of retries upon failure
*
* @return bool true if the function is succesfully deleted, otherwise false
*/
public function delete($retries = 3)
public function delete(array $flags = [], $retries = 3)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to make sure we're not setting this anywhere. My guess is that we aren't, and so changing the order is fine.

{
if (!$this->deployed) {
$this->errorLog('Nothing to delete: function not deployed during test');

return false;
}


$flattenedFlags = [];
foreach ($flags as $name => $value) {
$flattenedFlags[] = empty($value) ? $name : "$name=$value";
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we now do this twice, maybe abstract to a private function

$args = [
'delete',
$this->functionName
] + $flattenedFlags;
try {
$cmd = $this->gcloudCommand(['delete', $this->functionName]);
$cmd = $this->gcloudCommand($args);
$this->runWithRetry($cmd, $retries);
$this->deployed = false;
} catch (ProcessFailedException $e) {
Expand Down