oks-cli 1.19__tar.gz → 1.20__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 (28) hide show
  1. {oks_cli-1.19 → oks_cli-1.20}/PKG-INFO +2 -2
  2. {oks_cli-1.19 → oks_cli-1.20}/oks_cli/cluster.py +7 -0
  3. {oks_cli-1.19 → oks_cli-1.20}/oks_cli/project.py +16 -2
  4. {oks_cli-1.19 → oks_cli-1.20}/oks_cli/utils.py +15 -18
  5. {oks_cli-1.19 → oks_cli-1.20}/oks_cli.egg-info/PKG-INFO +2 -2
  6. {oks_cli-1.19 → oks_cli-1.20}/oks_cli.egg-info/requires.txt +1 -1
  7. {oks_cli-1.19 → oks_cli-1.20}/setup.py +2 -2
  8. {oks_cli-1.19 → oks_cli-1.20}/tests/test_shell_completion.py +2 -2
  9. {oks_cli-1.19 → oks_cli-1.20}/LICENSE +0 -0
  10. {oks_cli-1.19 → oks_cli-1.20}/README.md +0 -0
  11. {oks_cli-1.19 → oks_cli-1.20}/oks_cli/__init__.py +0 -0
  12. {oks_cli-1.19 → oks_cli-1.20}/oks_cli/cache.py +0 -0
  13. {oks_cli-1.19 → oks_cli-1.20}/oks_cli/main.py +0 -0
  14. {oks_cli-1.19 → oks_cli-1.20}/oks_cli/netpeering.py +0 -0
  15. {oks_cli-1.19 → oks_cli-1.20}/oks_cli/profile.py +0 -0
  16. {oks_cli-1.19 → oks_cli-1.20}/oks_cli/quotas.py +0 -0
  17. {oks_cli-1.19 → oks_cli-1.20}/oks_cli.egg-info/SOURCES.txt +0 -0
  18. {oks_cli-1.19 → oks_cli-1.20}/oks_cli.egg-info/dependency_links.txt +0 -0
  19. {oks_cli-1.19 → oks_cli-1.20}/oks_cli.egg-info/entry_points.txt +0 -0
  20. {oks_cli-1.19 → oks_cli-1.20}/oks_cli.egg-info/top_level.txt +0 -0
  21. {oks_cli-1.19 → oks_cli-1.20}/setup.cfg +0 -0
  22. {oks_cli-1.19 → oks_cli-1.20}/tests/test_cache.py +0 -0
  23. {oks_cli-1.19 → oks_cli-1.20}/tests/test_cluster.py +0 -0
  24. {oks_cli-1.19 → oks_cli-1.20}/tests/test_netpeering.py +0 -0
  25. {oks_cli-1.19 → oks_cli-1.20}/tests/test_nodepool.py +0 -0
  26. {oks_cli-1.19 → oks_cli-1.20}/tests/test_profile.py +0 -0
  27. {oks_cli-1.19 → oks_cli-1.20}/tests/test_project.py +0 -0
  28. {oks_cli-1.19 → oks_cli-1.20}/tests/test_quota.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oks-cli
3
- Version: 1.19
3
+ Version: 1.20
4
4
  Author: Outscale SAS
5
5
  Author-email: opensource@outscale.com
6
6
  License: BSD
@@ -17,7 +17,7 @@ Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
18
  Requires-Dist: certifi>=2024.8.30
19
19
  Requires-Dist: charset-normalizer>=3.3.2
20
- Requires-Dist: click<8.3.0,>=8.1.7
20
+ Requires-Dist: click<8.3.0,>=8.2.0
21
21
  Requires-Dist: colorama>=0.4.6
22
22
  Requires-Dist: idna>=3.10
23
23
  Requires-Dist: pyyaml>=6.0.2
@@ -74,6 +74,13 @@ def cluster_logout(ctx, profile):
74
74
  """Clear the current default cluster selection."""
75
75
  _, _, profile = ctx_update(ctx, None, None, profile)
76
76
  login_profile(profile)
77
+
78
+ current_cluster = get_cluster_id()
79
+
80
+ if not current_cluster:
81
+ click.echo("You are not connected to any cluster.")
82
+ return
83
+
77
84
  set_cluster_id("")
78
85
  click.echo("Logged out from the current cluster")
79
86
 
@@ -56,6 +56,13 @@ def project_logout(ctx, profile):
56
56
  """Unset the current default project and log out."""
57
57
  _, _, profile = ctx_update(ctx, None, None, profile)
58
58
  login_profile(profile)
59
+
60
+ current_project = get_project_id()
61
+
62
+ if not current_project:
63
+ click.echo("You are not connected to any project.")
64
+ return
65
+
59
66
  set_project_id("")
60
67
  set_cluster_id("")
61
68
  click.echo("Logged out from the current project")
@@ -404,7 +411,7 @@ def project_get_public_ips(ctx, project_name, output, profile):
404
411
  # GET NETS BY PROJECT NAME
405
412
  @project.command('nets', help="Get project nets")
406
413
  @click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer)
407
- @click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json")
414
+ @click.option('--output', '-o', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json")
408
415
  @click.option('--profile',help="Configuration profile to use")
409
416
  @click.pass_context
410
417
  def project_get_public_ips(ctx, project_name, output, profile):
@@ -415,4 +422,11 @@ def project_get_public_ips(ctx, project_name, output, profile):
415
422
  project_id = find_project_id_by_name(project_name)
416
423
 
417
424
  data = do_request("GET", f'projects/{project_id}/nets')
418
- print_output(data, output)
425
+ if output == "table":
426
+ print_table(data, [["DHCP options set id", "DhcpOptionsSetId"],
427
+ ["Ip range", "IpRange"],
428
+ ["Net id", "NetId"],
429
+ ["State", "State"],
430
+ ["Tenancy", "Tenancy"]])
431
+ else:
432
+ print_output(data, output)
@@ -917,7 +917,11 @@ def find_shell_profile(home, shell_type):
917
917
  if os.path.exists(bash_profile) and os.path.exists(bashrc):
918
918
  return None
919
919
 
920
- shell_profile = bash_profile or bashrc
920
+ if os.path.exists(bash_profile):
921
+ shell_profile = bash_profile
922
+
923
+ if os.path.exists(bashrc):
924
+ shell_profile = bashrc
921
925
 
922
926
  elif shell_type == "zsh":
923
927
 
@@ -927,7 +931,11 @@ def find_shell_profile(home, shell_type):
927
931
  if os.path.exists(zshrc) and os.path.exists(profile):
928
932
  return None
929
933
 
930
- shell_profile = zshrc or profile
934
+ if os.path.exists(zshrc):
935
+ shell_profile = zshrc
936
+
937
+ if os.path.exists(profile):
938
+ shell_profile = profile
931
939
 
932
940
  return shell_profile
933
941
 
@@ -1097,30 +1105,19 @@ def is_interesting_status(status):
1097
1105
  def normalize_key_path(key_path: str) -> str:
1098
1106
  return re.sub(r'\[(\d+)\]', r'.\1', key_path)
1099
1107
 
1100
- def parse_value(value):
1108
+ def parse_value(value: str):
1101
1109
  value = value.strip()
1102
1110
 
1103
- # Inline list: [a,b,c]
1104
- if value.startswith('[') and value.endswith(']'):
1105
- inner = value[1:-1].strip()
1106
- if not inner:
1107
- return []
1108
- return [parse_value(v.strip()) for v in inner.split(',')]
1111
+ try:
1112
+ return json.loads(value)
1113
+ except Exception:
1114
+ pass
1109
1115
 
1110
1116
  if value.lower() == "true":
1111
1117
  return True
1112
1118
  if value.lower() == "false":
1113
1119
  return False
1114
1120
 
1115
- try:
1116
- return int(value)
1117
- except ValueError:
1118
- pass
1119
-
1120
- try:
1121
- return float(value)
1122
- except ValueError:
1123
- pass
1124
1121
 
1125
1122
  if ',' in value:
1126
1123
  return [parse_value(v) for v in value.split(',')]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oks-cli
3
- Version: 1.19
3
+ Version: 1.20
4
4
  Author: Outscale SAS
5
5
  Author-email: opensource@outscale.com
6
6
  License: BSD
@@ -17,7 +17,7 @@ Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
18
  Requires-Dist: certifi>=2024.8.30
19
19
  Requires-Dist: charset-normalizer>=3.3.2
20
- Requires-Dist: click<8.3.0,>=8.1.7
20
+ Requires-Dist: click<8.3.0,>=8.2.0
21
21
  Requires-Dist: colorama>=0.4.6
22
22
  Requires-Dist: idna>=3.10
23
23
  Requires-Dist: pyyaml>=6.0.2
@@ -1,6 +1,6 @@
1
1
  certifi>=2024.8.30
2
2
  charset-normalizer>=3.3.2
3
- click<8.3.0,>=8.1.7
3
+ click<8.3.0,>=8.2.0
4
4
  colorama>=0.4.6
5
5
  idna>=3.10
6
6
  pyyaml>=6.0.2
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="oks-cli",
5
- version="1.19",
5
+ version="1.20",
6
6
  packages=['oks_cli'],
7
7
  author="Outscale SAS",
8
8
  author_email="opensource@outscale.com",
@@ -26,7 +26,7 @@ setup(
26
26
  install_requires=[
27
27
  "certifi>=2024.8.30",
28
28
  "charset-normalizer>=3.3.2",
29
- "click>=8.1.7,<8.3.0",
29
+ "click>=8.2.0,<8.3.0",
30
30
  "colorama>=0.4.6",
31
31
  "idna>=3.10",
32
32
  "pyyaml>=6.0.2",
@@ -9,7 +9,7 @@ def test_install_completion_zsh():
9
9
 
10
10
  result = runner.invoke(cli, ["install-completion", "--type", "zsh"])
11
11
  assert result.exit_code == 0
12
- assert "Autocompletion installed for zsh" in result.output
12
+ assert "To activate autocompletion on login please add following lines into your .profile or .zshrc file" in result.output
13
13
 
14
14
  completion_file = Path("~/.oks_cli/completions/oks-cli.sh").expanduser()
15
15
  assert completion_file.exists()
@@ -22,7 +22,7 @@ def test_install_completion_bash():
22
22
 
23
23
  result = runner.invoke(cli, ["install-completion", "--type", "bash"])
24
24
  assert result.exit_code == 0
25
- assert "Autocompletion installed for bash" in result.output
25
+ assert "To activate autocompletion on login please add following lines into your .bash_profile or .bashrc file" in result.output
26
26
 
27
27
  completion_file = Path("~/.oks_cli/completions/oks-cli.sh").expanduser()
28
28
  assert completion_file.exists()
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