Skip to content

Commit

Permalink
Gets token proper and introduces a clean env name
Browse files Browse the repository at this point in the history
  • Loading branch information
bomoko committed Dec 5, 2023
1 parent 601c2fa commit 6470bb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@ private function grabCluster($token = null, $kubeContext = null)
return KubernetesCluster::fromKubeConfigVariable($kubeContext)
->withToken($token);
}
$deployTokenFile = file_exists("/var/run/secrets/lagoon/deployer/token") ? "/var/run/secrets/lagoon/deployer/token" : "/var/run/secrets/kubernetes.io/serviceaccount/token";

$cluster = KubernetesCluster::inClusterConfiguration(
"https://kubernetes.default.svc.cluster.local"
)
->loadTokenFromFile("/var/run/secrets/lagoon/deployer/token");
->loadTokenFromFile($deployTokenFile);
return $cluster;
}

Expand All @@ -148,11 +150,19 @@ protected function getToken($token = null)
if (!empty($token)) {
return $token;
}

$inClusterTokenFile = "/var/run/secrets/lagoon/deployer/token";

if (file_exists($inClusterTokenFile)) {
return trim(file_get_contents($inClusterTokenFile));
}

$inClusterTokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token";

if (file_exists($inClusterTokenFile)) {
return trim(file_get_contents($inClusterTokenFile));
}

}


Expand Down
2 changes: 2 additions & 0 deletions src/Step/StepParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public function run(array $args) {
*/
public function doTextSubstitutions($string)
{
$environmentClean = str_replace("/","-", $this->args->environment);
$extraSubs = [
'project' => $this->args->project,
'environment' => $this->args->environment,
'environmentClean' => $environmentClean,
'namespace' => $this->args->namespace,
];

Expand Down

0 comments on commit 6470bb6

Please sign in to comment.