File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments