Skip to content

Commit

Permalink
fix plugin name
Browse files Browse the repository at this point in the history
  • Loading branch information
TakoB222 committed Oct 17, 2023
1 parent 3c60db0 commit a6b2d07
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ options:
default: false
type: boolean
description: Enable tsm_system_time extension
plugin_uuid-ossp_enable:
plugin_uuid_ossp_enable:
default: false
type: boolean
description: Enable uuid_ossp extension
Expand Down
12 changes: 5 additions & 7 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,15 +922,13 @@ def enable_disable_extensions(self, database: str = None) -> None:
Args:
database: optional database where to enable/disable the extension.
"""
for config, enable in self.model.config.items():
# Filter config option not related to plugins.
if not config.startswith("plugin_"):
continue
for plugin in self.config.plugin_keys():
enable = self.config[plugin]

# Enable or disable the plugin/extension.
extension = "_".join(config.split("_")[1:-1])
if "-" in extension:
extension = '"{}"'.format(extension)
extension = "_".join(plugin.split("_")[1:-1])
if extension == "uuid_ossp":
extension = '"uuid-ossp"'

try:
self.postgresql.enable_disable_extension(extension, enable, database)
Expand Down
23 changes: 23 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ class CharmConfig(BaseConfigModel):
plugin_pg_trgm_enable: bool
plugin_plpython3u_enable: bool
plugin_unaccent_enable: bool
plugin_bloom_enable: bool
plugin_btree_gin_enable: bool
plugin_btree_gist_enable: bool
plugin_cube_enable: bool
plugin_dict_int_enable: bool
plugin_dict_xsyn_enable: bool
plugin_earthdistance_enable: bool
plugin_fuzzystrmatch_enable: bool
plugin_intarray_enable: bool
plugin_isn_enable: bool
plugin_lo_enable: bool
plugin_ltree_enable: bool
plugin_old_snapshot_enable: bool
plugin_pg_freespacemap_enable: bool
plugin_pgrowlocks_enable: bool
plugin_pgstattuple_enable: bool
plugin_pg_visibility_enable: bool
plugin_seg_enable: bool
plugin_tablefunc_enable: bool
plugin_tcn_enable: bool
plugin_tsm_system_rows_enable: bool
plugin_tsm_system_time_enable: bool
plugin_uuid_ossp_enable: bool

@classmethod
def keys(cls) -> list[str]:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async def test_plugins(ops_test: OpsTest) -> None:
"plugin_tcn_enable": "True",
"plugin_tsm_system_rows_enable": "True",
"plugin_tsm_system_time_enable": "True",
"plugin_uuid-ossp_enable": "True",
"plugin_uuid_ossp_enable": "True",
}
await ops_test.model.applications[DATABASE_APP_NAME].set_config(config)
await ops_test.model.wait_for_idle(apps=[DATABASE_APP_NAME], status="active")
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def test_enable_disable_extensions(self):
plugin_tsm_system_time_enable:
default: false
type: boolean
plugin_uuid-ossp_enable:
plugin_uuid_ossp_enable:
default: false
type: boolean
profile:
Expand Down

0 comments on commit a6b2d07

Please sign in to comment.