kaqing 1.77.0__py3-none-any.whl → 2.0.171__py3-none-any.whl
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.
- adam/__init__.py +1 -0
- adam/app_session.py +182 -0
- {walker → adam}/apps.py +8 -24
- {walker → adam}/batch.py +54 -97
- {walker → adam}/checks/check.py +3 -3
- {walker → adam}/checks/check_result.py +1 -1
- adam/checks/check_utils.py +65 -0
- {walker → adam}/checks/compactionstats.py +6 -6
- {walker → adam}/checks/cpu.py +14 -8
- adam/checks/cpu_metrics.py +52 -0
- {walker → adam}/checks/disk.py +6 -6
- {walker → adam}/checks/gossip.py +5 -5
- {walker → adam}/checks/memory.py +7 -7
- {walker → adam}/checks/status.py +5 -5
- {walker → adam}/cli.py +3 -3
- {walker → adam}/columns/column.py +1 -1
- adam/columns/columns.py +45 -0
- {walker → adam}/columns/compactions.py +5 -5
- {walker → adam}/columns/cpu.py +6 -4
- adam/columns/cpu_metrics.py +22 -0
- {walker → adam}/columns/dir_data.py +3 -3
- {walker → adam}/columns/dir_snapshots.py +3 -3
- {walker → adam}/columns/gossip.py +5 -5
- {walker → adam}/columns/host_id.py +3 -3
- {walker → adam}/columns/memory.py +3 -3
- {walker → adam}/columns/node_address.py +3 -3
- {walker → adam}/columns/node_load.py +3 -3
- {walker → adam}/columns/node_owns.py +3 -3
- {walker → adam}/columns/node_status.py +3 -3
- {walker → adam}/columns/node_tokens.py +3 -3
- {walker → adam}/columns/node_utils.py +2 -2
- {walker → adam}/columns/pod_name.py +2 -2
- {walker → adam}/columns/volume_cassandra.py +4 -4
- {walker → adam}/columns/volume_root.py +3 -3
- adam/commands/__init__.py +15 -0
- adam/commands/alter_tables.py +81 -0
- adam/commands/app_cmd.py +38 -0
- {walker → adam}/commands/app_ping.py +10 -16
- adam/commands/audit/audit.py +84 -0
- adam/commands/audit/audit_repair_tables.py +74 -0
- adam/commands/audit/audit_run.py +50 -0
- adam/commands/audit/show_last10.py +48 -0
- adam/commands/audit/show_slow10.py +47 -0
- adam/commands/audit/show_top10.py +45 -0
- adam/commands/audit/utils_show_top10.py +59 -0
- adam/commands/bash/__init__.py +5 -0
- adam/commands/bash/bash.py +36 -0
- adam/commands/bash/bash_completer.py +93 -0
- adam/commands/bash/utils_bash.py +16 -0
- adam/commands/cat.py +50 -0
- adam/commands/cd.py +43 -0
- adam/commands/check.py +73 -0
- {walker → adam}/commands/cli_commands.py +7 -8
- adam/commands/code.py +57 -0
- adam/commands/command.py +190 -0
- {walker → adam}/commands/command_helpers.py +1 -1
- {walker → adam}/commands/commands_utils.py +15 -25
- adam/commands/cp.py +89 -0
- adam/commands/cql/cql_completions.py +33 -0
- {walker/commands → adam/commands/cql}/cqlsh.py +20 -35
- adam/commands/cql/utils_cql.py +343 -0
- {walker/commands/frontend → adam/commands/deploy}/code_start.py +11 -14
- adam/commands/deploy/code_stop.py +40 -0
- {walker/commands/frontend → adam/commands/deploy}/code_utils.py +7 -9
- adam/commands/deploy/deploy.py +25 -0
- adam/commands/deploy/deploy_frontend.py +49 -0
- adam/commands/deploy/deploy_pg_agent.py +35 -0
- adam/commands/deploy/deploy_pod.py +108 -0
- adam/commands/deploy/deploy_utils.py +29 -0
- adam/commands/deploy/undeploy.py +25 -0
- adam/commands/deploy/undeploy_frontend.py +38 -0
- adam/commands/deploy/undeploy_pg_agent.py +39 -0
- adam/commands/deploy/undeploy_pod.py +48 -0
- adam/commands/devices/device.py +118 -0
- adam/commands/devices/device_app.py +173 -0
- adam/commands/devices/device_auit_log.py +49 -0
- adam/commands/devices/device_cass.py +185 -0
- adam/commands/devices/device_export.py +86 -0
- adam/commands/devices/device_postgres.py +144 -0
- adam/commands/devices/devices.py +25 -0
- {walker → adam}/commands/exit.py +3 -6
- adam/commands/export/clean_up_all_export_sessions.py +37 -0
- adam/commands/export/clean_up_export_sessions.py +51 -0
- adam/commands/export/drop_export_database.py +55 -0
- adam/commands/export/drop_export_databases.py +43 -0
- adam/commands/export/export.py +53 -0
- adam/commands/export/export_databases.py +170 -0
- adam/commands/export/export_handlers.py +71 -0
- adam/commands/export/export_select.py +81 -0
- adam/commands/export/export_select_x.py +54 -0
- adam/commands/export/export_use.py +52 -0
- adam/commands/export/exporter.py +352 -0
- adam/commands/export/import_session.py +40 -0
- adam/commands/export/importer.py +67 -0
- adam/commands/export/importer_athena.py +80 -0
- adam/commands/export/importer_sqlite.py +47 -0
- adam/commands/export/show_column_counts.py +54 -0
- adam/commands/export/show_export_databases.py +36 -0
- adam/commands/export/show_export_session.py +48 -0
- adam/commands/export/show_export_sessions.py +44 -0
- adam/commands/export/utils_export.py +314 -0
- {walker → adam}/commands/help.py +17 -12
- adam/commands/intermediate_command.py +49 -0
- adam/commands/issues.py +43 -0
- adam/commands/kubectl.py +38 -0
- adam/commands/login.py +70 -0
- {walker → adam}/commands/logs.py +8 -10
- adam/commands/ls.py +41 -0
- adam/commands/medusa/medusa.py +27 -0
- adam/commands/medusa/medusa_backup.py +57 -0
- adam/commands/medusa/medusa_restore.py +83 -0
- adam/commands/medusa/medusa_show_backupjobs.py +51 -0
- adam/commands/medusa/medusa_show_restorejobs.py +47 -0
- {walker → adam}/commands/nodetool.py +17 -21
- {walker → adam}/commands/param_get.py +15 -16
- adam/commands/param_set.py +43 -0
- adam/commands/postgres/postgres.py +104 -0
- adam/commands/postgres/postgres_context.py +274 -0
- {walker → adam}/commands/postgres/postgres_ls.py +7 -11
- {walker → adam}/commands/postgres/postgres_preview.py +8 -13
- adam/commands/postgres/psql_completions.py +10 -0
- adam/commands/postgres/utils_postgres.py +66 -0
- adam/commands/preview_table.py +37 -0
- adam/commands/pwd.py +47 -0
- adam/commands/reaper/reaper.py +35 -0
- adam/commands/reaper/reaper_forward.py +93 -0
- adam/commands/reaper/reaper_forward_session.py +6 -0
- {walker → adam}/commands/reaper/reaper_forward_stop.py +13 -19
- {walker → adam}/commands/reaper/reaper_restart.py +10 -17
- adam/commands/reaper/reaper_run_abort.py +46 -0
- adam/commands/reaper/reaper_runs.py +82 -0
- adam/commands/reaper/reaper_runs_abort.py +63 -0
- adam/commands/reaper/reaper_schedule_activate.py +45 -0
- adam/commands/reaper/reaper_schedule_start.py +45 -0
- adam/commands/reaper/reaper_schedule_stop.py +45 -0
- {walker → adam}/commands/reaper/reaper_schedules.py +6 -16
- {walker → adam}/commands/reaper/reaper_status.py +11 -19
- adam/commands/reaper/utils_reaper.py +196 -0
- adam/commands/repair/repair.py +26 -0
- {walker → adam}/commands/repair/repair_log.py +7 -10
- adam/commands/repair/repair_run.py +70 -0
- adam/commands/repair/repair_scan.py +71 -0
- {walker → adam}/commands/repair/repair_stop.py +8 -11
- adam/commands/report.py +61 -0
- adam/commands/restart.py +60 -0
- {walker → adam}/commands/rollout.py +25 -30
- adam/commands/shell.py +34 -0
- adam/commands/show/show.py +39 -0
- walker/commands/show/show_version.py → adam/commands/show/show_adam.py +14 -10
- adam/commands/show/show_app_actions.py +57 -0
- {walker → adam}/commands/show/show_app_id.py +12 -15
- {walker → adam}/commands/show/show_app_queues.py +9 -12
- adam/commands/show/show_cassandra_repairs.py +38 -0
- adam/commands/show/show_cassandra_status.py +124 -0
- {walker → adam}/commands/show/show_cassandra_version.py +6 -16
- adam/commands/show/show_commands.py +59 -0
- walker/commands/show/show_storage.py → adam/commands/show/show_host.py +11 -13
- adam/commands/show/show_login.py +62 -0
- {walker → adam}/commands/show/show_params.py +4 -4
- adam/commands/show/show_processes.py +51 -0
- adam/commands/show/show_storage.py +42 -0
- adam/commands/watch.py +82 -0
- {walker → adam}/config.py +10 -22
- {walker → adam}/embedded_apps.py +1 -1
- adam/embedded_params.py +2 -0
- adam/log.py +47 -0
- {walker → adam}/pod_exec_result.py +10 -2
- adam/repl.py +182 -0
- adam/repl_commands.py +124 -0
- adam/repl_state.py +458 -0
- adam/sql/__init__.py +0 -0
- adam/sql/sql_completer.py +120 -0
- adam/sql/sql_state_machine.py +618 -0
- adam/sql/term_completer.py +76 -0
- adam/sso/__init__.py +0 -0
- {walker → adam}/sso/authenticator.py +5 -1
- adam/sso/authn_ad.py +170 -0
- {walker → adam}/sso/authn_okta.py +39 -22
- adam/sso/cred_cache.py +60 -0
- adam/sso/id_token.py +23 -0
- adam/sso/idp.py +143 -0
- adam/sso/idp_login.py +50 -0
- adam/sso/idp_session.py +55 -0
- adam/sso/sso_config.py +63 -0
- adam/utils.py +679 -0
- adam/utils_app.py +98 -0
- adam/utils_athena.py +145 -0
- adam/utils_audits.py +106 -0
- adam/utils_issues.py +32 -0
- adam/utils_k8s/__init__.py +0 -0
- adam/utils_k8s/app_clusters.py +28 -0
- adam/utils_k8s/app_pods.py +33 -0
- adam/utils_k8s/cassandra_clusters.py +36 -0
- adam/utils_k8s/cassandra_nodes.py +33 -0
- adam/utils_k8s/config_maps.py +34 -0
- {walker/k8s_utils → adam/utils_k8s}/custom_resources.py +7 -2
- adam/utils_k8s/deployment.py +56 -0
- {walker/k8s_utils → adam/utils_k8s}/ingresses.py +3 -4
- {walker/k8s_utils → adam/utils_k8s}/jobs.py +3 -3
- adam/utils_k8s/k8s.py +87 -0
- {walker/k8s_utils → adam/utils_k8s}/kube_context.py +4 -4
- adam/utils_k8s/pods.py +290 -0
- {walker/k8s_utils → adam/utils_k8s}/secrets.py +8 -4
- adam/utils_k8s/service_accounts.py +170 -0
- {walker/k8s_utils → adam/utils_k8s}/services.py +3 -4
- {walker/k8s_utils → adam/utils_k8s}/statefulsets.py +6 -16
- {walker/k8s_utils → adam/utils_k8s}/volumes.py +10 -1
- adam/utils_net.py +24 -0
- adam/utils_repl/__init__.py +0 -0
- adam/utils_repl/automata_completer.py +48 -0
- adam/utils_repl/repl_completer.py +46 -0
- adam/utils_repl/state_machine.py +173 -0
- adam/utils_sqlite.py +109 -0
- adam/version.py +5 -0
- {kaqing-1.77.0.dist-info → kaqing-2.0.171.dist-info}/METADATA +1 -1
- kaqing-2.0.171.dist-info/RECORD +236 -0
- kaqing-2.0.171.dist-info/entry_points.txt +3 -0
- kaqing-2.0.171.dist-info/top_level.txt +1 -0
- kaqing-1.77.0.dist-info/RECORD +0 -159
- kaqing-1.77.0.dist-info/entry_points.txt +0 -3
- kaqing-1.77.0.dist-info/top_level.txt +0 -1
- walker/__init__.py +0 -3
- walker/app_session.py +0 -168
- walker/checks/check_utils.py +0 -97
- walker/columns/columns.py +0 -43
- walker/commands/add_user.py +0 -68
- walker/commands/app.py +0 -67
- walker/commands/bash.py +0 -87
- walker/commands/cd.py +0 -115
- walker/commands/check.py +0 -68
- walker/commands/command.py +0 -104
- walker/commands/cp.py +0 -95
- walker/commands/cql_utils.py +0 -53
- walker/commands/devices.py +0 -89
- walker/commands/frontend/code_stop.py +0 -57
- walker/commands/frontend/setup.py +0 -60
- walker/commands/frontend/setup_frontend.py +0 -58
- walker/commands/frontend/teardown.py +0 -61
- walker/commands/frontend/teardown_frontend.py +0 -42
- walker/commands/issues.py +0 -69
- walker/commands/login.py +0 -72
- walker/commands/ls.py +0 -145
- walker/commands/medusa/medusa.py +0 -69
- walker/commands/medusa/medusa_backup.py +0 -61
- walker/commands/medusa/medusa_restore.py +0 -86
- walker/commands/medusa/medusa_show_backupjobs.py +0 -52
- walker/commands/medusa/medusa_show_restorejobs.py +0 -52
- walker/commands/param_set.py +0 -44
- walker/commands/postgres/postgres.py +0 -113
- walker/commands/postgres/postgres_session.py +0 -225
- walker/commands/preview_table.py +0 -98
- walker/commands/processes.py +0 -53
- walker/commands/pwd.py +0 -64
- walker/commands/reaper/reaper.py +0 -78
- walker/commands/reaper/reaper_forward.py +0 -100
- walker/commands/reaper/reaper_run_abort.py +0 -65
- walker/commands/reaper/reaper_runs.py +0 -97
- walker/commands/reaper/reaper_runs_abort.py +0 -83
- walker/commands/reaper/reaper_schedule_activate.py +0 -64
- walker/commands/reaper/reaper_schedule_start.py +0 -64
- walker/commands/reaper/reaper_schedule_stop.py +0 -64
- walker/commands/reaper/reaper_session.py +0 -159
- walker/commands/repair/repair.py +0 -68
- walker/commands/repair/repair_run.py +0 -72
- walker/commands/repair/repair_scan.py +0 -79
- walker/commands/report.py +0 -57
- walker/commands/restart.py +0 -61
- walker/commands/show/show.py +0 -72
- walker/commands/show/show_app_actions.py +0 -53
- walker/commands/show/show_cassandra_status.py +0 -35
- walker/commands/show/show_commands.py +0 -58
- walker/commands/show/show_processes.py +0 -35
- walker/commands/show/show_repairs.py +0 -47
- walker/commands/status.py +0 -128
- walker/commands/storage.py +0 -52
- walker/commands/user_entry.py +0 -69
- walker/commands/watch.py +0 -85
- walker/embedded_params.py +0 -2
- walker/k8s_utils/cassandra_clusters.py +0 -48
- walker/k8s_utils/cassandra_nodes.py +0 -26
- walker/k8s_utils/pods.py +0 -211
- walker/repl.py +0 -165
- walker/repl_commands.py +0 -58
- walker/repl_state.py +0 -211
- walker/sso/authn_ad.py +0 -94
- walker/sso/idp.py +0 -150
- walker/sso/idp_login.py +0 -29
- walker/sso/sso_config.py +0 -45
- walker/utils.py +0 -194
- walker/version.py +0 -5
- {walker → adam}/checks/__init__.py +0 -0
- {walker → adam}/checks/check_context.py +0 -0
- {walker → adam}/checks/issue.py +0 -0
- {walker → adam}/cli_group.py +0 -0
- {walker → adam}/columns/__init__.py +0 -0
- {walker/commands → adam/commands/audit}/__init__.py +0 -0
- {walker/commands/frontend → adam/commands/cql}/__init__.py +0 -0
- {walker/commands/medusa → adam/commands/deploy}/__init__.py +0 -0
- {walker/commands/postgres → adam/commands/devices}/__init__.py +0 -0
- {walker/commands/reaper → adam/commands/export}/__init__.py +0 -0
- {walker/commands/repair → adam/commands/medusa}/__init__.py +0 -0
- {walker → adam}/commands/nodetool_commands.py +0 -0
- {walker/commands/show → adam/commands/postgres}/__init__.py +0 -0
- {walker/k8s_utils → adam/commands/reaper}/__init__.py +0 -0
- {walker/sso → adam/commands/repair}/__init__.py +0 -0
- /walker/medusa_show_restorejobs.py → /adam/commands/show/__init__.py +0 -0
- {walker → adam}/repl_session.py +0 -0
- {kaqing-1.77.0.dist-info → kaqing-2.0.171.dist-info}/WHEEL +0 -0
walker/commands/ls.py
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import copy
|
|
2
|
-
import re
|
|
3
|
-
|
|
4
|
-
from walker.commands.command import Command
|
|
5
|
-
from walker.commands.commands_utils import show_pods, show_rollout
|
|
6
|
-
from walker.commands.cqlsh import Cqlsh
|
|
7
|
-
from walker.commands.postgres.postgres_session import PostgresSession
|
|
8
|
-
from walker.config import Config
|
|
9
|
-
from walker.k8s_utils.custom_resources import CustomResources
|
|
10
|
-
from walker.k8s_utils.ingresses import Ingresses
|
|
11
|
-
from walker.k8s_utils.kube_context import KubeContext
|
|
12
|
-
from walker.k8s_utils.services import Services
|
|
13
|
-
from walker.k8s_utils.statefulsets import StatefulSets
|
|
14
|
-
from walker.pod_exec_result import PodExecResult
|
|
15
|
-
from walker.repl_state import ReplState
|
|
16
|
-
from walker.utils import lines_to_tabular, log, log2
|
|
17
|
-
from walker.apps import Apps
|
|
18
|
-
|
|
19
|
-
class Ls(Command):
|
|
20
|
-
COMMAND = 'ls'
|
|
21
|
-
|
|
22
|
-
# the singleton pattern
|
|
23
|
-
def __new__(cls, *args, **kwargs):
|
|
24
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Ls, cls).__new__(cls)
|
|
25
|
-
|
|
26
|
-
return cls.instance
|
|
27
|
-
|
|
28
|
-
def __init__(self, successor: Command=None):
|
|
29
|
-
super().__init__(successor)
|
|
30
|
-
|
|
31
|
-
def command(self):
|
|
32
|
-
return Ls.COMMAND
|
|
33
|
-
|
|
34
|
-
def run(self, cmd: str, state: ReplState):
|
|
35
|
-
if not(args := self.args(cmd)):
|
|
36
|
-
return super().run(cmd, state)
|
|
37
|
-
|
|
38
|
-
state, args = self.apply_state(args, state)
|
|
39
|
-
|
|
40
|
-
if len(args) > 0:
|
|
41
|
-
arg = args[0]
|
|
42
|
-
if arg in ['p:', 'c:'] and arg != f'{state.device}:':
|
|
43
|
-
state = copy.copy(state)
|
|
44
|
-
state.device = arg.replace(':', '')
|
|
45
|
-
|
|
46
|
-
if state.device == ReplState.P:
|
|
47
|
-
if state.pg_path:
|
|
48
|
-
pg = PostgresSession(state.namespace, state.pg_path)
|
|
49
|
-
if pg.db:
|
|
50
|
-
self.show_pg_tables(pg)
|
|
51
|
-
else:
|
|
52
|
-
self.show_pg_databases(pg)
|
|
53
|
-
else:
|
|
54
|
-
self.show_pg_hosts(state)
|
|
55
|
-
elif state.device == ReplState.A:
|
|
56
|
-
if state.app_env:
|
|
57
|
-
def line(n: str, ns: str):
|
|
58
|
-
host = Ingresses.get_host(Config().get('app.login.ingress', '{app_id}-k8singr-appleader-001').replace('{app_id}', f'{ns}-{n}'), ns)
|
|
59
|
-
if not host:
|
|
60
|
-
return None
|
|
61
|
-
|
|
62
|
-
endpoint = Config().get('app.login.url', 'https://{host}/{env}/{app}').replace('{host}', host).replace('{env}', state.app_env).replace('{app}', 'c3')
|
|
63
|
-
if not endpoint:
|
|
64
|
-
return None
|
|
65
|
-
|
|
66
|
-
return f"{n.split('-')[1]},{Ingresses.get_host(f'{ns}-{n}-k8singr-appleader-001', ns)},{endpoint}"
|
|
67
|
-
|
|
68
|
-
svcs = [l for l in [line(n, ns) for n, ns in Apps.apps(state.app_env)] if l]
|
|
69
|
-
|
|
70
|
-
log(lines_to_tabular(svcs, 'APP,HOST,ENDPOINT', separator=','))
|
|
71
|
-
else:
|
|
72
|
-
svcs = [n for n, ns in Apps.envs()]
|
|
73
|
-
|
|
74
|
-
log(lines_to_tabular(svcs, 'ENV', separator=','))
|
|
75
|
-
else:
|
|
76
|
-
if state.pod:
|
|
77
|
-
r: PodExecResult = Cqlsh().run(f'cql describe tables', state)
|
|
78
|
-
if r.stderr:
|
|
79
|
-
log(r.stderr)
|
|
80
|
-
log(r.stdout)
|
|
81
|
-
elif state.sts and state.namespace:
|
|
82
|
-
show_pods(StatefulSets.pods(state.sts, state.namespace), state.namespace, show_namespace=not KubeContext.in_cluster_namespace())
|
|
83
|
-
show_rollout(state.sts, state.namespace)
|
|
84
|
-
else:
|
|
85
|
-
self.show_statefulsets()
|
|
86
|
-
|
|
87
|
-
return state
|
|
88
|
-
|
|
89
|
-
def show_statefulsets(self):
|
|
90
|
-
ss = StatefulSets.list_sts_names(show_namespace=not KubeContext.in_cluster_namespace())
|
|
91
|
-
if len(ss) == 0:
|
|
92
|
-
log2('No cassandra statefulsets found.')
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
app_ids = CustomResources.get_app_ids()
|
|
96
|
-
list = []
|
|
97
|
-
for s in ss:
|
|
98
|
-
cr_name = CustomResources.get_cr_name(s)
|
|
99
|
-
app_id = 'Unknown'
|
|
100
|
-
if cr_name in app_ids:
|
|
101
|
-
app_id = app_ids[cr_name]
|
|
102
|
-
list.append(f"{s} {app_id}")
|
|
103
|
-
|
|
104
|
-
header = 'STATEFULSET_NAME@NAMESPACE APP_ID'
|
|
105
|
-
if KubeContext.in_cluster_namespace():
|
|
106
|
-
header = 'STATEFULSET_NAME APP_ID'
|
|
107
|
-
log(lines_to_tabular(list, header))
|
|
108
|
-
|
|
109
|
-
def show_pg_hosts(self, state: ReplState):
|
|
110
|
-
if state.namespace:
|
|
111
|
-
def line(pg: PostgresSession):
|
|
112
|
-
return f'{pg.directory()},{pg.endpoint()}:{pg.port()},{pg.username()},{pg.password()}'
|
|
113
|
-
|
|
114
|
-
lines = [line(PostgresSession(state.namespace, pg)) for pg in PostgresSession.hosts(state.namespace)]
|
|
115
|
-
|
|
116
|
-
log(lines_to_tabular(lines, 'NAME,ENDPOINT,USERNAME,PASSWORD', separator=','))
|
|
117
|
-
else:
|
|
118
|
-
def line(pg: PostgresSession):
|
|
119
|
-
return f'{pg.directory()},{pg.namespace},{pg.endpoint()}:{pg.port()},{pg.username()},{pg.password()}'
|
|
120
|
-
|
|
121
|
-
lines = [line(PostgresSession(state.namespace, pg)) for pg in PostgresSession.hosts(state.namespace)]
|
|
122
|
-
|
|
123
|
-
log(lines_to_tabular(lines, 'NAME,NAMESPACE,ENDPOINT,USERNAME,PASSWORD', separator=','))
|
|
124
|
-
|
|
125
|
-
def show_pg_databases(self, pg: PostgresSession):
|
|
126
|
-
lines = [db["name"] for db in pg.databases() if db["owner"] == PostgresSession.default_owner()]
|
|
127
|
-
|
|
128
|
-
log(lines_to_tabular(lines, 'DATABASE', separator=','))
|
|
129
|
-
|
|
130
|
-
def show_pg_tables(self, pg: PostgresSession):
|
|
131
|
-
lines = [db["name"] for db in pg.tables() if db["schema"] == PostgresSession.default_schema()]
|
|
132
|
-
|
|
133
|
-
log(lines_to_tabular(lines, 'NAME', separator=','))
|
|
134
|
-
|
|
135
|
-
def completion(self, state: ReplState):
|
|
136
|
-
if state.pod:
|
|
137
|
-
return {}
|
|
138
|
-
|
|
139
|
-
if not state.sts:
|
|
140
|
-
return {Ls.COMMAND: {n: None for n in StatefulSets.list_sts_names()}}
|
|
141
|
-
|
|
142
|
-
return {Ls.COMMAND: None}
|
|
143
|
-
|
|
144
|
-
def help(self, _: ReplState):
|
|
145
|
-
return f'{Ls.COMMAND} [device:]\t list apps, envs, clusters, nodes, pg hosts or pg databases'
|
walker/commands/medusa/medusa.py
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
|
|
3
|
-
from walker.commands.command import Command
|
|
4
|
-
from walker.commands.command_helpers import ClusterCommandHelper
|
|
5
|
-
from .medusa_backup import MedusaBackup
|
|
6
|
-
from .medusa_restore import MedusaRestore
|
|
7
|
-
from .medusa_show_backupjobs import MedusaShowBackupJobs
|
|
8
|
-
from .medusa_show_restorejobs import MedusaShowRestoreJobs
|
|
9
|
-
from walker.repl_state import ReplState, RequiredState
|
|
10
|
-
from walker.utils import lines_to_tabular, log, log2
|
|
11
|
-
|
|
12
|
-
class Medusa(Command):
|
|
13
|
-
COMMAND = 'medusa'
|
|
14
|
-
|
|
15
|
-
# the singleton pattern
|
|
16
|
-
def __new__(cls, *args, **kwargs):
|
|
17
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Medusa, cls).__new__(cls)
|
|
18
|
-
|
|
19
|
-
return cls.instance
|
|
20
|
-
|
|
21
|
-
def __init__(self, successor: Command=None):
|
|
22
|
-
super().__init__(successor)
|
|
23
|
-
|
|
24
|
-
def command(self):
|
|
25
|
-
return Medusa.COMMAND
|
|
26
|
-
|
|
27
|
-
def required(self):
|
|
28
|
-
return RequiredState.CLUSTER
|
|
29
|
-
|
|
30
|
-
def run(self, cmd: str, state: ReplState):
|
|
31
|
-
if not(args := self.args(cmd)):
|
|
32
|
-
return super().run(cmd, state)
|
|
33
|
-
|
|
34
|
-
state, args = self.apply_state(args, state)
|
|
35
|
-
if not self.validate_state(state):
|
|
36
|
-
return state
|
|
37
|
-
|
|
38
|
-
if state.in_repl:
|
|
39
|
-
log(lines_to_tabular([c.help(ReplState()) for c in Medusa.cmd_list()], separator=':'))
|
|
40
|
-
|
|
41
|
-
return 'command-missing'
|
|
42
|
-
else:
|
|
43
|
-
# head with the Chain of Responsibility pattern
|
|
44
|
-
cmds = Command.chain(Medusa.cmd_list())
|
|
45
|
-
if not cmds.run(cmd, state):
|
|
46
|
-
log2('* Command is missing.')
|
|
47
|
-
Command.display_help()
|
|
48
|
-
|
|
49
|
-
def cmd_list():
|
|
50
|
-
return [MedusaBackup(), MedusaRestore(), MedusaShowBackupJobs(), MedusaShowRestoreJobs()]
|
|
51
|
-
|
|
52
|
-
def completion(self, state: ReplState):
|
|
53
|
-
if state.sts:
|
|
54
|
-
return super().completion(state)
|
|
55
|
-
|
|
56
|
-
return {}
|
|
57
|
-
|
|
58
|
-
def help(self, _: ReplState):
|
|
59
|
-
return None
|
|
60
|
-
|
|
61
|
-
class MedusaCommandHelper(click.Command):
|
|
62
|
-
def get_help(self, ctx: click.Context):
|
|
63
|
-
log(super().get_help(ctx))
|
|
64
|
-
log()
|
|
65
|
-
log('Sub-Commands:')
|
|
66
|
-
|
|
67
|
-
log(lines_to_tabular([c.help(ReplState()).replace(f'{Medusa.COMMAND} ', ' ', 1) for c in Medusa.cmd_list()], separator=':'))
|
|
68
|
-
log()
|
|
69
|
-
ClusterCommandHelper.cluster_help()
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
import re
|
|
3
|
-
|
|
4
|
-
from walker.commands.command import Command
|
|
5
|
-
from walker.k8s_utils.statefulsets import StatefulSets
|
|
6
|
-
from walker.repl_state import ReplState, RequiredState
|
|
7
|
-
from walker.k8s_utils.custom_resources import CustomResources
|
|
8
|
-
from walker.utils import log2
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MedusaBackup(Command):
|
|
12
|
-
COMMAND = 'backup'
|
|
13
|
-
|
|
14
|
-
# the singleton pattern
|
|
15
|
-
def __new__(cls, *args, **kwargs):
|
|
16
|
-
if not hasattr(cls, 'instance'): cls.instance = super(MedusaBackup, cls).__new__(cls)
|
|
17
|
-
|
|
18
|
-
return cls.instance
|
|
19
|
-
|
|
20
|
-
def __init__(self, successor: Command=None):
|
|
21
|
-
super().__init__(successor)
|
|
22
|
-
|
|
23
|
-
def command(self):
|
|
24
|
-
return MedusaBackup.COMMAND
|
|
25
|
-
|
|
26
|
-
def required(self):
|
|
27
|
-
return RequiredState.CLUSTER
|
|
28
|
-
|
|
29
|
-
def run(self, cmd: str, state: ReplState):
|
|
30
|
-
if not(args := self.args(cmd)):
|
|
31
|
-
return super().run(cmd, state)
|
|
32
|
-
state, args = self.apply_state(args, state)
|
|
33
|
-
if not self.validate_state(state):
|
|
34
|
-
return state
|
|
35
|
-
|
|
36
|
-
ns = state.namespace
|
|
37
|
-
sts = state.sts
|
|
38
|
-
now_dtformat = datetime.now().strftime("%Y-%m-%d.%H.%M.%S")
|
|
39
|
-
bkname = 'medusa-' + now_dtformat + 'full-backup-' + sts
|
|
40
|
-
if len(args) == 1:
|
|
41
|
-
bkname = str(args[0])
|
|
42
|
-
groups = re.match(r'^(.*?-.*?-).*', sts)
|
|
43
|
-
dc = StatefulSets.get_datacenter(state.sts, ns)
|
|
44
|
-
if not dc:
|
|
45
|
-
return state
|
|
46
|
-
|
|
47
|
-
try:
|
|
48
|
-
CustomResources.create_medusa_backupjob(bkname, dc, ns)
|
|
49
|
-
except Exception as e:
|
|
50
|
-
log2("Exception: MedusaBackup failed: %s\n" % e)
|
|
51
|
-
|
|
52
|
-
return state
|
|
53
|
-
|
|
54
|
-
def completion(self, state: ReplState):
|
|
55
|
-
if state.sts:
|
|
56
|
-
return super().completion(state)
|
|
57
|
-
|
|
58
|
-
return {}
|
|
59
|
-
|
|
60
|
-
def help(self, _: ReplState):
|
|
61
|
-
return f'{MedusaBackup.COMMAND}\t start a backup job'
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
|
|
3
|
-
from walker.commands.command import Command
|
|
4
|
-
from walker.k8s_utils.statefulsets import StatefulSets
|
|
5
|
-
from walker.repl_state import ReplState, RequiredState
|
|
6
|
-
from walker.k8s_utils.custom_resources import CustomResources
|
|
7
|
-
from walker.config import Config
|
|
8
|
-
from walker.utils import lines_to_tabular, log2
|
|
9
|
-
|
|
10
|
-
class MedusaRestore(Command):
|
|
11
|
-
COMMAND = 'restore'
|
|
12
|
-
|
|
13
|
-
# the singleton pattern
|
|
14
|
-
def __new__(cls, *args, **kwargs):
|
|
15
|
-
if not hasattr(cls, 'instance'): cls.instance = super(MedusaRestore, cls).__new__(cls)
|
|
16
|
-
|
|
17
|
-
return cls.instance
|
|
18
|
-
|
|
19
|
-
def __init__(self, successor: Command=None):
|
|
20
|
-
super().__init__(successor)
|
|
21
|
-
|
|
22
|
-
def command(self):
|
|
23
|
-
return MedusaRestore.COMMAND
|
|
24
|
-
|
|
25
|
-
def required(self):
|
|
26
|
-
return RequiredState.CLUSTER
|
|
27
|
-
|
|
28
|
-
def run(self, cmd: str, state: ReplState):
|
|
29
|
-
if not(args := self.args(cmd)):
|
|
30
|
-
return super().run(cmd, state)
|
|
31
|
-
state, args = self.apply_state(args, state)
|
|
32
|
-
if not self.validate_state(state):
|
|
33
|
-
return state
|
|
34
|
-
|
|
35
|
-
ns = state.namespace
|
|
36
|
-
dc = StatefulSets.get_datacenter(state.sts, ns)
|
|
37
|
-
if not dc:
|
|
38
|
-
return state
|
|
39
|
-
|
|
40
|
-
if len(args) == 1:
|
|
41
|
-
bkname = args[0]
|
|
42
|
-
job = CustomResources.medusa_get_backupjob(dc, ns, bkname)
|
|
43
|
-
if not job:
|
|
44
|
-
log2('\n* Backup job name is not valid.')
|
|
45
|
-
bklist = [f"{x['metadata']['name']}\t{x['metadata']['creationTimestamp']}\t{x['status'].get('finishTime', '')}" for x in CustomResources.medusa_show_backupjobs(dc, ns)]
|
|
46
|
-
log2(lines_to_tabular(bklist, 'NAME\tCREATED\tFINISHED', separator='\t'))
|
|
47
|
-
|
|
48
|
-
return state
|
|
49
|
-
|
|
50
|
-
if not input(f"Restoring from {bkname} created at {job['metadata']['creationTimestamp']}. Please enter Yes to continue: ").lower() in ['y', 'yes']:
|
|
51
|
-
return state
|
|
52
|
-
else:
|
|
53
|
-
bklist = [f"{x['metadata']['name']}\t{x['metadata']['creationTimestamp']}\t{x['status'].get('finishTime', '')}" for x in CustomResources.medusa_show_backupjobs(dc, ns)]
|
|
54
|
-
log2('\n* Missing Backup Name')
|
|
55
|
-
log2('Usage: qing medusa restore <backup> <sts@name_space>\n')
|
|
56
|
-
log2(lines_to_tabular(bklist, 'NAME\tCREATED\tFINISHED', separator='\t'))
|
|
57
|
-
return state
|
|
58
|
-
|
|
59
|
-
now_dtformat = datetime.now().strftime("%Y-%m-%d.%H.%M.%S")
|
|
60
|
-
rtname = 'medusa-' + now_dtformat + '-restore-from-' + bkname
|
|
61
|
-
try:
|
|
62
|
-
print('SEAN doing')
|
|
63
|
-
# CustomResources.create_medusa_restorejob(rtname, bkname, dc, ns)
|
|
64
|
-
except Exception as e:
|
|
65
|
-
log2("Exception: MedusaRestore failed: %s\n" % e)
|
|
66
|
-
|
|
67
|
-
return state
|
|
68
|
-
|
|
69
|
-
def completion(self, state: ReplState):
|
|
70
|
-
if state.sts:
|
|
71
|
-
ns = state.namespace
|
|
72
|
-
dc = StatefulSets.get_datacenter(state.sts, ns)
|
|
73
|
-
if not dc:
|
|
74
|
-
return {}
|
|
75
|
-
|
|
76
|
-
if Config().get('medusa.restore-auto-complete', False):
|
|
77
|
-
leaf = {id: None for id in [f"{x['metadata']['name']}" for x in CustomResources.medusa_show_backupjobs(dc, ns)]}
|
|
78
|
-
|
|
79
|
-
return super().completion(state, leaf)
|
|
80
|
-
else:
|
|
81
|
-
return super().completion(state)
|
|
82
|
-
|
|
83
|
-
return {}
|
|
84
|
-
|
|
85
|
-
def help(self, _: ReplState):
|
|
86
|
-
return f'{MedusaRestore.COMMAND}\t start a restore job'
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.k8s_utils.statefulsets import StatefulSets
|
|
3
|
-
from walker.repl_state import ReplState, RequiredState
|
|
4
|
-
from walker.k8s_utils.custom_resources import CustomResources
|
|
5
|
-
from walker.utils import lines_to_tabular, log2
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class MedusaShowBackupJobs(Command):
|
|
9
|
-
COMMAND = 'show backups'
|
|
10
|
-
|
|
11
|
-
# the singleton pattern
|
|
12
|
-
def __new__(cls, *args, **kwargs):
|
|
13
|
-
if not hasattr(cls, 'instance'): cls.instance = super(MedusaShowBackupJobs, cls).__new__(cls)
|
|
14
|
-
|
|
15
|
-
return cls.instance
|
|
16
|
-
|
|
17
|
-
def __init__(self, successor: Command=None):
|
|
18
|
-
super().__init__(successor)
|
|
19
|
-
|
|
20
|
-
def command(self):
|
|
21
|
-
return MedusaShowBackupJobs.COMMAND
|
|
22
|
-
|
|
23
|
-
def required(self):
|
|
24
|
-
return RequiredState.CLUSTER
|
|
25
|
-
|
|
26
|
-
def run(self, cmd: str, state: ReplState):
|
|
27
|
-
if not(args := self.args(cmd)):
|
|
28
|
-
return super().run(cmd, state)
|
|
29
|
-
state, args = self.apply_state(args, state)
|
|
30
|
-
if not self.validate_state(state):
|
|
31
|
-
return state
|
|
32
|
-
ns = state.namespace
|
|
33
|
-
dc = StatefulSets.get_datacenter(state.sts, ns)
|
|
34
|
-
if not dc:
|
|
35
|
-
return state
|
|
36
|
-
|
|
37
|
-
try:
|
|
38
|
-
bklist = [f"{x['metadata']['name']}\t{x['metadata']['creationTimestamp']}\t{x['status'].get('finishTime', '')}" for x in CustomResources.medusa_show_backupjobs(dc, ns)]
|
|
39
|
-
log2(lines_to_tabular(bklist, 'NAME\tCREATED\tFINISHED', separator='\t'))
|
|
40
|
-
except Exception as e:
|
|
41
|
-
log2("Exception: MedusaShowBackupJobs failed: %s\n" % e)
|
|
42
|
-
|
|
43
|
-
return state
|
|
44
|
-
|
|
45
|
-
def completion(self, state: ReplState):
|
|
46
|
-
if state.sts:
|
|
47
|
-
return super().completion(state)
|
|
48
|
-
|
|
49
|
-
return {}
|
|
50
|
-
|
|
51
|
-
def help(self, _: ReplState):
|
|
52
|
-
return f'{MedusaShowBackupJobs.COMMAND}\t start a restore job'
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.k8s_utils.statefulsets import StatefulSets
|
|
3
|
-
from walker.repl_state import ReplState, RequiredState
|
|
4
|
-
from walker.k8s_utils.custom_resources import CustomResources
|
|
5
|
-
from walker.utils import lines_to_tabular, log2
|
|
6
|
-
|
|
7
|
-
class MedusaShowRestoreJobs(Command):
|
|
8
|
-
COMMAND = 'show restores'
|
|
9
|
-
|
|
10
|
-
# the singleton pattern
|
|
11
|
-
def __new__(cls, *args, **kwargs):
|
|
12
|
-
if not hasattr(cls, 'instance'): cls.instance = super(MedusaShowRestoreJobs, cls).__new__(cls)
|
|
13
|
-
|
|
14
|
-
return cls.instance
|
|
15
|
-
|
|
16
|
-
def __init__(self, successor: Command=None):
|
|
17
|
-
super().__init__(successor)
|
|
18
|
-
|
|
19
|
-
def command(self):
|
|
20
|
-
return MedusaShowRestoreJobs.COMMAND
|
|
21
|
-
|
|
22
|
-
def required(self):
|
|
23
|
-
return RequiredState.CLUSTER
|
|
24
|
-
|
|
25
|
-
def run(self, cmd: str, state: ReplState):
|
|
26
|
-
if not(args := self.args(cmd)):
|
|
27
|
-
return super().run(cmd, state)
|
|
28
|
-
state, args = self.apply_state(args, state)
|
|
29
|
-
if not self.validate_state(state):
|
|
30
|
-
return state
|
|
31
|
-
|
|
32
|
-
ns = state.namespace
|
|
33
|
-
dc = StatefulSets.get_datacenter(state.sts, ns)
|
|
34
|
-
if not dc:
|
|
35
|
-
return state
|
|
36
|
-
|
|
37
|
-
try:
|
|
38
|
-
rtlist = CustomResources.medusa_show_restorejobs(dc, ns)
|
|
39
|
-
log2(lines_to_tabular(rtlist, 'NAME\tCREATED\tFINISHED', separator='\t'))
|
|
40
|
-
except Exception as e:
|
|
41
|
-
log2("Exception: MedusaShowRestoreJobs failed: %s\n" % e)
|
|
42
|
-
|
|
43
|
-
return state
|
|
44
|
-
|
|
45
|
-
def completion(self, state: ReplState):
|
|
46
|
-
if state.sts:
|
|
47
|
-
return super().completion(state)
|
|
48
|
-
|
|
49
|
-
return {}
|
|
50
|
-
|
|
51
|
-
def help(self, _: ReplState):
|
|
52
|
-
return f'{MedusaShowRestoreJobs.COMMAND}\t start a restore job'
|
walker/commands/param_set.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.config import Config
|
|
3
|
-
from walker.repl_state import ReplState
|
|
4
|
-
from walker.utils import log, log2
|
|
5
|
-
|
|
6
|
-
class SetParam(Command):
|
|
7
|
-
COMMAND = 'set'
|
|
8
|
-
|
|
9
|
-
# the singleton pattern
|
|
10
|
-
def __new__(cls, *args, **kwargs):
|
|
11
|
-
if not hasattr(cls, 'instance'): cls.instance = super(SetParam, cls).__new__(cls)
|
|
12
|
-
|
|
13
|
-
return cls.instance
|
|
14
|
-
|
|
15
|
-
def __init__(self, successor: Command=None):
|
|
16
|
-
super().__init__(successor)
|
|
17
|
-
|
|
18
|
-
def command(self):
|
|
19
|
-
return SetParam.COMMAND
|
|
20
|
-
|
|
21
|
-
def run(self, cmd: str, state: ReplState):
|
|
22
|
-
if not(args := self.args(cmd)):
|
|
23
|
-
return super().run(cmd, state)
|
|
24
|
-
|
|
25
|
-
state, args = self.apply_state(args, state)
|
|
26
|
-
|
|
27
|
-
if len(args) < 2:
|
|
28
|
-
log2('set <key> <value>')
|
|
29
|
-
|
|
30
|
-
return 'invalid args'
|
|
31
|
-
|
|
32
|
-
key = args[0]
|
|
33
|
-
value = args[1]
|
|
34
|
-
Config().set(key, value)
|
|
35
|
-
|
|
36
|
-
log(Config().get(key, None))
|
|
37
|
-
|
|
38
|
-
return value
|
|
39
|
-
|
|
40
|
-
def completion(self, _: ReplState):
|
|
41
|
-
return {SetParam.COMMAND: {key: None for key in Config().keys()}}
|
|
42
|
-
|
|
43
|
-
def help(self, _: ReplState):
|
|
44
|
-
return f"{SetParam.COMMAND} <key> <value>\t sets a Kaqing parameter to a different value"
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
|
|
3
|
-
from walker.commands.command import Command
|
|
4
|
-
from walker.commands.command_helpers import ClusterCommandHelper
|
|
5
|
-
from .postgres_ls import PostgresLs
|
|
6
|
-
from .postgres_preview import PostgresPreview
|
|
7
|
-
from .postgres_session import PostgresSession
|
|
8
|
-
from walker.repl_state import ReplState
|
|
9
|
-
from walker.utils import lines_to_tabular, log, log2
|
|
10
|
-
|
|
11
|
-
class Postgres(Command):
|
|
12
|
-
COMMAND = 'pg'
|
|
13
|
-
reaper_login = None
|
|
14
|
-
|
|
15
|
-
# the singleton pattern
|
|
16
|
-
def __new__(cls, *args, **kwargs):
|
|
17
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Postgres, cls).__new__(cls)
|
|
18
|
-
|
|
19
|
-
return cls.instance
|
|
20
|
-
|
|
21
|
-
def __init__(self, successor: Command=None):
|
|
22
|
-
super().__init__(successor)
|
|
23
|
-
|
|
24
|
-
def command(self):
|
|
25
|
-
return Postgres.COMMAND
|
|
26
|
-
|
|
27
|
-
def run(self, cmd: str, state: ReplState):
|
|
28
|
-
if not(args := self.args(cmd)):
|
|
29
|
-
return super().run(cmd, state)
|
|
30
|
-
|
|
31
|
-
state, args = self.apply_state(args, state)
|
|
32
|
-
|
|
33
|
-
if state.in_repl:
|
|
34
|
-
if not args:
|
|
35
|
-
log2('Please use SQL statement. e.g. pg \l')
|
|
36
|
-
|
|
37
|
-
return 'command-missing'
|
|
38
|
-
else:
|
|
39
|
-
self.run_sql(state, args)
|
|
40
|
-
else:
|
|
41
|
-
if not args:
|
|
42
|
-
log2('* Command or SQL statements is missing.')
|
|
43
|
-
Command.display_help()
|
|
44
|
-
|
|
45
|
-
return 'command-missing'
|
|
46
|
-
else:
|
|
47
|
-
# head with the Chain of Responsibility pattern
|
|
48
|
-
cmds = Command.chain(Postgres.cmd_list())
|
|
49
|
-
if not cmds.run(cmd, state) :
|
|
50
|
-
if not args:
|
|
51
|
-
log2('* Command or SQL statements is missing.')
|
|
52
|
-
Command.display_help()
|
|
53
|
-
|
|
54
|
-
return 'command-missing'
|
|
55
|
-
else:
|
|
56
|
-
self.run_sql(state, args)
|
|
57
|
-
|
|
58
|
-
return state
|
|
59
|
-
|
|
60
|
-
def cmd_list():
|
|
61
|
-
return [PostgresLs(), PostgresPreview()]
|
|
62
|
-
|
|
63
|
-
def run_sql(self, state: ReplState, args: list[str]):
|
|
64
|
-
if not state.pg_path:
|
|
65
|
-
if state.in_repl:
|
|
66
|
-
log2('Enter "use <pg-name>" first.')
|
|
67
|
-
else:
|
|
68
|
-
log2('* pg-name is missing.')
|
|
69
|
-
|
|
70
|
-
return state
|
|
71
|
-
|
|
72
|
-
PostgresSession(state.namespace, state.pg_path).run_sql(' '.join(args))
|
|
73
|
-
|
|
74
|
-
def completion(self, state: ReplState):
|
|
75
|
-
leaf = {}
|
|
76
|
-
if PostgresSession(state.namespace, state.pg_path).db:
|
|
77
|
-
leaf = {
|
|
78
|
-
'\h': None,
|
|
79
|
-
'\d': None,
|
|
80
|
-
'\dt': None,
|
|
81
|
-
'\du': None,
|
|
82
|
-
'delete': {'from': None},
|
|
83
|
-
'insert': {'into': None},
|
|
84
|
-
'select': None,
|
|
85
|
-
'update': None,
|
|
86
|
-
}
|
|
87
|
-
elif state.pg_path:
|
|
88
|
-
leaf = {
|
|
89
|
-
'\h': None,
|
|
90
|
-
'\l': None,
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if state.pg_path:
|
|
94
|
-
return super().completion(state, leaf) | leaf
|
|
95
|
-
else:
|
|
96
|
-
return {}
|
|
97
|
-
|
|
98
|
-
def help(self, _: ReplState):
|
|
99
|
-
return f'[{Postgres.COMMAND}] <sql-statements>\t run psql with queries'
|
|
100
|
-
|
|
101
|
-
class PostgresCommandHelper(click.Command):
|
|
102
|
-
def get_help(self, ctx: click.Context):
|
|
103
|
-
log(super().get_help(ctx))
|
|
104
|
-
log()
|
|
105
|
-
log('Sub-Commands:')
|
|
106
|
-
|
|
107
|
-
log(lines_to_tabular([c.help(ReplState()).replace(f'{Postgres.COMMAND} ', ' ', 1) for c in Postgres.cmd_list()], separator='\t'))
|
|
108
|
-
log()
|
|
109
|
-
ClusterCommandHelper.cluster_help()
|
|
110
|
-
log('PG-Name: Kubernetes secret for Postgres credentials')
|
|
111
|
-
log(' e.g. stgawsscpsr-c3-c3-k8spg-cs-001')
|
|
112
|
-
log('Database: Postgres database name within a host')
|
|
113
|
-
log(' e.g. stgawsscpsr_c3_c3')
|