forked from ashleyhood/php-lxd
-
Notifications
You must be signed in to change notification settings - Fork 4
PHP8, Guzzle 7 and new Endpoints #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
renky
wants to merge
9
commits into
turtle0x1:master
Choose a base branch
from
renky:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e125a67
Guzzle7 compatibility
2568c5e
fixed response when execution is waiting
8c4dd21
fixed error when output not set
f2360e1
due to used features php 5 isn't possible any more
098e06f
due to used features php 5 isn't possible any more
d91dcc9
php8 support
afbc2f8
added ExecOutput Endpoint
20d4f45
added endpoint-detection for exec-output
0cafaf4
added endpoint-detection for exec-output
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Opensaucesystems\Lxd\Endpoint\Instance\Logs; | ||
|
||
use Opensaucesystems\Lxd\Endpoint\AbstractEndpoint; | ||
|
||
class ExecOutput extends AbstractEndpoint | ||
{ | ||
private $endpoint; | ||
|
||
protected function getEndpoint() | ||
{ | ||
return $this->endpoint; | ||
} | ||
|
||
public function setEndpoint(string $endpoint) | ||
{ | ||
$this->endpoint = $endpoint; | ||
} | ||
|
||
/** | ||
* List of exec record-output logs for a container | ||
* | ||
* @param string $name Name of container | ||
* @return array | ||
*/ | ||
public function all($name) | ||
{ | ||
$logs = []; | ||
|
||
foreach ($this->get($this->getEndpoint().$name.'/logs/exec-output/') as $log) { | ||
$logs[] = str_replace( | ||
'/'.$this->client->getApiVersion().$this->getEndpoint().$name.'/logs/exec-output/', | ||
'', | ||
$log | ||
); | ||
} | ||
|
||
return $logs; | ||
} | ||
|
||
/** | ||
* Get the contents of a particular exec record-output log file | ||
* | ||
* @param string $name Name of container | ||
* @param string $log Name of log | ||
* @return object | ||
*/ | ||
public function read($name, $log) | ||
{ | ||
return $this->get($this->getEndpoint().$name.'/logs/exec-output/'.$log); | ||
} | ||
|
||
/** | ||
* Remove a particular exec record-output log file | ||
* | ||
* @param string $name Name of container | ||
* @param string $log Name of log | ||
* @return object | ||
*/ | ||
public function remove($name, $log) | ||
{ | ||
return $this->delete($this->getEndpoint().$name.'/logs/exec-output/'.$log); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Opensaucesystems\Lxd\Helpers; | ||
|
||
/** | ||
* Inspired by Laravel | ||
* https://github.com/illuminate/support/blob/master/Str.php | ||
*/ | ||
class Str | ||
{ | ||
/** | ||
* The cache of studly-cased words. | ||
* | ||
* @var array | ||
*/ | ||
protected static $studlyCache = []; | ||
|
||
/** | ||
* Convert a value to studly caps case. | ||
* | ||
* @param string $value | ||
* @return string | ||
*/ | ||
public static function studly($value) | ||
{ | ||
$key = $value; | ||
|
||
if (isset(static::$studlyCache[$key])) { | ||
return static::$studlyCache[$key]; | ||
} | ||
|
||
$words = explode(' ', str_replace(['-', '_'], ' ', $value)); | ||
|
||
$studlyWords = array_map(function ($word) { return ucfirst($word); }, $words); | ||
|
||
return static::$studlyCache[$key] = implode($studlyWords); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? PSR says we shouldn't have class names with "-" or "_" so it seems like an un-needed code path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Class name is ...\Logs\ExecOutput - but to use it in the code you need to do something like that:
$client->containers->logs->exec_output->read
and I don't want to do ...->execOutput->read - thats looking aweful :) so it needs a possibility to come from exec_output to ExecOutput... studly is the best option for it...
finally id also like to add a Trait that contains the __get method - so it can be used everywhere - but for now it would be a to big refactoring...