Skip to content

Commit 236a771

Browse files
committed
Fix KubeConfig temp certificate filename extension .pem
1 parent 990acd6 commit 236a771

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Traits/Cluster/LoadsFromKubeConfig.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ protected function writeTempFileForContext(
244244
/** @var \RenokiCo\PhpK8s\KubernetesCluster $this */
245245
$tempFolder = static::$tempFolder ?: sys_get_temp_dir();
246246

247-
$tempFilePath = $tempFolder.DIRECTORY_SEPARATOR.Str::slug("ctx-{$context}-{$userName}-{$url}-{$fileName}");
247+
$tempFilePath = $tempFolder.DIRECTORY_SEPARATOR.Str::slug("ctx-{$context}-{$userName}-{$url}")."-{$fileName}";
248248

249249
if (file_exists($tempFilePath)) {
250250
return $tempFilePath;

tests/KubeConfigTest.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111

1212
class KubeConfigTest extends TestCase
1313
{
14+
private $tempFolder;
15+
1416
/**
1517
* {@inheritdoc}
1618
*/
1719
public function setUp(): void
1820
{
1921
parent::setUp();
2022

21-
KubernetesCluster::setTempFolder(__DIR__.DIRECTORY_SEPARATOR.'temp');
23+
$this->tempFolder = __DIR__.DIRECTORY_SEPARATOR.'temp';
24+
KubernetesCluster::setTempFolder($this->tempFolder);
2225
}
2326

2427
/**
@@ -41,6 +44,12 @@ public function test_kube_config_from_yaml_file_with_base64_encoded_ssl()
4144
'ssl_key' => $keyPath,
4245
] = $cluster->getClient()->getConfig();
4346

47+
$tempFilePath = $this->tempFolder.DIRECTORY_SEPARATOR.'ctx-minikube-minikube-httpsminikube8443-';
48+
49+
$this->assertSame($tempFilePath.'ca-cert.pem', $caPath);
50+
$this->assertSame($tempFilePath.'client-cert.pem', $certPath);
51+
$this->assertSame($tempFilePath.'client-key.pem', $keyPath);
52+
4453
$this->assertEquals("some-ca\n", file_get_contents($caPath));
4554
$this->assertEquals("some-cert\n", file_get_contents($certPath));
4655
$this->assertEquals("some-key\n", file_get_contents($keyPath));

0 commit comments

Comments
 (0)