Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ jobs:
strategy:
fail-fast: false
matrix:
phpVersion: [7.4, 8.0, 8.1]
phpVersion: [8.1, 8.2, 8.3]
symfonyVersion: ["5.4.*", "6.1.*"]
exclude:
- phpVersion: 7.4
symfonyVersion: "6.1.*"

steps:
-
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
},
"require": {
"php": "^7.4|^8.0",
"php": ">=8.1",
"ext-json": "*",
"keboola/common-exceptions": "^1.2",
"monolog/monolog": "^2.3",
Expand Down
12 changes: 9 additions & 3 deletions src/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,18 @@ public function getEnvKbcUrl(): string
return (string) $env;
}

public function getDataTypeSupport(): string
public function getDataTypeSupport(): ?DatatypeSupport
{
$env = getenv('KBC_DATA_TYPE_SUPPORT');
if (!$env) {
return 'none';
return DatatypeSupport::NONE;
}
return $this->getStringValue(['storage', 'output', 'data_type_support'], (string) $env);
$datatypeSupport = DatatypeSupport::tryFrom($this->getStringValue([
'storage',
'output',
'data_type_support',
], (string) $env));

return $datatypeSupport ?? DatatypeSupport::from((string) $env);
}
}
17 changes: 17 additions & 0 deletions src/Config/DatatypeSupport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Keboola\Component\Config;

enum DatatypeSupport: string
{
case AUTHORITATIVE = 'authoritative';
case HINT = 'hint';
case NONE = 'none';

public function usingLegacyManifest(): bool
{
return $this === self::NONE;
}
}
43 changes: 40 additions & 3 deletions tests/Config/BaseConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Generator;
use Keboola\Component\Config\BaseConfig;
use Keboola\Component\Config\BaseConfigDefinition;
use Keboola\Component\Config\DatatypeSupport;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
Expand Down Expand Up @@ -240,7 +241,43 @@ protected function getParametersDefinition(): ArrayNodeDefinition
$config->getValue(['parameters', 'ipsum', 'dolor']),
);
$this->assertEquals(
'hint',
DatatypeSupport::HINT,
$config->getDataTypeSupport(),
);
}

public function testGetDataTypeSupportUserInvalidInput(): void
{
putenv('KBC_DATA_TYPE_SUPPORT=authoritative');
$config = new BaseConfig([
'storage' => [
'output' => [
'data_type_support' => 'I\'m invalid',
'files' => [],
],
],
], new BaseConfigDefinition);

$this->assertEquals(
DatatypeSupport::AUTHORITATIVE, // from env
$config->getDataTypeSupport(),
);
}

public function testGetDataTypeSupportNoEnvUserInvalidInput(): void
{
putenv('KBC_DATA_TYPE_SUPPORT=');
$config = new BaseConfig([
'storage' => [
'output' => [
'data_type_support' => 'I\'m invalid',
'files' => [],
],
],
], new BaseConfigDefinition);

$this->assertEquals(
DatatypeSupport::NONE, // default when env not setZ
$config->getDataTypeSupport(),
);
}
Expand Down Expand Up @@ -325,9 +362,9 @@ public function testEnvGetters(array $envs): void
}

if (!isset($envs['KBC_DATA_TYPE_SUPPORT'])) {
Assert::assertEquals('none', $config->getDataTypeSupport());
Assert::assertEquals(DatatypeSupport::NONE, $config->getDataTypeSupport());
} else {
Assert::assertEquals($envs['KBC_DATA_TYPE_SUPPORT'], $config->getDataTypeSupport());
Assert::assertEquals(DatatypeSupport::from($envs['KBC_DATA_TYPE_SUPPORT']), $config->getDataTypeSupport());
}

foreach ($envs as $env => $value) {
Expand Down