Skip to content

Commit 67f1c0d

Browse files
committed
Remove json schema validation
1 parent ee651b6 commit 67f1c0d

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

bin/build

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ foreach ($iterator as $fileInfo) {
6868
}
6969
}
7070

71-
// Add schema.json
72-
echo "+ /src/schema.json\n";
73-
$phar->addFile(realpath(__DIR__ . '/../src/schema.json'), '/src/schema.json');
74-
7571
// Add Caddyfile
7672
echo "+ /recipe/provision/Caddyfile\n";
7773
$phar->addFile(realpath(__DIR__ . '/../recipe/provision/Caddyfile'), '/recipe/provision/Caddyfile');

src/Importer/Importer.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,9 @@
1010

1111
namespace Deployer\Importer;
1212

13-
use Deployer\Deployer;
1413
use Deployer\Exception\ConfigurationException;
1514
use Deployer\Exception\Exception;
16-
use JsonSchema\Constraints\Constraint;
17-
use JsonSchema\Constraints\Factory;
18-
use JsonSchema\SchemaStorage;
19-
use JsonSchema\Validator;
2015
use Symfony\Component\Yaml\Yaml;
21-
2216
use function array_filter;
2317
use function array_keys;
2418
use function Deployer\after;
@@ -33,8 +27,6 @@
3327
use function Deployer\Support\find_line_number;
3428
use function Deployer\task;
3529
use function Deployer\upload;
36-
use function substr;
37-
3830
use const ARRAY_FILTER_USE_KEY;
3931

4032
class Importer
@@ -76,27 +68,11 @@ public static function import($paths)
7668
} elseif (preg_match('/\.ya?ml$/i', $path)) {
7769
self::$recipeFilename = basename($path);
7870
self::$recipeSource = file_get_contents($path, true);
71+
7972
$root = array_filter(Yaml::parse(self::$recipeSource), static function (string $key) {
80-
return substr($key, 0, 1) !== '.';
73+
return !str_starts_with($key, '.');
8174
}, ARRAY_FILTER_USE_KEY);
8275

83-
$schema = 'file://' . __DIR__ . '/../schema.json';
84-
if (Deployer::isPharArchive()) {
85-
$schema = __DIR__ . '/../schema.json';
86-
}
87-
$yamlSchema = json_decode(file_get_contents($schema));
88-
$schemaStorage = new SchemaStorage();
89-
$schemaStorage->addSchema('file://schema', $yamlSchema);
90-
$validator = new Validator(new Factory($schemaStorage));
91-
$validator->validate($root, $yamlSchema, Constraint::CHECK_MODE_TYPE_CAST);
92-
if (!$validator->isValid()) {
93-
$msg = "YAML " . self::$recipeFilename . " does not validate. Violations:\n";
94-
foreach ($validator->getErrors() as $error) {
95-
$msg .= "[{$error['property']}] {$error['message']}\n";
96-
}
97-
throw new ConfigurationException($msg);
98-
}
99-
10076
foreach (array_keys($root) as $key) {
10177
static::$key($root[$key]);
10278
}

0 commit comments

Comments
 (0)