validio-cli 0.12.0__tar.gz → 0.13.0__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.
Files changed (27) hide show
  1. {validio_cli-0.12.0 → validio_cli-0.13.0}/PKG-INFO +1 -1
  2. {validio_cli-0.12.0 → validio_cli-0.13.0}/pyproject.toml +1 -1
  3. validio_cli-0.13.0/validio_cli/bin/main.py +177 -0
  4. validio_cli-0.12.0/validio_cli/bin/main.py +0 -83
  5. {validio_cli-0.12.0 → validio_cli-0.13.0}/LICENSE +0 -0
  6. {validio_cli-0.12.0 → validio_cli-0.13.0}/README_PUBLIC.md +0 -0
  7. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/__init__.py +0 -0
  8. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/channels.py +0 -0
  9. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/code.py +0 -0
  10. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/config.py +0 -0
  11. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/credentials.py +0 -0
  12. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/dbt.py +0 -0
  13. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/incidents.py +0 -0
  14. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/metrics.py +0 -0
  15. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/notification_rules.py +0 -0
  16. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/recommendations.py +0 -0
  17. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/resources.py +0 -0
  18. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/segmentations.py +0 -0
  19. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/segments.py +0 -0
  20. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/sources.py +0 -0
  21. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/users.py +0 -0
  22. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/validators.py +0 -0
  23. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/bin/entities/windows.py +0 -0
  24. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/components.py +0 -0
  25. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/metadata.py +0 -0
  26. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/namespace.py +0 -0
  27. {validio_cli-0.12.0 → validio_cli-0.13.0}/validio_cli/schema.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: validio-cli
3
- Version: 0.12.0
3
+ Version: 0.13.0
4
4
  Summary: CLI tool to interact with the Validio platform
5
5
  Home-page: https://validio.io/
6
6
  License: Apache-2.0
@@ -3,7 +3,7 @@ name = "validio-cli"
3
3
  # This version does not represent the released version or any tag. For each
4
4
  # release we automatically bump this before building and publishing so this
5
5
  # should be kept at 0.0.1dev1
6
- version = "0.12.0"
6
+ version = "0.13.0"
7
7
  description = "CLI tool to interact with the Validio platform"
8
8
  authors = ["Validio <support@validio.io>"]
9
9
  license = "Apache-2.0"
@@ -0,0 +1,177 @@
1
+ import os
2
+ import shutil
3
+ import sys
4
+ from typing import Optional
5
+
6
+ import typer
7
+ import validio_sdk.metadata
8
+ from tabulate import tabulate
9
+ from validio_sdk import ValidioError
10
+ from validio_sdk.config import Config
11
+
12
+ import validio_cli.metadata
13
+ from validio_cli.bin.entities import (
14
+ channels,
15
+ code,
16
+ config,
17
+ credentials,
18
+ dbt,
19
+ incidents,
20
+ metrics,
21
+ notification_rules,
22
+ recommendations,
23
+ resources,
24
+ segmentations,
25
+ segments,
26
+ sources,
27
+ users,
28
+ validators,
29
+ windows,
30
+ )
31
+
32
+ app = typer.Typer(
33
+ help="Validio CLI tool",
34
+ no_args_is_help=True,
35
+ pretty_exceptions_enable=False,
36
+ rich_markup_mode="rich",
37
+ )
38
+
39
+ app.add_typer(channels.app, no_args_is_help=True, name="channels")
40
+ app.add_typer(code.app, no_args_is_help=True, name="code")
41
+ app.add_typer(config.app, no_args_is_help=True, name="config")
42
+ app.add_typer(credentials.app, no_args_is_help=True, name="credentials")
43
+ app.add_typer(dbt.app, no_args_is_help=True, name="dbt")
44
+ app.add_typer(incidents.app, no_args_is_help=True, name="incidents")
45
+ app.add_typer(metrics.app, no_args_is_help=True, name="metrics")
46
+ app.add_typer(resources.app, no_args_is_help=True, name="resources")
47
+ app.add_typer(notification_rules.app, no_args_is_help=True, name="notification-rules")
48
+ app.add_typer(recommendations.app, no_args_is_help=True, name="recommendations")
49
+ app.add_typer(segmentations.app, no_args_is_help=True, name="segmentations")
50
+ app.add_typer(segments.app, no_args_is_help=True, name="segments")
51
+ app.add_typer(sources.app, no_args_is_help=True, name="sources")
52
+ app.add_typer(users.app, no_args_is_help=True, name="users")
53
+ app.add_typer(validators.app, no_args_is_help=True, name="validators")
54
+ app.add_typer(windows.app, no_args_is_help=True, name="windows")
55
+
56
+
57
+ @app.command(help="Show current version")
58
+ def version() -> None:
59
+ print(
60
+ tabulate(
61
+ [
62
+ ["SDK version", validio_sdk.metadata.version()],
63
+ ["CLI version", validio_cli.metadata.version()],
64
+ ],
65
+ tablefmt="plain",
66
+ )
67
+ )
68
+
69
+
70
+ @app.command(
71
+ add_help_option=False,
72
+ context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
73
+ )
74
+ def plugins(
75
+ ctx: typer.Context,
76
+ # We need to keep this for typer
77
+ # ruff: noqa: UP007
78
+ plugin: Optional[str] = typer.Argument(
79
+ None,
80
+ help="Plugin to run. Leave empty to list available plugins.",
81
+ ),
82
+ ) -> None:
83
+ """
84
+ Run plugin.
85
+
86
+ This works similar to `git` in that any executable prefixed with `validio-`
87
+ will be executed through this CLI without the prefix. That means that if you
88
+ have an executable somewhere in your `PATH` named `validio-my-app` you can
89
+ invoke that by running `validio plugin my-app`.
90
+
91
+ Any additional arguments will be passed to your plugin so you can run
92
+ `validio plugin my-app --arg1 --arg2`.
93
+ """
94
+ # We allow plugin as None since we want to show all available plugins when
95
+ # this part is
96
+ if plugin is None:
97
+ _list_executables()
98
+ return
99
+
100
+ # Since we want to allow passing any argument to plugins we accept extra
101
+ # unknown arguments and remove the `--help` flag so it can be passed to the
102
+ # plugin. However, if the _only_ argument passed (i.e. the `plugin`) is help
103
+ # we assume that the user wants help about the `plugin` subcommand.
104
+ if plugin in ["-h", "--help"]:
105
+ typer.echo(ctx.get_help())
106
+ return
107
+
108
+ plugin_path = shutil.which(f"validio-{plugin}")
109
+ if not plugin_path:
110
+ raise ValidioError(f"Unknown plugin {plugin}")
111
+
112
+ cfg = Config(None)
113
+ validio_cfg = cfg.read()
114
+
115
+ os.execve(
116
+ plugin_path,
117
+ [plugin_path] + sys.argv[3:],
118
+ # If someone wants to write a plugin with tooling that doesn't have an
119
+ # SDK we kindly pass the credentials to the environment so you can
120
+ # easily call Validio anyway.
121
+ {
122
+ "VALIDIO_CONFIG_PATH": str(cfg.config_path),
123
+ "VALIDIO_ENDPOINT": validio_cfg.endpoint,
124
+ "VALIDIO_ACCESS_KEY_ENV": validio_cfg.access_key,
125
+ "VALIDIO_SECRET_ACCESS_KEY_ENV": validio_cfg._access_secret,
126
+ },
127
+ )
128
+
129
+
130
+ def _list_executables() -> None:
131
+ paths = os.environ.get("PATH", "").split(":")
132
+
133
+ executables = set()
134
+ for path in paths:
135
+ try:
136
+ executables.update({
137
+ filename.lstrip("validio-")
138
+ for filename in os.listdir(path)
139
+ if filename.startswith("validio-")
140
+ })
141
+ except FileNotFoundError:
142
+ continue
143
+
144
+ if not executables:
145
+ print("No plugins found")
146
+ return
147
+
148
+ print(
149
+ tabulate(
150
+ [[executable] for executable in executables],
151
+ tablefmt="plain",
152
+ headers=["PLUGIN NAME"],
153
+ )
154
+ )
155
+
156
+
157
+ def main() -> None:
158
+ exit_code = 1
159
+
160
+ try:
161
+ app()
162
+ exit_code = 0
163
+
164
+ # If the pipe is broken we can't print more so just return asap.
165
+ except BrokenPipeError:
166
+ return
167
+
168
+ # ValidioErrors are thrown by us and should not require the stack trace
169
+ # to tell what went wrong.
170
+ except ValidioError as e:
171
+ print(f"Something went wrong: {e}")
172
+
173
+ sys.exit(exit_code)
174
+
175
+
176
+ if __name__ == "__main__":
177
+ main()
@@ -1,83 +0,0 @@
1
- import sys
2
-
3
- import typer
4
- import validio_sdk.metadata
5
- from tabulate import tabulate
6
- from validio_sdk import ValidioError
7
-
8
- import validio_cli.metadata
9
- from validio_cli.bin.entities import (
10
- channels,
11
- code,
12
- config,
13
- credentials,
14
- dbt,
15
- incidents,
16
- metrics,
17
- notification_rules,
18
- recommendations,
19
- resources,
20
- segmentations,
21
- segments,
22
- sources,
23
- users,
24
- validators,
25
- windows,
26
- )
27
-
28
- app = typer.Typer(
29
- help="Validio CLI tool", no_args_is_help=True, pretty_exceptions_enable=False
30
- )
31
-
32
- app.add_typer(channels.app, no_args_is_help=True, name="channels")
33
- app.add_typer(code.app, no_args_is_help=True, name="code")
34
- app.add_typer(config.app, no_args_is_help=True, name="config")
35
- app.add_typer(credentials.app, no_args_is_help=True, name="credentials")
36
- app.add_typer(dbt.app, no_args_is_help=True, name="dbt")
37
- app.add_typer(incidents.app, no_args_is_help=True, name="incidents")
38
- app.add_typer(metrics.app, no_args_is_help=True, name="metrics")
39
- app.add_typer(resources.app, no_args_is_help=True, name="resources")
40
- app.add_typer(notification_rules.app, no_args_is_help=True, name="notification-rules")
41
- app.add_typer(recommendations.app, no_args_is_help=True, name="recommendations")
42
- app.add_typer(segmentations.app, no_args_is_help=True, name="segmentations")
43
- app.add_typer(segments.app, no_args_is_help=True, name="segments")
44
- app.add_typer(sources.app, no_args_is_help=True, name="sources")
45
- app.add_typer(users.app, no_args_is_help=True, name="users")
46
- app.add_typer(validators.app, no_args_is_help=True, name="validators")
47
- app.add_typer(windows.app, no_args_is_help=True, name="windows")
48
-
49
-
50
- @app.command(help="Show current version")
51
- def version() -> None:
52
- print(
53
- tabulate(
54
- [
55
- ["SDK version", validio_sdk.metadata.version()],
56
- ["CLI version", validio_cli.metadata.version()],
57
- ],
58
- tablefmt="plain",
59
- )
60
- )
61
-
62
-
63
- def main() -> None:
64
- exit_code = 1
65
-
66
- try:
67
- app()
68
- exit_code = 0
69
-
70
- # If the pipe is broken we can't print more so just return asap.
71
- except BrokenPipeError:
72
- return
73
-
74
- # ValidioErrors are thrown by us and should not require the stack trace
75
- # to tell what went wrong.
76
- except ValidioError as e:
77
- print(f"Something went wrong: {e}")
78
-
79
- sys.exit(exit_code)
80
-
81
-
82
- if __name__ == "__main__":
83
- main()
File without changes