Skip to content

Commit

Permalink
fix: Better error message if local scaffold file can't be resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
stmh committed May 11, 2023
1 parent 4a7f9e8 commit 87f5b38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Method/K8sMethod.php
Expand Up @@ -334,8 +334,12 @@ protected function scaffold(HostConfig $host_config, TaskContextInterface $conte

$root_folder = $this->ensureShell($host_config, $context);
$scaffold_url = $kube_config['scaffolder']['baseUrl'] . '/' . $kube_config['scaffolder']['template'];
if ($scaffold_url[0] == '.') {
if ($scaffold_url[0] === '.') {
$orig_scaffold_url = $scaffold_url;
$scaffold_url = realpath($scaffold_url);
if (!$scaffold_url) {
throw new \RuntimeException(sprintf('Could not find scaffold file at `%s`!', $orig_scaffold_url));
}
}
$scaffolder = new Scaffolder($configuration);

Expand Down
8 changes: 7 additions & 1 deletion src/Scaffolder/Scaffolder.php
Expand Up @@ -95,6 +95,7 @@ public function scaffold(
$is_remote = false;
$root_path = $options->getRootPath();
if (!$data = $options->getScaffoldDefinition()) {
$orig_url = $url;
$root_path = dirname($url);
try {
if (!Utilities::isHttpUrl($url)) {
Expand All @@ -111,7 +112,12 @@ public function scaffold(
$is_remote = true;
}
} catch (ParseException $e) {
throw new YamlParseException(sprintf("Could not parse %s! Working dir: %s", $url, getcwd()), 0, $e);
throw new YamlParseException(sprintf(
"Could not parse `%s` (%s)! Working dir: %s",
$orig_url,
$url,
getcwd()
), 0, $e);
}
if (!$data) {
throw new InvalidArgumentException('Could not read yaml from ' . $url);
Expand Down

0 comments on commit 87f5b38

Please sign in to comment.