Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,20 @@ Arguments:
Options:
--output[=OUTPUT] Output format (json, default: table)
```

### brancher:update

```
Description:
Update a Brancher node with new labels

Usage:
brancher:update [options] [--] <hypernode>

Arguments:
hypernode

Options:
--append-labels
--label[=LABEL] Add labels to your Brancher node (comma-separated)
```
3 changes: 1 addition & 2 deletions app/Commands/ListBrancherNodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ public function handle()

$tableData = [];
foreach ($branchers as $brancher) {
$brancher['labels'] = array_keys($brancher['labels']);
foreach ($brancher as $key => $value) {
if (is_array($value)) $brancher[$key] = implode(', ', $value);
if (is_array($value)) $brancher[$key] = http_build_query(data: $value, arg_separator: PHP_EOL);
}
$tableData[] = $brancher;
}
Expand Down
45 changes: 45 additions & 0 deletions app/Commands/UpdateBrancherNode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Commands;

use Hypernode\Api\Exception\HypernodeApiClientException;
use Hypernode\Api\Exception\HypernodeApiServerException;
use Hypernode\Api\HypernodeClientFactory;
use LaravelZero\Framework\Commands\Command;

class UpdateBrancherNode extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'brancher:update {hypernode} {--append-labels} {--label= : Add labels to your Brancher node (comma-separated)}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'Update a Brancher node with new labels';

/**
* Execute the console command.
*
* @return mixed
* @throws HypernodeApiClientException
* @throws HypernodeApiServerException
*/
public function handle()
{
$client = HypernodeClientFactory::create(config('hypernode.api_token'));

$originHypernode = $this->argument('hypernode');

$labels = array_filter(array_map('trim', explode(',', $this->option('label'))));

$client->brancherApp->update($originHypernode, ['labels' => $labels], (bool) $this->option('append-labels'));

$this->line('Brancher node update for ' . $originHypernode . ' requested');
}
}
Loading