Skip to content

Commit 7a2047e

Browse files
authored
Merge pull request #18 from peterjaap/patch-1
2 parents 1726fea + 9948ecb commit 7a2047e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Service/BrancherApp.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,22 @@ public function create(string $app, ?array $data = null): string
6060
*
6161
* @param string $name Name of the Brancher node
6262
* @param array $data Data to be updated
63+
* @param bool $appendLabels Whether to append labels or to overwrite
6364
* @return array Updated data
6465
* @throws HypernodeApiClientException
6566
* @throws HypernodeApiServerException
6667
*/
67-
public function update(string $name, array $data): array
68+
public function update(string $name, array $data, bool $appendLabels = false): array
6869
{
6970
$url = sprintf(App::V2_BRANCHER_DETAIL_URL, $name);
71+
72+
if ($appendLabels) {
73+
$originHypernode = substr($name, 0, strrpos($name, '-'));
74+
$existingLabels = $this->list($originHypernode)[0]['labels'] ?? [];
75+
foreach (explode('&', http_build_query($existingLabels)) as $label) {
76+
$data['labels'][] = $label;
77+
}
78+
}
7079

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

0 commit comments

Comments
 (0)