diff --git a/src/Traits/Cluster/LoadsFromKubeConfig.php b/src/Traits/Cluster/LoadsFromKubeConfig.php index aab4bba8..60f8948e 100644 --- a/src/Traits/Cluster/LoadsFromKubeConfig.php +++ b/src/Traits/Cluster/LoadsFromKubeConfig.php @@ -244,7 +244,7 @@ protected function writeTempFileForContext( /** @var \RenokiCo\PhpK8s\KubernetesCluster $this */ $tempFolder = static::$tempFolder ?: sys_get_temp_dir(); - $tempFilePath = $tempFolder.DIRECTORY_SEPARATOR.Str::slug("ctx-{$context}-{$userName}-{$url}-{$fileName}"); + $tempFilePath = $tempFolder.DIRECTORY_SEPARATOR.Str::slug("ctx-{$context}-{$userName}-{$url}")."-{$fileName}"; if (file_exists($tempFilePath)) { return $tempFilePath; diff --git a/tests/KubeConfigTest.php b/tests/KubeConfigTest.php index a69a5457..b98a3ff9 100644 --- a/tests/KubeConfigTest.php +++ b/tests/KubeConfigTest.php @@ -11,6 +11,8 @@ class KubeConfigTest extends TestCase { + private $tempFolder; + /** * {@inheritdoc} */ @@ -18,7 +20,8 @@ public function setUp(): void { parent::setUp(); - KubernetesCluster::setTempFolder(__DIR__.DIRECTORY_SEPARATOR.'temp'); + $this->tempFolder = __DIR__.DIRECTORY_SEPARATOR.'temp'; + KubernetesCluster::setTempFolder($this->tempFolder); } /** @@ -41,6 +44,12 @@ public function test_kube_config_from_yaml_file_with_base64_encoded_ssl() 'ssl_key' => $keyPath, ] = $cluster->getClient()->getConfig(); + $tempFilePath = $this->tempFolder.DIRECTORY_SEPARATOR.'ctx-minikube-minikube-httpsminikube8443-'; + + $this->assertSame($tempFilePath.'ca-cert.pem', $caPath); + $this->assertSame($tempFilePath.'client-cert.pem', $certPath); + $this->assertSame($tempFilePath.'client-key.pem', $keyPath); + $this->assertEquals("some-ca\n", file_get_contents($caPath)); $this->assertEquals("some-cert\n", file_get_contents($certPath)); $this->assertEquals("some-key\n", file_get_contents($keyPath));