Skip to content

Commit

Permalink
Merge pull request #27 from utopia-php/promote-new-cli-version
Browse files Browse the repository at this point in the history
Update composer.json
  • Loading branch information
christyjacob4 authored Mar 17, 2023
2 parents f9fa340 + c014846 commit 55f4351
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 361 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require": {
"php": ">=8.0",
"utopia-php/cli": "0.14.*"
"utopia-php/cli": "0.15.*"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
Expand Down
226 changes: 112 additions & 114 deletions composer.lock

Large diffs are not rendered by default.

44 changes: 0 additions & 44 deletions src/Orchestration/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ abstract class Adapter

/**
* Filter ENV vars
*
* @param string $string
* @return string
*/
public function filterEnvKey(string $string): string
{
Expand All @@ -37,43 +34,26 @@ public function filterEnvKey(string $string): string

/**
* Create Network
*
* @param string $name
* @return bool
*/
abstract public function createNetwork(string $name, bool $internal = false): bool;

/**
* Remove Network
*
* @param string $name
* @return bool
*/
abstract public function removeNetwork(string $name): bool;

/**
* Connect a container to a network
*
* @param string $container
* @param string $network
* @return bool
*/
abstract public function networkConnect(string $container, string $network): bool;

/**
* Disconnect a container from a network
*
* @param string $container
* @param string $network
* @param bool $force
* @return bool
*/
abstract public function networkDisconnect(string $container, string $network, bool $force = false): bool;

/**
* List Networks
*
* @return array
*/
abstract public function listNetworks(): array;

Expand All @@ -88,9 +68,6 @@ abstract public function getStats(string $container = null, array $filters = [])

/**
* Pull Image
*
* @param string $image
* @return bool
*/
abstract public function pull(string $image): bool;

Expand All @@ -108,17 +85,9 @@ abstract public function list(array $filters = []): array;
* Creates and runs a new container, On success it will return a string containing the container ID.
* On fail it will throw an exception.
*
* @param string $image
* @param string $name
* @param string[] $command
* @param string $entrypoint
* @param string $workdir
* @param string[] $volumes
* @param array<string, string> $vars
* @param string $mountFolder
* @param string $hostname
* @param bool $remove
* @return string
*/
abstract public function run(
string $image,
Expand All @@ -136,29 +105,19 @@ abstract public function run(
/**
* Execute Container
*
* @param string $name
* @param string[] $command
* @param string &$stdout
* @param string &$stderr
* @param array<string, string> $vars
* @param int $timeout
* @return bool
*/
abstract public function execute(string $name, array $command, string &$stdout, string &$stderr, array $vars = [], int $timeout = -1): bool;

/**
* Remove Container
*
* @param string $name
* @param bool $force
* @return bool
*/
abstract public function remove(string $name, bool $force): bool;

/**
* Set containers namespace
*
* @param string $namespace
* @return $this
*/
public function setNamespace(string $namespace): self
Expand All @@ -171,7 +130,6 @@ public function setNamespace(string $namespace): self
/**
* Set max allowed CPU cores per container
*
* @param int $cores
* @return $this
*/
public function setCpus(int $cores): self
Expand All @@ -184,7 +142,6 @@ public function setCpus(int $cores): self
/**
* Set max allowed memory in mb per container
*
* @param int $mb
* @return $this
*/
public function setMemory(int $mb): self
Expand All @@ -197,7 +154,6 @@ public function setMemory(int $mb): self
/**
* Set max allowed swap memory in mb per container
*
* @param int $mb
* @return $this
*/
public function setSwap(int $mb): self
Expand Down
41 changes: 0 additions & 41 deletions src/Orchestration/Adapter/DockerAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ public function __construct(string $username = null, string $password = null, st
/**
* Create a request with cURL via the Docker socket
*
* @param string $url
* @param string $method
* @param array|bool|int|float|object|resource|string|null $body
* @param string[] $headers
* @param int $timeout
* @return (bool|mixed|string)[]
*
* @psalm-return array{response: mixed, code: mixed}
Expand Down Expand Up @@ -95,8 +92,6 @@ protected function call(string $url, string $method, $body = null, array $header
* Create a request with cURL via the Docker socket
* but process a Docker Stream Response
*
* @param string $url
* @param int $timeout
* @return (bool|mixed|string)[]
*
* @psalm-return array{response: bool|string, code: mixed, stdout: mixed, stderr: mixed}
Expand Down Expand Up @@ -179,10 +174,6 @@ protected function streamCall(string $url, int $timeout = -1): array

/**
* Create Network
*
* @param string $name
* @param bool $internal
* @return bool
*/
public function createNetwork(string $name, bool $internal = false): bool
{
Expand All @@ -205,9 +196,6 @@ public function createNetwork(string $name, bool $internal = false): bool

/**
* Remove Network
*
* @param string $name
* @return bool
*/
public function removeNetwork(string $name): bool
{
Expand All @@ -222,10 +210,6 @@ public function removeNetwork(string $name): bool

/**
* Connect a container to a network
*
* @param string $container
* @param string $network
* @return bool
*/
public function networkConnect(string $container, string $network): bool
{
Expand All @@ -247,11 +231,6 @@ public function networkConnect(string $container, string $network): bool

/**
* Disconnect a container from a network
*
* @param string $container
* @param string $network
* @param bool $force
* @return bool
*/
public function networkDisconnect(string $container, string $network, bool $force = false): bool
{
Expand Down Expand Up @@ -328,8 +307,6 @@ public function getStats(string $container = null, array $filters = []): array

/**
* List Networks
*
* @return array
*/
public function listNetworks(): array
{
Expand Down Expand Up @@ -359,9 +336,6 @@ public function listNetworks(): array

/**
* Pull Image
*
* @param string $image
* @return bool
*/
public function pull(string $image): bool
{
Expand Down Expand Up @@ -427,15 +401,9 @@ public function list(array $filters = []): array
* Creates and runs a new container, On success it will return a string containing the container ID.
* On fail it will throw an exception.
*
* @param string $image
* @param string $name
* @param string[] $command
* @param string $entrypoint
* @param string $workdir
* @param string[] $volumes
* @param array<string, string> $vars
* @param string $mountFolder
* @return string
*/
public function run(
string $image,
Expand Down Expand Up @@ -509,13 +477,8 @@ public function run(
/**
* Execute Container
*
* @param string $name
* @param string[] $command
* @param string &$stdout
* @param string &$stderr
* @param array<string, string> $vars
* @param int $timeout
* @return bool
*/
public function execute(
string $name,
Expand Down Expand Up @@ -566,10 +529,6 @@ public function execute(

/**
* Remove Container
*
* @param string $name
* @param bool $force
* @return bool
*/
public function remove(string $name, bool $force = false): bool
{
Expand Down
36 changes: 0 additions & 36 deletions src/Orchestration/Adapter/DockerCLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public function __construct(string $username = null, string $password = null)

/**
* Create Network
*
* @param string $name
* @param bool $internal
* @return bool
*/
public function createNetwork(string $name, bool $internal = false): bool
{
Expand All @@ -50,9 +46,6 @@ public function createNetwork(string $name, bool $internal = false): bool

/**
* Remove Network
*
* @param string $name
* @return bool
*/
public function removeNetwork(string $name): bool
{
Expand All @@ -66,10 +59,6 @@ public function removeNetwork(string $name): bool

/**
* Connect a container to a network
*
* @param string $container
* @param string $network
* @return bool
*/
public function networkConnect(string $container, string $network): bool
{
Expand All @@ -83,11 +72,6 @@ public function networkConnect(string $container, string $network): bool

/**
* Disconnect a container from a network
*
* @param string $container
* @param string $network
* @param bool $force
* @return bool
*/
public function networkDisconnect(string $container, string $network, bool $force = false): bool
{
Expand Down Expand Up @@ -214,8 +198,6 @@ private function parseIOStats(string $stats)

/**
* List Networks
*
* @return array
*/
public function listNetworks(): array
{
Expand Down Expand Up @@ -248,9 +230,6 @@ public function listNetworks(): array

/**
* Pull Image
*
* @param string $image
* @return bool
*/
public function pull(string $image): bool
{
Expand Down Expand Up @@ -322,15 +301,9 @@ public function list(array $filters = []): array
* Creates and runs a new container, On success it will return a string containing the container ID.
* On fail it will throw an exception.
*
* @param string $image
* @param string $name
* @param string[] $command
* @param string $entrypoint
* @param string $workdir
* @param string[] $volumes
* @param array<string, string> $vars
* @param string $mountFolder
* @return string
*/
public function run(string $image,
string $name,
Expand Down Expand Up @@ -413,13 +386,8 @@ public function run(string $image,
/**
* Execute Container
*
* @param string $name
* @param string[] $command
* @param string &$stdout
* @param string &$stderr
* @param array<string, string> $vars
* @param int $timeout
* @return bool
*/
public function execute(
string $name,
Expand Down Expand Up @@ -461,10 +429,6 @@ public function execute(

/**
* Remove Container
*
* @param string $name
* @param bool $force
* @return bool
*/
public function remove(string $name, bool $force = false): bool
{
Expand Down
Loading

0 comments on commit 55f4351

Please sign in to comment.