Skip to content

Commit

Permalink
Allow to set an entrypoint on KubectlTransport (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
ceesgeene authored Dec 1, 2022
1 parent d2df249 commit 399bd23
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Transport/KubectlTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function wrap($args)
$resource = $this->siteAlias->get('kubectl.resource');
$container = $this->siteAlias->get('kubectl.container');
$kubeconfig = $this->siteAlias->get('kubectl.kubeconfig');
$entrypoint = $this->siteAlias->get('kubectl.entrypoint');

$transport = [
'kubectl',
Expand All @@ -59,6 +60,9 @@ public function wrap($args)
$transport[] = "--kubeconfig=$kubeconfig";
}
$transport[] = "--";
if ($entrypoint) {
$transport = is_array($entrypoint) ? [...$transport, ...$entrypoint] : [...$transport, $entrypoint];
}

return array_merge($transport, $args);
}
Expand Down
32 changes: 32 additions & 0 deletions tests/Transport/KubectlTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,38 @@ public function wrapTestValues()
]
],
],

// With entrypoint as string.
[
'kubectl --namespace=vv exec --tty=false --stdin=false deploy/drupal --container=drupal -- /docker-entrypoint ls',
['ls'],
[
'kubectl' => [
'tty' => false,
'interactive' => false,
'namespace' => 'vv',
'resource' => 'deploy/drupal',
'container' => 'drupal',
'entrypoint' => '/docker-entrypoint',
]
],
],

// With entrypoint as array.
[
'kubectl --namespace=vv exec --tty=false --stdin=false deploy/drupal --container=drupal -- /docker-entrypoint --debug ls',
['ls'],
[
'kubectl' => [
'tty' => false,
'interactive' => false,
'namespace' => 'vv',
'resource' => 'deploy/drupal',
'container' => 'drupal',
'entrypoint' => ['/docker-entrypoint', '--debug'],
]
],
],
];
}

Expand Down

0 comments on commit 399bd23

Please sign in to comment.