diff --git a/src/Component.php b/src/Component.php index 72fcf63..383dde1 100644 --- a/src/Component.php +++ b/src/Component.php @@ -82,6 +82,12 @@ protected function run(): void case 'create-state': $this->writeOutputStateToFile($config->getArrayValue(['parameters', 'arbitrary'])); break; + case 'create-result': + file_put_contents( + $this->getDataDir() . '/out/result.json', + (string) json_encode($config->getResult()), + ); + break; case 'whoami': $process = new Process(['whoami']); $process->mustRun(); diff --git a/src/Config.php b/src/Config.php index c83bbdf..581510d 100644 --- a/src/Config.php +++ b/src/Config.php @@ -48,4 +48,9 @@ public function getLogs(): array // @phpstan-ignore-next-line because getArrayValue returns generic array return $this->getArrayValue(['parameters', 'logs']); } + + public function getResult(): mixed + { + return $this->getValue(['parameters', 'result']); + } } diff --git a/src/ConfigDefinition.php b/src/ConfigDefinition.php index 9937582..4971776 100644 --- a/src/ConfigDefinition.php +++ b/src/ConfigDefinition.php @@ -14,6 +14,7 @@ protected function getParametersDefinition(): ArrayNodeDefinition { $operations = [ 'application-error', + 'create-result', 'create-state', 'child-jobs', 'dump-config', @@ -38,6 +39,7 @@ protected function getParametersDefinition(): ArrayNodeDefinition ->end() ->scalarNode('timeout')->end() ->variableNode('arbitrary')->end() + ->variableNode('result')->end() ->scalarNode('#token')->end() ->scalarNode('queueApiUrl')->end() ->scalarNode('childJobsCount')->end() diff --git a/tests/functional/create-result/expected-code b/tests/functional/create-result/expected-code new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/functional/create-result/expected-code @@ -0,0 +1 @@ +0 diff --git a/tests/functional/create-result/expected/data/out/files/.gitkeep b/tests/functional/create-result/expected/data/out/files/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/functional/create-result/expected/data/out/result.json b/tests/functional/create-result/expected/data/out/result.json new file mode 100644 index 0000000..c21d7a3 --- /dev/null +++ b/tests/functional/create-result/expected/data/out/result.json @@ -0,0 +1 @@ +{"variables":{"foo":"bar"}} \ No newline at end of file diff --git a/tests/functional/create-result/expected/data/out/tables/.gitkeep b/tests/functional/create-result/expected/data/out/tables/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/functional/create-result/source/data/config.json b/tests/functional/create-result/source/data/config.json new file mode 100644 index 0000000..c1abf2d --- /dev/null +++ b/tests/functional/create-result/source/data/config.json @@ -0,0 +1,10 @@ +{ + "parameters": { + "operation": "create-result", + "result": { + "variables": { + "foo": "bar" + } + } + } +}