kaqing 2.0.42__tar.gz → 2.0.43__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kaqing-2.0.42 → kaqing-2.0.43}/PKG-INFO +1 -1
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/cd.py +1 -1
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/cql_utils.py +1 -1
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/ls.py +1 -3
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/postgres/postgres.py +8 -7
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/postgres/postgres_session.py +0 -8
- kaqing-2.0.42/adam/commands/postgres/pg_utils.py → kaqing-2.0.43/adam/commands/postgres/postgres_utils.py +5 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/preview_table.py +1 -3
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_session.py +1 -1
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/statefulsets.py +1 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/repl.py +8 -4
- kaqing-2.0.43/adam/repl_completer.py +74 -0
- kaqing-2.0.43/adam/version.py +5 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/kaqing.egg-info/PKG-INFO +1 -1
- {kaqing-2.0.42 → kaqing-2.0.43}/kaqing.egg-info/SOURCES.txt +2 -1
- {kaqing-2.0.42 → kaqing-2.0.43}/setup.py +1 -1
- kaqing-2.0.42/adam/version.py +0 -5
- {kaqing-2.0.42 → kaqing-2.0.43}/README +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/app_session.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/apps.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/batch.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/check.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/check_context.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/check_result.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/check_utils.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/compactionstats.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/cpu.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/disk.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/gossip.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/issue.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/memory.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/checks/status.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/cli.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/cli_group.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/column.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/columns.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/compactions.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/cpu.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/dir_data.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/dir_snapshots.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/gossip.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/host_id.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/memory.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/node_address.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/node_load.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/node_owns.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/node_status.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/node_tokens.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/node_utils.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/pod_name.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/volume_cassandra.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/columns/volume_root.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/alter_tables.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/app.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/app_ping.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/bash.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/check.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/cli_commands.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/command.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/command_helpers.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/commands_utils.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/cp.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/cqlsh.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/code_start.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/code_stop.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/code_utils.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/deploy.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/deploy_frontend.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/deploy_pg_agent.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/deploy_pod.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/deploy_utils.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/undeploy.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/undeploy_frontend.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/undeploy_pg_agent.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/deploy/undeploy_pod.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/describe/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/describe/describe.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/describe/describe_keyspace.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/describe/describe_keyspaces.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/describe/describe_table.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/describe/describe_tables.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/devices.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/exit.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/help.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/issues.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/login.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/logs.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/medusa/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/medusa/medusa.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/medusa/medusa_backup.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/medusa/medusa_restore.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/medusa/medusa_show_backupjobs.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/medusa/medusa_show_restorejobs.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/nodetool.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/nodetool_commands.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/param_get.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/param_set.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/postgres/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/postgres/postgres_ls.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/postgres/postgres_preview.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/pwd.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_forward.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_forward_stop.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_restart.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_run_abort.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_runs.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_runs_abort.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_schedule_activate.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_schedule_start.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_schedule_stop.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_schedules.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/reaper/reaper_status.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/repair/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/repair/repair.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/repair/repair_log.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/repair/repair_run.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/repair/repair_scan.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/repair/repair_stop.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/report.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/restart.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/rollout.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/shell.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_adam.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_app_actions.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_app_id.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_app_queues.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_cassandra_status.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_cassandra_version.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_commands.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_login.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_params.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_processes.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_repairs.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/show/show_storage.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/commands/watch.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/config.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/embedded_apps.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/embedded_params.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/cassandra_clusters.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/cassandra_nodes.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/config_maps.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/custom_resources.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/deployment.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/ingresses.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/jobs.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/kube_context.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/pods.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/secrets.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/service_accounts.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/services.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/k8s_utils/volumes.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/log.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/pod_exec_result.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/repl_commands.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/repl_session.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/repl_state.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/__init__.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/authenticator.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/authn_ad.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/authn_okta.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/cred_cache.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/id_token.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/idp.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/idp_login.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/idp_session.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/sso/sso_config.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/adam/utils.py +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/kaqing.egg-info/dependency_links.txt +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/kaqing.egg-info/entry_points.txt +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/kaqing.egg-info/top_level.txt +0 -0
- {kaqing-2.0.42 → kaqing-2.0.43}/setup.cfg +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
from adam.commands.command import Command
|
2
|
-
from adam.commands.postgres.
|
2
|
+
from adam.commands.postgres.postgres_utils import pg_database_names
|
3
3
|
from adam.commands.postgres.postgres_session import PostgresSession
|
4
4
|
from adam.k8s_utils.cassandra_clusters import CassandraClusters
|
5
5
|
from adam.k8s_utils.kube_context import KubeContext
|
@@ -11,7 +11,7 @@ from adam.utils import log2
|
|
11
11
|
|
12
12
|
@functools.lru_cache()
|
13
13
|
def keyspaces(state: ReplState, on_any=False):
|
14
|
-
Config().wait_log(
|
14
|
+
Config().wait_log('Inspecting Cassandra Keyspaces...')
|
15
15
|
|
16
16
|
r: list[PodExecResult] = run_cql(state, 'describe keyspaces', show_out=False, on_any=on_any)
|
17
17
|
if not r:
|
@@ -1,16 +1,14 @@
|
|
1
1
|
import copy
|
2
|
-
import re
|
3
2
|
|
4
3
|
from adam.commands.command import Command
|
5
4
|
from adam.commands.commands_utils import show_pods, show_rollout
|
6
5
|
from adam.commands.cqlsh import Cqlsh
|
7
|
-
from adam.commands.postgres.
|
6
|
+
from adam.commands.postgres.postgres_utils import pg_database_names, pg_table_names
|
8
7
|
from adam.commands.postgres.postgres_session import PostgresSession
|
9
8
|
from adam.config import Config
|
10
9
|
from adam.k8s_utils.custom_resources import CustomResources
|
11
10
|
from adam.k8s_utils.ingresses import Ingresses
|
12
11
|
from adam.k8s_utils.kube_context import KubeContext
|
13
|
-
from adam.k8s_utils.services import Services
|
14
12
|
from adam.k8s_utils.statefulsets import StatefulSets
|
15
13
|
from adam.pod_exec_result import PodExecResult
|
16
14
|
from adam.repl_state import ReplState
|
@@ -2,7 +2,7 @@ import functools
|
|
2
2
|
import click
|
3
3
|
|
4
4
|
from adam.commands.command import Command
|
5
|
-
from adam.commands.postgres.
|
5
|
+
from adam.commands.postgres.postgres_utils import pg_table_names
|
6
6
|
from .postgres_ls import PostgresLs
|
7
7
|
from .postgres_preview import PostgresPreview
|
8
8
|
from .postgres_session import PostgresSession
|
@@ -68,19 +68,20 @@ class Postgres(Command):
|
|
68
68
|
leaf = {}
|
69
69
|
session = PostgresSession(state.namespace, state.pg_path)
|
70
70
|
if session.db:
|
71
|
-
if
|
71
|
+
if pg_table_names(state.namespace, state.pg_path):
|
72
|
+
ts = f'<pg_tables:{state.namespace}:{state.pg_path}>'
|
72
73
|
leaf = {
|
73
74
|
'\h': None,
|
74
75
|
'\d': None,
|
75
76
|
'\dt': None,
|
76
77
|
'\du': None,
|
77
|
-
'delete': {'from': {
|
78
|
-
'insert': {'into': {
|
79
|
-
'select': {'*': {'from': {
|
78
|
+
'delete': {'from': {ts: {'where': {'id': {'=': None}}}}},
|
79
|
+
'insert': {'into': {ts: {'values': None}}},
|
80
|
+
'select': {'*': {'from': {ts: {
|
80
81
|
'limit': {'1': None},
|
81
82
|
'where': {'id': {'=': None}}
|
82
|
-
}
|
83
|
-
'update': {
|
83
|
+
}}}},
|
84
|
+
'update': {ts: {'set': None}},
|
84
85
|
}
|
85
86
|
elif state.pg_path:
|
86
87
|
leaf = {
|
@@ -25,13 +25,6 @@ class PostgresSession:
|
|
25
25
|
if len(tks) > 1:
|
26
26
|
self.db = tks[1]
|
27
27
|
|
28
|
-
# works only for databases()
|
29
|
-
def __eq__(self, other: 'PostgresSession'):
|
30
|
-
return self.host == other.host
|
31
|
-
|
32
|
-
def __hash__(self):
|
33
|
-
return hash(self.host)
|
34
|
-
|
35
28
|
def find_namespace(self, arg: str):
|
36
29
|
if arg:
|
37
30
|
tks = arg.split('@')
|
@@ -82,7 +75,6 @@ class PostgresSession:
|
|
82
75
|
|
83
76
|
return [s for s in ss if not excludes(s)]
|
84
77
|
|
85
|
-
@functools.lru_cache()
|
86
78
|
def databases(self):
|
87
79
|
dbs = []
|
88
80
|
# List of databases
|
@@ -1,13 +1,18 @@
|
|
1
1
|
import functools
|
2
2
|
|
3
3
|
from adam.commands.postgres.postgres_session import PostgresSession
|
4
|
+
from adam.config import Config
|
4
5
|
|
6
|
+
@functools.lru_cache()
|
5
7
|
def pg_database_names(ns: str, pg_path: str):
|
8
|
+
Config().wait_log('Inspecting Postgres Databases...')
|
9
|
+
|
6
10
|
pg = PostgresSession(ns, pg_path)
|
7
11
|
return [db['name'] for db in pg.databases() if db['owner'] == PostgresSession.default_owner()]
|
8
12
|
|
9
13
|
@functools.lru_cache()
|
10
14
|
def pg_table_names(ns: str, pg_path: str):
|
15
|
+
Config().wait_log('Inspecting Postgres Database...')
|
11
16
|
return [table['name'] for table in pg_tables(ns, pg_path) if table['schema'] == PostgresSession.default_schema()]
|
12
17
|
|
13
18
|
def pg_tables(ns: str, pg_path: str):
|
@@ -2,7 +2,6 @@ import functools
|
|
2
2
|
|
3
3
|
from adam.commands.command import Command
|
4
4
|
from adam.commands.cql_utils import run_cql, tables
|
5
|
-
from adam.commands.postgres.pg_utils import pg_table_names
|
6
5
|
from adam.commands.postgres.postgres_session import PostgresSession
|
7
6
|
from adam.config import Config
|
8
7
|
from adam.repl_state import ReplState, RequiredState
|
@@ -72,8 +71,7 @@ class PreviewTable(Command):
|
|
72
71
|
|
73
72
|
def completion(self, state: ReplState):
|
74
73
|
if state.device == ReplState.P:
|
75
|
-
|
76
|
-
return {PreviewTable.COMMAND: {table: None for table in tables}}
|
74
|
+
return {PreviewTable.COMMAND: {f'<pg_tables:{state.namespace}:{state.pg_path}>': None}}
|
77
75
|
elif state.sts:
|
78
76
|
tables = PreviewTable.cql_tables(state)
|
79
77
|
return {PreviewTable.COMMAND: {f'{k}.{t}': None for k, ts in tables.items() for t in ts}}
|
@@ -149,7 +149,7 @@ class ReaperSession:
|
|
149
149
|
return ReaperSession.schedules_ids_by_cluster[state.sts]
|
150
150
|
|
151
151
|
if reaper := ReaperSession.create(state):
|
152
|
-
Config().wait_log(
|
152
|
+
Config().wait_log('Inspecting Cassandra Reaper...')
|
153
153
|
|
154
154
|
schedules = reaper.schedule_ids(state, show_output = False)
|
155
155
|
ReaperSession.schedules_ids_by_cluster[state.sts] = schedules
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import json
|
1
2
|
import os
|
2
3
|
import re
|
3
4
|
import time
|
@@ -16,6 +17,7 @@ from adam.k8s_utils.kube_context import KubeContext
|
|
16
17
|
from adam.k8s_utils.statefulsets import StatefulSets
|
17
18
|
from adam.log import Log
|
18
19
|
from adam.repl_commands import ReplCommands
|
20
|
+
from adam.repl_completer import CompleterContext, ReplCompleter
|
19
21
|
from adam.repl_session import ReplSession
|
20
22
|
from adam.repl_state import ReplState
|
21
23
|
from adam.utils import deep_merge_dicts, deep_sort_dict, lines_to_tabular, log2
|
@@ -92,7 +94,7 @@ def enter_repl(state: ReplState):
|
|
92
94
|
sorted_cmds = sorted(cmd_list, key=lambda cmd: cmd.command())
|
93
95
|
while True:
|
94
96
|
try:
|
95
|
-
completer =
|
97
|
+
completer = ReplCompleter.from_nested_dict({})
|
96
98
|
if not state.bash_session:
|
97
99
|
completions = {}
|
98
100
|
# app commands are available only on a: drive
|
@@ -105,9 +107,10 @@ def enter_repl(state: ReplState):
|
|
105
107
|
completions = deep_sort_dict(deep_merge_dicts(completions, cmd.completion(state)))
|
106
108
|
finally:
|
107
109
|
if Config().get('debugs.timings', False):
|
108
|
-
|
110
|
+
log2(f'Timing auto-completion-calc {cmd.command()}: {time.time() - s1:.2f}')
|
109
111
|
|
110
|
-
|
112
|
+
# print(json.dumps(completions, indent=4))
|
113
|
+
completer = ReplCompleter.from_nested_dict(completions)
|
111
114
|
|
112
115
|
cmd = session.prompt(prompt_msg(), completer=completer, key_bindings=kb)
|
113
116
|
s0 = time.time()
|
@@ -151,9 +154,10 @@ def enter_repl(state: ReplState):
|
|
151
154
|
log2(e)
|
152
155
|
Config().debug(traceback.format_exc())
|
153
156
|
finally:
|
157
|
+
CompleterContext().reset()
|
154
158
|
Config().clear_wait_log_flag()
|
155
159
|
if Config().get('debugs.timings', False) and 'cmd' in locals() and 's0' in locals():
|
156
|
-
|
160
|
+
log2(f'Timing command {cmd}: {time.time() - s0:.2f}')
|
157
161
|
|
158
162
|
@cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterCommandHelper, help="Enter interactive shell.")
|
159
163
|
@click.option('--kubeconfig', '-k', required=False, metavar='path', help='path to kubeconfig file')
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import re
|
2
|
+
|
3
|
+
from typing import Iterable
|
4
|
+
from prompt_toolkit.completion import CompleteEvent, Completion, NestedCompleter, WordCompleter
|
5
|
+
from prompt_toolkit.document import Document
|
6
|
+
|
7
|
+
from adam.commands.postgres.postgres_utils import pg_table_names
|
8
|
+
|
9
|
+
class CompleterContext:
|
10
|
+
# the singleton pattern
|
11
|
+
def __new__(cls, *args, **kwargs):
|
12
|
+
if not hasattr(cls, 'instance'): cls.instance = super(CompleterContext, cls).__new__(cls)
|
13
|
+
|
14
|
+
return cls.instance
|
15
|
+
|
16
|
+
def __init__(self):
|
17
|
+
if not hasattr(self, 'table_resolver'):
|
18
|
+
self.table_resolver = None
|
19
|
+
self.tables = []
|
20
|
+
|
21
|
+
def produce(self, word: str):
|
22
|
+
if match := re.match(r'^<pg_tables:(.*?):(.*?)>$', word):
|
23
|
+
self.table_resolver = word
|
24
|
+
self.tables = pg_table_names(match.group(1), match.group(2))
|
25
|
+
|
26
|
+
return self.tables
|
27
|
+
|
28
|
+
return None
|
29
|
+
|
30
|
+
def is_table(self, word: str):
|
31
|
+
if word in self.tables and self.table_resolver:
|
32
|
+
return self.table_resolver
|
33
|
+
|
34
|
+
return None
|
35
|
+
|
36
|
+
def reset(self):
|
37
|
+
self.table_resolver = None
|
38
|
+
self.tables = []
|
39
|
+
|
40
|
+
|
41
|
+
class ReplCompleter(NestedCompleter):
|
42
|
+
def get_completions(
|
43
|
+
self, document: Document, complete_event: CompleteEvent
|
44
|
+
) -> Iterable[Completion]:
|
45
|
+
text = document.text_before_cursor.lstrip()
|
46
|
+
stripped_len = len(document.text_before_cursor) - len(text)
|
47
|
+
|
48
|
+
if " " in text:
|
49
|
+
first_term = text.split()[0]
|
50
|
+
completer = self.options.get(first_term)
|
51
|
+
if table_resolver := CompleterContext().is_table(first_term):
|
52
|
+
completer = self.options.get(table_resolver)
|
53
|
+
|
54
|
+
if completer is not None:
|
55
|
+
remaining_text = text[len(first_term) :].lstrip()
|
56
|
+
move_cursor = len(text) - len(remaining_text) + stripped_len
|
57
|
+
|
58
|
+
new_document = Document(
|
59
|
+
remaining_text,
|
60
|
+
cursor_position=document.cursor_position - move_cursor,
|
61
|
+
)
|
62
|
+
|
63
|
+
for c in completer.get_completions(new_document, complete_event):
|
64
|
+
if words := CompleterContext().produce(c.text):
|
65
|
+
for w in words:
|
66
|
+
yield Completion(w)
|
67
|
+
else:
|
68
|
+
yield c
|
69
|
+
else:
|
70
|
+
completer = WordCompleter(
|
71
|
+
list(self.options.keys()), ignore_case=self.ignore_case
|
72
|
+
)
|
73
|
+
for c in completer.get_completions(document, complete_event):
|
74
|
+
yield c
|
@@ -13,6 +13,7 @@ adam/log.py
|
|
13
13
|
adam/pod_exec_result.py
|
14
14
|
adam/repl.py
|
15
15
|
adam/repl_commands.py
|
16
|
+
adam/repl_completer.py
|
16
17
|
adam/repl_session.py
|
17
18
|
adam/repl_state.py
|
18
19
|
adam/utils.py
|
@@ -106,11 +107,11 @@ adam/commands/medusa/medusa_restore.py
|
|
106
107
|
adam/commands/medusa/medusa_show_backupjobs.py
|
107
108
|
adam/commands/medusa/medusa_show_restorejobs.py
|
108
109
|
adam/commands/postgres/__init__.py
|
109
|
-
adam/commands/postgres/pg_utils.py
|
110
110
|
adam/commands/postgres/postgres.py
|
111
111
|
adam/commands/postgres/postgres_ls.py
|
112
112
|
adam/commands/postgres/postgres_preview.py
|
113
113
|
adam/commands/postgres/postgres_session.py
|
114
|
+
adam/commands/postgres/postgres_utils.py
|
114
115
|
adam/commands/reaper/__init__.py
|
115
116
|
adam/commands/reaper/reaper.py
|
116
117
|
adam/commands/reaper/reaper_forward.py
|
kaqing-2.0.42/adam/version.py
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|