Skip to content

Commit 7096b15

Browse files
committed
extract path to shared const
1 parent 8d78451 commit 7096b15

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/KubernetesClientConfiguration.InCluster.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using System;
22
using System.IO;
3-
using System.Security.Cryptography.X509Certificates;
43
using k8s.Exceptions;
54

65
namespace k8s
76
{
87
public partial class KubernetesClientConfiguration
98
{
10-
private const string ServiceAccountTokenKey = "token";
11-
private const string ServiceAccountRootCAKey = "ca.crt";
9+
private const string ServiceaccountPath = "/var/run/secrets/kubernetes.io/serviceaccount/";
10+
private const string ServiceAccountTokenKeyFileName = "token";
11+
private const string ServiceAccountRootCAKeyFileName = "ca.crt";
1212

1313
public static KubernetesClientConfiguration InClusterConfig()
1414
{
@@ -21,8 +21,8 @@ public static KubernetesClientConfiguration InClusterConfig()
2121
"unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined");
2222
}
2323

24-
var token = File.ReadAllText("/var/run/secrets/kubernetes.io/serviceaccount/" + ServiceAccountTokenKey);
25-
var rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/" + ServiceAccountRootCAKey;
24+
var token = File.ReadAllText(Path.Combine(ServiceaccountPath, ServiceAccountTokenKeyFileName));
25+
var rootCAFile = Path.Combine(ServiceaccountPath, ServiceAccountRootCAKeyFileName);
2626

2727
return new KubernetesClientConfiguration
2828
{

0 commit comments

Comments
 (0)