Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BI-4163: feat: add collate to greenplum form_config #161

Merged
merged 2 commits into from
Dec 12, 2023
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
10 changes: 9 additions & 1 deletion docker_build/target_base_ci/scripts/500-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/
#chmod 755 /etc/apt/keyrings
#chmod a+r /etc/apt/keyrings/docker.gpg

echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list
case $(arch) in
"aarch64"|"arm64")
arch="arm64"
;;
*)
arch="amd64"
;;
esac
echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu jammy stable" > /etc/apt/sources.list.d/docker.list
ovsds marked this conversation as resolved.
Show resolved Hide resolved

apt-get update
# apt-get install --yes docker-ce-cli docker-compose-plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@ echo 'Installing taskfile tool...'

TMP_DIR="$(mktemp -d)"

cd $TMP_DIR
wget https://github.com/go-task/task/releases/download/v3.29.1/task_linux_amd64.deb
echo "e411770abf73d5e094100ab7a1c8278f35b591ecadbfd778200b6b2ad1ee340b task_linux_amd64.deb" | sha256sum -c -
dpkg -i task_linux_amd64.deb
base_url="https://github.com/go-task/task/releases/download"
version="v3.29.1"
case $(arch) in
"aarch64"|"arm64")
arch="arm64"
checksum="a7688f188e2f21218a27c383e82ebc24d61677c9609c890ebed68a1fb21e3551"
;;
*)
arch="amd64"
checksum="e411770abf73d5e094100ab7a1c8278f35b591ecadbfd778200b6b2ad1ee340b"
;;
esac

rm -r "$TMP_DIR"
download_url="${base_url}/${version}/task_linux_${arch}.deb"
filename="task.deb"

cd "$TMP_DIR"
wget ${download_url} -O ${filename}
sha256sum ${filename}
echo "${checksum} ${filename}" | sha256sum -c -
dpkg -i ${filename}

rm -r "${TMP_DIR}"
ovsds marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
from dl_configs.connectors_settings import ConnectorSettingsBase

from dl_connector_greenplum.api.connection_info import GreenplumConnectionInfoProvider
from dl_connector_postgresql.api.connection_form.form_config import (
PostgreSQLFieldName,
PostgresRowConstructor,
)


class GreenplumConnectionFormFactory(ConnectionFormFactory):
Expand All @@ -39,6 +43,7 @@ def _get_base_edit_api_schema(self) -> FormActionApiSchema:
),
FormFieldApiSchema(name=CommonFieldName.cache_ttl_sec, nullable=True),
FormFieldApiSchema(name=CommonFieldName.raw_sql_level),
FormFieldApiSchema(name=PostgreSQLFieldName.enforce_collate),
FormFieldApiSchema(name=CommonFieldName.data_export_forbidden),
],
)
Expand Down Expand Up @@ -76,6 +81,7 @@ def _get_base_form_config(
edit_api_schema: FormActionApiSchema,
check_api_schema: FormActionApiSchema,
rc: RowConstructor,
postgres_rc: PostgresRowConstructor,
) -> ConnectionForm:
return ConnectionForm(
title=GreenplumConnectionInfoProvider.get_title(self._localizer),
Expand All @@ -89,6 +95,7 @@ def _get_base_form_config(
C.CacheTTLRow(name=CommonFieldName.cache_ttl_sec),
rc.raw_sql_level_row(),
rc.collapse_advanced_settings_row(),
postgres_rc.enforce_collate_row(),
rc.data_export_forbidden_row(),
]
),
Expand All @@ -105,6 +112,7 @@ def get_form_config(
tenant: Optional[TenantDef],
) -> ConnectionForm:
rc = RowConstructor(localizer=self._localizer)
postgres_rc = PostgresRowConstructor(localizer=self._localizer)

host_section: list[FormRow] = [rc.host_row()]
username_section: list[FormRow] = [rc.username_row()]
Expand All @@ -122,4 +130,5 @@ def get_form_config(
edit_api_schema=edit_api_schema,
check_api_schema=check_api_schema,
rc=rc,
postgres_rc=postgres_rc,
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
GreenplumTableCoreSourceDefinition,
)
from dl_connector_postgresql.api.connector import PostgreSQLApiBackendDefinition
from dl_connector_postgresql.api.i18n.localizer import CONFIGS as BI_CONNECTOR_POSTGRESQL_CONFIGS


class GreenplumApiTableSourceDefinition(ApiSourceDefinition):
Expand Down Expand Up @@ -54,4 +55,4 @@ class GreenplumApiConnector(ApiConnector):
GreenplumApiTableSourceDefinition,
GreenplumApiSubselectSourceDefinition,
)
translation_configs = frozenset(CONFIGS)
translation_configs = frozenset(CONFIGS) | frozenset(BI_CONNECTOR_POSTGRESQL_CONFIGS)
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from dl_connector_greenplum.api.connection_form.form_config import GreenplumConnectionFormFactory
from dl_connector_greenplum.api.i18n.localizer import CONFIGS as BI_CONNECTOR_GREENPLUM_CONFIGS
from dl_connector_postgresql.api.i18n.localizer import CONFIGS as BI_CONNECTOR_POSTGRESQL_CONFIGS


class TestGreenplumConnectionForm(ConnectionFormTestBase):
CONN_FORM_FACTORY_CLS = GreenplumConnectionFormFactory
TRANSLATION_CONFIGS = BI_API_CONNECTOR_CONFIGS + BI_CONNECTOR_GREENPLUM_CONFIGS
TRANSLATION_CONFIGS = BI_API_CONNECTOR_CONFIGS + BI_CONNECTOR_GREENPLUM_CONFIGS + BI_CONNECTOR_POSTGRESQL_CONFIGS
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
Sequence,
)

import attr

from dl_api_commons.base_models import TenantDef
from dl_api_connector.form_config.models import rows as C
from dl_api_connector.form_config.models.api_schema import (
FormActionApiSchema,
FormApiSchema,
Expand All @@ -21,10 +24,11 @@
CommonFieldName,
FormFieldName,
)
import dl_api_connector.form_config.models.rows as C
from dl_api_connector.form_config.models.rows.base import FormRow
from dl_api_connector.form_config.models.shortcuts.rows import RowConstructor
from dl_api_connector.i18n.localizer import Translatable
from dl_configs.connectors_settings import ConnectorSettingsBase
from dl_i18n.localizer_base import Localizer

from dl_connector_postgresql.api.connection_info import PostgreSQLConnectionInfoProvider
from dl_connector_postgresql.api.i18n.localizer import Translatable
Expand All @@ -36,6 +40,40 @@ class PostgreSQLFieldName(FormFieldName):
enforce_collate = "enforce_collate"


@attr.s
class PostgresRowConstructor:
_localizer: Localizer = attr.ib()

def enforce_collate_row(self) -> C.CustomizableRow:
return C.CustomizableRow(
items=[
C.LabelRowItem(
text=self._localizer.translate(Translatable("field_enforce-collate")),
display_conditions={CommonFieldName.advanced_settings: "opened"},
),
C.RadioButtonRowItem(
name=PostgreSQLFieldName.enforce_collate,
options=[
C.SelectableOption(
text=self._localizer.translate(Translatable("value_enforce-collate-auto")),
value=PGEnforceCollateMode.auto.value,
),
C.SelectableOption(
text=self._localizer.translate(Translatable("value_enforce-collate-off")),
value=PGEnforceCollateMode.off.value,
),
C.SelectableOption(
text=self._localizer.translate(Translatable("value_enforce-collate-on")),
value=PGEnforceCollateMode.on.value,
),
],
default_value=PGEnforceCollateMode.auto.value,
display_conditions={CommonFieldName.advanced_settings: "opened"},
),
]
)


class PostgreSQLConnectionFormFactory(ConnectionFormFactory):
def _get_base_edit_api_schema(self) -> FormActionApiSchema:
return FormActionApiSchema(
Expand Down Expand Up @@ -86,6 +124,7 @@ def _get_base_form_config(
edit_api_schema: FormActionApiSchema,
check_api_schema: FormActionApiSchema,
rc: RowConstructor,
postgres_rc: PostgresRowConstructor,
) -> ConnectionForm:
return ConnectionForm(
title=PostgreSQLConnectionInfoProvider.get_title(self._localizer),
Expand All @@ -99,33 +138,7 @@ def _get_base_form_config(
C.CacheTTLRow(name=CommonFieldName.cache_ttl_sec),
rc.raw_sql_level_row(),
rc.collapse_advanced_settings_row(),
C.CustomizableRow(
items=[
C.LabelRowItem(
text=self._localizer.translate(Translatable("field_enforce-collate")),
display_conditions={CommonFieldName.advanced_settings: "opened"},
),
C.RadioButtonRowItem(
name=PostgreSQLFieldName.enforce_collate,
options=[
C.SelectableOption(
text=self._localizer.translate(Translatable("value_enforce-collate-auto")),
value=PGEnforceCollateMode.auto.value,
),
C.SelectableOption(
text=self._localizer.translate(Translatable("value_enforce-collate-off")),
value=PGEnforceCollateMode.off.value,
),
C.SelectableOption(
text=self._localizer.translate(Translatable("value_enforce-collate-on")),
value=PGEnforceCollateMode.on.value,
),
],
default_value=PGEnforceCollateMode.auto.value,
display_conditions={CommonFieldName.advanced_settings: "opened"},
),
]
),
postgres_rc.enforce_collate_row(),
*rc.ssl_rows(
enabled_name=CommonFieldName.ssl_enable,
enabled_help_text=self._localizer.translate(Translatable("label_postgres-ssl-enabled-tooltip")),
Expand All @@ -147,6 +160,7 @@ def get_form_config(
tenant: Optional[TenantDef],
) -> ConnectionForm:
rc = RowConstructor(localizer=self._localizer)
postgres_rc = PostgresRowConstructor(localizer=self._localizer)

host_section = [rc.host_row()]
username_section = [rc.username_row()]
Expand All @@ -164,4 +178,5 @@ def get_form_config(
edit_api_schema=edit_api_schema,
check_api_schema=check_api_schema,
rc=rc,
postgres_rc=postgres_rc,
)
Loading