Skip to content
Merged
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
11 changes: 10 additions & 1 deletion src/Service/BrancherApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,22 @@ public function create(string $app, ?array $data = null): string
*
* @param string $name Name of the Brancher node
* @param array $data Data to be updated
* @param bool $appendLabels Whether to append labels or to overwrite
* @return array Updated data
* @throws HypernodeApiClientException
* @throws HypernodeApiServerException
*/
public function update(string $name, array $data): array
public function update(string $name, array $data, bool $appendLabels = false): array
{
$url = sprintf(App::V2_BRANCHER_DETAIL_URL, $name);

if ($appendLabels) {
$originHypernode = substr($name, 0, strrpos($name, '-'));
$existingLabels = $this->list($originHypernode)[0]['labels'] ?? [];
foreach (explode('&', http_build_query($existingLabels)) as $label) {
$data['labels'][] = $label;
}
}

$response = $this->client->api->put($url, [], json_encode($data));

Expand Down