Skip to content
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

Move to composer/semver #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
}
],
"require": {
"composer/semver": "*",
"guzzlehttp/guzzle": "^6.5|^7.0",
"illuminate/macroable": "^9.35|^10.1|^11.0",
"illuminate/support": "^9.35|^10.1|^11.0",
"ratchet/pawl": "^0.4.1",
"symfony/process": "^5.4|^6.0|^7.0",
"vierbergenlars/php-semver": "^2.1|^3.0"
"symfony/process": "^5.4|^6.0|^7.0"
},
"suggest": {
"ext-yaml": "YAML extension is used to read or generate YAML from PHP K8s internal classes."
Expand Down
11 changes: 6 additions & 5 deletions src/Traits/Cluster/ChecksClusterVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

namespace RenokiCo\PhpK8s\Traits\Cluster;

use Composer\Semver\Comparator;
use Composer\Semver\VersionParser;
use GuzzleHttp\Exception\ClientException;
use RenokiCo\PhpK8s\Exceptions\KubernetesAPIException;
use vierbergenlars\SemVer\version as Semver;

trait ChecksClusterVersion
{
/**
* The Kubernetes cluster version.
*
* @var \vierbergenlars\SemVer\version|null
* @var string|null
*/
protected $kubernetesVersion;

Expand Down Expand Up @@ -44,7 +45,7 @@ protected function loadClusterVersion(): void

$json = @json_decode($response->getBody(), true);

$this->kubernetesVersion = new Semver($json['gitVersion']);
$this->kubernetesVersion = (new VersionParser)->normalize($json['gitVersion']);
}

/**
Expand All @@ -58,7 +59,7 @@ public function newerThan(string $kubernetesVersion): bool
{
$this->loadClusterVersion();

return Semver::gte(
return Comparator::greaterThanOrEqualTo(
$this->kubernetesVersion, $kubernetesVersion
);
}
Expand All @@ -74,7 +75,7 @@ public function olderThan(string $kubernetesVersion): bool
{
$this->loadClusterVersion();

return Semver::lt(
return Comparator::lessThan(
$this->kubernetesVersion, $kubernetesVersion
);
}
Expand Down