Skip to content

Commit

Permalink
add byodb source and ST support
Browse files Browse the repository at this point in the history
  • Loading branch information
pivnicek committed Dec 3, 2024
1 parent c782822 commit 668a631
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
40 changes: 30 additions & 10 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Config extends BaseConfig
'account' => 'NE35810',
'region' => 'GCP_US_EAST4',
],
'coates.keboola.cloud' => [
'connection.coates.keboola.cloud' => [
'db_replica_prefix' => 'COATESAWSUS',
'db_prefix' => 'KBC_AWSUSE1',
'account' => 'ALB08210',
Expand Down Expand Up @@ -98,6 +98,12 @@ public function getTargetWarehouse(): string

public function getSourceDatabaseAccount(): string
{
if ($this->isSourceByodb()) {
$sourceByodb = $this->getValue(['parameters', 'sourceByodb']);
assert(array_key_exists($sourceByodb, self::BYODB_DATABASES));

return self::BYODB_DATABASES[$sourceByodb]['account'];
}
$url = parse_url($this->getSourceKbcUrl());
assert($url && array_key_exists('host', $url));

Expand All @@ -106,6 +112,12 @@ public function getSourceDatabaseAccount(): string

public function getSourceDatabaseRegion(): string
{
if ($this->isSourceByodb()) {
$sourceByodb = $this->getValue(['parameters', 'sourceByodb']);
assert(array_key_exists($sourceByodb, self::BYODB_DATABASES));

return self::BYODB_DATABASES[$sourceByodb]['region'];
}
$url = parse_url($this->getSourceKbcUrl());
assert($url && array_key_exists('host', $url));

Expand All @@ -114,6 +126,12 @@ public function getSourceDatabaseRegion(): string

public function getSourceDatabasePrefix(): string
{
if ($this->isSourceByodb()) {
$sourceByodb = $this->getValue(['parameters', 'sourceByodb']);
assert(array_key_exists($sourceByodb, self::BYODB_DATABASES));

return self::BYODB_DATABASES[$sourceByodb]['db_prefix'];
}
$url = parse_url($this->getSourceKbcUrl());
assert($url && array_key_exists('host', $url));

Expand All @@ -122,7 +140,12 @@ public function getSourceDatabasePrefix(): string

public function getReplicaDatabasePrefix(): string
{
if ($this->isSourceByodb()) {
$sourceByodb = $this->getValue(['parameters', 'sourceByodb']);
assert(array_key_exists($sourceByodb, self::BYODB_DATABASES));

return self::BYODB_DATABASES[$sourceByodb]['db_replica_prefix'];
}
$url = parse_url($this->getSourceKbcUrl());
assert($url && array_key_exists('host', $url));

Expand Down Expand Up @@ -176,18 +199,15 @@ public function isDryRun(): bool
return (bool) $this->getValue(['parameters', 'dryRun']);
}

public function getIncludedWorkspaceSchemas(): array
{
return $this->getArrayValue(['parameters', 'includeWorkspaceSchemas']);
}

public function getIncludedExternalSchemas(): array
public function isSourceByodb(): bool
{
return $this->getArrayValue(['parameters', 'includeExternalSchemas']);
return (bool) $this->getValue(['parameters', 'isSourceByodb']);
}

public function getByodbSource(): bool
public function getByodbSource(): array
{
return (bool) $this->getValue(['parameters', 'sourceByodb']);
$sourceByodb = $this->getValue(['parameters', 'sourceByodb']);
assert(array_key_exists($sourceByodb, self::BYODB_DATABASES));
return self::BYODB_DATABASES[$sourceByodb];
}
}
1 change: 1 addition & 0 deletions src/Configuration/ConfigDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ protected function getParametersDefinition(): ArrayNodeDefinition
->enumNode('mode')->values(['sapi', 'database'])->defaultValue('sapi')->end()
->booleanNode('dryRun')->defaultFalse()->end()
->booleanNode('isSourceByodb')->defaultFalse()->end()
->scalarNode('sourceByodb')->end()
->scalarNode('sourceKbcUrl')->isRequired()->cannotBeEmpty()->end()
->scalarNode('#sourceKbcToken')->isRequired()->cannotBeEmpty()->end()
->arrayNode('tables')->prototype('scalar')->end()->end()
Expand Down

0 comments on commit 668a631

Please sign in to comment.