Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
41 changes: 10 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ name: CI
on:
push:
branches:
- "*"
- main
tags:
- "*"
pull_request:
branches:
- "*"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
Expand All @@ -22,16 +26,9 @@ jobs:
fail-fast: false
matrix:
php: ['8.3', '8.4', '8.5']
kubernetes: ['1.33.10', '1.34.6', '1.35.3']
laravel: ['12.*', '13.*']
prefer: [prefer-lowest, prefer-stable]
include:
- laravel: "12.*"
testbench: "10.*"
- laravel: "13.*"
testbench: "11.*"
kubernetes: ['1.33.10']

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - K8s v${{ matrix.kubernetes }} --${{ matrix.prefer }}
name: PHP ${{ matrix.php }} - K8s v${{ matrix.kubernetes }}
Comment thread
loks0n marked this conversation as resolved.

steps:
- uses: actions/checkout@v6
Expand All @@ -43,27 +40,11 @@ jobs:
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, yaml
coverage: pcov

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Prepare cache key
id: prep
run: |
PHP_VERSION=${{ matrix.php }}
LARAVEL_VERSION=${{ matrix.laravel }}
PREFER_VERSION=${{ matrix.prefer }}

# Remove any .* from the versions
LARAVEL_VERSION=${LARAVEL_VERSION//.*}

echo "cache-key=composer-php-$PHP_VERSION-$LARAVEL_VERSION-$PREFER_VERSION-${{ hashFiles('composer.json') }}" >> $GITHUB_OUTPUT

- uses: actions/cache@v5
name: Cache dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ steps.prep.outputs.cache-key }}
path: ~/.composer/cache/files
key: composer-php-${{ matrix.php }}-${{ hashFiles('composer.json') }}

- uses: medyagh/setup-minikube@latest
name: Setup Minikube
Expand Down Expand Up @@ -92,9 +73,7 @@ jobs:
kubectl proxy --port=8080 --reject-paths="^/non-existent-path" &

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.prefer }} --prefer-dist --no-interaction
run: composer update --prefer-stable --prefer-dist --no-interaction

- name: Setup in-cluster config
run: |
Expand Down
15 changes: 7 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"ext-json": "*",
"composer/semver": "^3.4",
"guzzlehttp/guzzle": "^7.10",
"illuminate/macroable": "^12.0|^13.0",
"illuminate/support": "^12.0|^13.0",
"ratchet/pawl": "^0.4.1",
"symfony/process": "^7.3.4|^8.0"
"illuminate/macroable": "^12.0",
"illuminate/support": "^12.0",
"ratchet/pawl": "^0.4.3",
"symfony/process": "^7.4"
},
"suggest": {
"ext-yaml": "YAML extension is used to read or generate YAML from PHP K8s internal classes.",
Expand All @@ -57,14 +57,13 @@
"test": "vendor/bin/phpunit"
},
"require-dev": {
"laravel/pint": "dev-main",
"laravel/pint": "^1.29",
"mockery/mockery": "^1.6",
"orchestra/testbench": "^10.9.0|^11.0",
"orchestra/testbench": "^10.9.0",
"phpunit/phpunit": "^11.5",
"vimeo/psalm": "^6.16.1"
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev"
}
}
80 changes: 80 additions & 0 deletions src/Instances/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

class Container extends Instance
{
/**
* Set the container name.
*/
public function setName(string $name): static
{
return $this->setAttribute('name', $name);
}

/**
* Get the container name.
*/
public function getName(): ?string
{
return $this->getAttribute('name');
}

/**
* Set the image for the container.
*
Expand All @@ -14,6 +30,70 @@ public function setImage(string $image, string $tag = 'latest'): static
return $this->setAttribute('image', $image.':'.$tag);
}

/**
* Set the image pull policy.
*/
public function setImagePullPolicy(string $policy): static
{
return $this->setAttribute('imagePullPolicy', $policy);
}

/**
* Get the image pull policy.
*/
public function getImagePullPolicy(): ?string
{
return $this->getAttribute('imagePullPolicy');
}

/**
* Set the command (entrypoint) for the container.
*/
public function setCommand(array $command): static
{
return $this->setAttribute('command', $command);
}

/**
* Get the command (entrypoint) for the container.
*/
public function getCommand(): array
{
return $this->getAttribute('command', []);
}

/**
* Set the args for the container.
*/
public function setArgs(array $args): static
{
return $this->setAttribute('args', $args);
}

/**
* Get the args for the container.
*/
public function getArgs(): array
{
return $this->getAttribute('args', []);
}

/**
* Set the working directory for the container.
*/
public function setWorkingDir(string $dir): static
{
return $this->setAttribute('workingDir', $dir);
}

/**
* Get the working directory for the container.
*/
public function getWorkingDir(): ?string
{
return $this->getAttribute('workingDir');
}

/**
* Add a new port to the container list.
*
Expand Down
16 changes: 16 additions & 0 deletions src/Kinds/K8sSecret.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ class K8sSecret extends K8sResource implements InteractsWithK8sCluster, Watchabl
*/
protected static bool $namespaceable = true;

/**
* Set the secret type.
*/
public function setType(string $type): static
{
return $this->setAttribute('type', $type);
}

/**
* Get the secret type.
*/
public function getType(): ?string
{
return $this->getAttribute('type');
}

/**
* Get the data attribute.
* Supports base64 decoding.
Expand Down
25 changes: 9 additions & 16 deletions src/Traits/RunsClusterOperations.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use RenokiCo\PhpK8s\Exceptions\KubernetesLogsException;
use RenokiCo\PhpK8s\Exceptions\KubernetesScalingException;
use RenokiCo\PhpK8s\Exceptions\KubernetesWatchException;
use RenokiCo\PhpK8s\Kinds\K8sResource;
use RenokiCo\PhpK8s\Kinds\K8sScale;
use RenokiCo\PhpK8s\KubernetesCluster;
use RenokiCo\PhpK8s\Patches\JsonMergePatch;
Expand Down Expand Up @@ -107,10 +106,8 @@ public function refreshResourceVersion(): static
/**
* Create or update the resource, wether the resource exists
* or not within the cluster.
*
* @return $this
*/
public function syncWithCluster(array $query = ['pretty' => 1]): K8sResource
public function syncWithCluster(array $query = ['pretty' => 1]): static
{
try {
return $this->get($query);
Expand All @@ -121,10 +118,8 @@ public function syncWithCluster(array $query = ['pretty' => 1]): K8sResource

/**
* Create or update the app based on existence.
*
* @return $this
*/
public function createOrUpdate(array $query = ['pretty' => 1]): K8sResource
public function createOrUpdate(array $query = ['pretty' => 1]): static
{
if ($this->exists($query)) {
$this->update($query);
Expand Down Expand Up @@ -174,10 +169,9 @@ public function allNamespaces(array $query = ['pretty' => 1]): ResourcesList
/**
* Get a fresh instance from the cluster.
*
*
* @throws KubernetesAPIException
*/
public function get(array $query = ['pretty' => 1]): K8sResource
public function get(array $query = ['pretty' => 1]): static
{
return $this->cluster
->setResourceClass(get_class($this))
Expand All @@ -192,10 +186,9 @@ public function get(array $query = ['pretty' => 1]): K8sResource
/**
* Create the resource.
*
*
* @throws KubernetesAPIException
*/
public function create(array $query = ['pretty' => 1]): K8sResource
public function create(array $query = ['pretty' => 1]): static
{
return $this->cluster
->setResourceClass(get_class($this))
Expand Down Expand Up @@ -604,7 +597,7 @@ public function resourceStatusPath(): string
/**
* Update the status subresource.
*/
public function updateStatus(array $query = ['pretty' => 1]): self
public function updateStatus(array $query = ['pretty' => 1]): static
{
$this->refreshOriginal();
$this->refreshResourceVersion();
Expand All @@ -622,9 +615,9 @@ public function updateStatus(array $query = ['pretty' => 1]): self
/**
* JSON Patch (RFC 6902) the status subresource.
*/
public function jsonPatchStatus(JsonPatch|array $patch, array $query = ['pretty' => 1]): self
public function jsonPatchStatus(JsonPatch|array $patch, array $query = ['pretty' => 1]): static
{
if (! $patch instanceof JsonPatch) {
if (is_array($patch)) {
$patch = new JsonPatch($patch);
}

Expand All @@ -645,9 +638,9 @@ public function jsonPatchStatus(JsonPatch|array $patch, array $query = ['pretty'
/**
* JSON Merge Patch (RFC 7396) the status subresource.
*/
public function jsonMergePatchStatus(JsonMergePatch|array $patch, array $query = ['pretty' => 1]): self
public function jsonMergePatchStatus(JsonMergePatch|array $patch, array $query = ['pretty' => 1]): static
{
if (! $patch instanceof JsonMergePatch) {
if (is_array($patch)) {
$patch = new JsonMergePatch($patch);
}

Expand Down
Loading