vgs-cli 0.0.1.dev0__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.
Files changed (56) hide show
  1. vgs_cli-0.0.1.dev0.data/data/vgscli/calm.yaml +16 -0
  2. vgs_cli-0.0.1.dev0.data/data/vgscli/checkout.yaml +21 -0
  3. vgs_cli-0.0.1.dev0.data/data/vgscli/http-route-template.yaml +61 -0
  4. vgs_cli-0.0.1.dev0.data/data/vgscli/mft-route-template.yaml +10 -0
  5. vgs_cli-0.0.1.dev0.data/data/vgscli/payments-admin.yaml +25 -0
  6. vgs_cli-0.0.1.dev0.data/data/vgscli/service-account-schema.yaml +54 -0
  7. vgs_cli-0.0.1.dev0.data/data/vgscli/sub-account-checkout.yaml +23 -0
  8. vgs_cli-0.0.1.dev0.data/data/vgscli/vault-resources.yaml +710 -0
  9. vgs_cli-0.0.1.dev0.data/data/vgscli/vault-schema.yaml +36 -0
  10. vgs_cli-0.0.1.dev0.data/data/vgscli/vault-template.yaml +12 -0
  11. vgs_cli-0.0.1.dev0.data/data/vgscli/vgs-cli.yaml +17 -0
  12. vgs_cli-0.0.1.dev0.dist-info/METADATA +139 -0
  13. vgs_cli-0.0.1.dev0.dist-info/RECORD +56 -0
  14. vgs_cli-0.0.1.dev0.dist-info/WHEEL +5 -0
  15. vgs_cli-0.0.1.dev0.dist-info/entry_points.txt +2 -0
  16. vgs_cli-0.0.1.dev0.dist-info/licenses/LICENSE +22 -0
  17. vgs_cli-0.0.1.dev0.dist-info/top_level.txt +1 -0
  18. vgscli/__init__.py +0 -0
  19. vgscli/_version.py +32 -0
  20. vgscli/access_logs.py +65 -0
  21. vgscli/audits_api.py +102 -0
  22. vgscli/auth.py +68 -0
  23. vgscli/auth_server.py +131 -0
  24. vgscli/auth_utils.py +24 -0
  25. vgscli/callback_server.py +41 -0
  26. vgscli/cert_manager_api.py +34 -0
  27. vgscli/cli/__init__.py +23 -0
  28. vgscli/cli/commands/__init__.py +3 -0
  29. vgscli/cli/commands/apply.py +307 -0
  30. vgscli/cli/commands/generate.py +134 -0
  31. vgscli/cli/commands/get.py +200 -0
  32. vgscli/cli/types/__init__.py +2 -0
  33. vgscli/cli/types/resource_id.py +39 -0
  34. vgscli/cli/types/variable.py +21 -0
  35. vgscli/cli_utils.py +132 -0
  36. vgscli/click_extensions.py +88 -0
  37. vgscli/config_file.py +58 -0
  38. vgscli/errors.py +263 -0
  39. vgscli/file_token_util.py +30 -0
  40. vgscli/id_generator.py +46 -0
  41. vgscli/keyring_token_util.py +128 -0
  42. vgscli/resource-templates/http-route-template.yaml +61 -0
  43. vgscli/resource-templates/mft-route-template.yaml +10 -0
  44. vgscli/resource-templates/service-account/calm.yaml +16 -0
  45. vgscli/resource-templates/service-account/checkout.yaml +21 -0
  46. vgscli/resource-templates/service-account/payments-admin.yaml +25 -0
  47. vgscli/resource-templates/service-account/sub-account-checkout.yaml +23 -0
  48. vgscli/resource-templates/service-account/vgs-cli.yaml +17 -0
  49. vgscli/resource-templates/vault-template.yaml +12 -0
  50. vgscli/testing.py +48 -0
  51. vgscli/text.py +9 -0
  52. vgscli/token_handler.py +11 -0
  53. vgscli/validation-schemas/service-account-schema.yaml +54 -0
  54. vgscli/validation-schemas/vault-resources.yaml +710 -0
  55. vgscli/validation-schemas/vault-schema.yaml +36 -0
  56. vgscli/vgs.py +249 -0
vgscli/testing.py ADDED
@@ -0,0 +1,48 @@
1
+ import importlib
2
+ import unittest
3
+ from typing import List
4
+ from unittest import mock
5
+
6
+ from click.testing import CliRunner, Result
7
+
8
+ from vgscli.vgs import cli
9
+
10
+
11
+ class CliRunnerTestCase(unittest.TestCase):
12
+ def setUp(self) -> None:
13
+ self.runner = CliRunner()
14
+
15
+ def invoke(self, command: List[str]) -> Result:
16
+ return self.runner.invoke(cli, args=[*command])
17
+
18
+ def assertExitCode(self, result: Result, exit_code: int) -> None:
19
+ self.assertEqual(exit_code, result.exit_code, "Unexpected exit code")
20
+
21
+ def assertOutput(self, result: Result, output: str) -> None:
22
+ self.assertEqual(output, result.output, "Unexpected output")
23
+
24
+ def assertOutputContains(self, result: Result, expected: str) -> None:
25
+ self.assertTrue(
26
+ expected in result.output,
27
+ f'Could not find "{expected}" in "{result.output}"',
28
+ )
29
+
30
+
31
+ # https://stackoverflow.com/questions/52324568
32
+ def patch(*args, **kwargs):
33
+ target = args[0].split(".")
34
+
35
+ for i in range(len(target), 0, -1):
36
+ # noinspection PyBroadException
37
+ try:
38
+ module = importlib.import_module(".".join(target[:i]))
39
+
40
+ # noinspection PyShadowingNames
41
+ patch = mock.patch(*args, **kwargs)
42
+ patch.attribute = ".".join(target[i:])
43
+ patch.getter = lambda: module
44
+ return patch
45
+ except Exception:
46
+ pass
47
+
48
+ return mock.patch(*args, **kwargs)
vgscli/text.py ADDED
@@ -0,0 +1,9 @@
1
+ from termcolor import colored
2
+
3
+
4
+ def bold(text: str) -> str:
5
+ return colored(text, attrs=["bold"])
6
+
7
+
8
+ def green(text: str) -> str:
9
+ return colored(text, color="green")
@@ -0,0 +1,11 @@
1
+ token = None
2
+
3
+
4
+ class CodeHandler:
5
+ def put_code(self, api_token):
6
+ global token
7
+ token = api_token
8
+
9
+ def get_code(self):
10
+ global token
11
+ return token
@@ -0,0 +1,54 @@
1
+ ---
2
+ "$schema": http://json-schema.org/draft-07/schema#
3
+ type: object
4
+ properties:
5
+ apiVersion:
6
+ type: string
7
+ enum:
8
+ - 1.0.0
9
+ kind:
10
+ type: string
11
+ enum:
12
+ - ServiceAccount
13
+ data:
14
+ type: object
15
+ properties:
16
+ name:
17
+ type: string
18
+ annotations:
19
+ type: object
20
+ additionalProperties:
21
+ type: string
22
+ default: {}
23
+ vaults:
24
+ type: array
25
+ items:
26
+ type: string
27
+ scopes:
28
+ type: array
29
+ items:
30
+ oneOf:
31
+ - type: object
32
+ properties:
33
+ name:
34
+ type: string
35
+ optional:
36
+ type: boolean
37
+ default: false
38
+ required:
39
+ - name
40
+ additionalProperties: false
41
+ - type: string # Left for compatibility
42
+ minItems: 1
43
+ accessTokenLifespan:
44
+ type: integer
45
+ minimum: 60
46
+ required:
47
+ - name
48
+ - scopes
49
+ additionalProperties: false
50
+ required:
51
+ - apiVersion
52
+ - kind
53
+ - data
54
+ additionalProperties: false