Skip to content

Commit c5cecf9

Browse files
Merge pull request #728 from linode/dev
Release v5.56.2
2 parents c8c17d0 + 184b017 commit c5cecf9

File tree

6 files changed

+62
-8
lines changed

6 files changed

+62
-8
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: make requirements
4040

4141
- name: Set up QEMU
42-
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # pin@v3.2.0
42+
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # pin@v3.3.0
4343

4444
- name: Set up Docker Buildx
4545
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # [email protected]
@@ -67,7 +67,7 @@ jobs:
6767
result-encoding: string
6868

6969
- name: Build and push to DockerHub
70-
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # pin@v6.10.0
70+
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # pin@v6.13.0
7171
with:
7272
context: .
7373
file: Dockerfile
@@ -102,6 +102,6 @@ jobs:
102102
LINODE_CLI_VERSION: ${{ github.event.release.tag_name }}
103103

104104
- name: Publish the release artifacts to PyPI
105-
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # pin@release/v1.12.3
105+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # pin@release/v1.12.4
106106
with:
107107
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/remote-release-trigger.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
commit_sha: ${{ steps.calculate_head_sha.outputs.commit_sha }}
6767

6868
- name: Release
69-
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048 # [email protected].0
69+
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # [email protected].1
7070
with:
7171
target_commitish: 'main'
7272
token: ${{ steps.generate_token.outputs.token }}

linodecli/configuration/helpers.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
"""
44

55
import configparser
6+
import math
67
import os
78
import webbrowser
9+
from functools import partial
810
from typing import Any, Callable, List, Optional
911

1012
LEGACY_CONFIG_NAME = ".linode-cli"
@@ -142,13 +144,14 @@ def _default_thing_input(
142144
exists = current_value is not None
143145

144146
idx_offset = int(exists) + 1
147+
pad = partial(_pad_index, total=len(things) + idx_offset)
145148

146149
# If there is a current value, users should have the option to clear it
147150
if exists:
148-
print(" 1 - No Default")
151+
print(f"{pad(1)} - No Default")
149152

150153
for ind, thing in enumerate(things):
151-
print(f" {ind + idx_offset} - {thing}")
154+
print(f"{pad(ind + idx_offset)} - {thing}")
152155
print()
153156

154157
while True:
@@ -184,6 +187,16 @@ def _default_thing_input(
184187
return things[choice_idx]
185188

186189

190+
def _pad_index(idx: int, total: int) -> str:
191+
# NOTE: The implementation of this function could be less opaque if we're
192+
# willing to say, "There will never be a case where total > X, because no
193+
# one could examine and choose from that many options."
194+
max_padding = math.floor(math.log10(total)) + 1
195+
num_spaces = max_padding - math.floor(math.log10(idx))
196+
197+
return " " * num_spaces + str(idx)
198+
199+
187200
def _default_text_input(
188201
ask: str,
189202
default: Optional[str] = None,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies = [
2222
dynamic = ["version"]
2323

2424
[project.optional-dependencies]
25-
obj = ["boto3"]
25+
obj = ["boto3>=1.36.0"]
2626
dev = [
2727
"pylint>=2.17.4",
2828
"pytest>=7.3.1",

resolve_spec_url

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ if __name__ == "__main__":
3939
desired_version = get_latest_tag()
4040

4141
print(
42-
f"https://raw.githubusercontent.com/{LINODE_DOCS_REPO}/{desired_version}/openapi.yaml"
42+
f"https://raw.githubusercontent.com/{LINODE_DOCS_REPO}/{desired_version}/openapi.json"
4343
)

tests/unit/test_configuration.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,47 @@ def test_default_thing_input_out_of_range(self, monkeypatch):
519519

520520
assert result == "foo"
521521

522+
def test_default_thing_spacing(self, monkeypatch):
523+
stdout_buf = io.StringIO()
524+
monkeypatch.setattr("sys.stdin", io.StringIO("1\n"))
525+
526+
with contextlib.redirect_stdout(stdout_buf):
527+
_default_thing_input(
528+
"foo\n", [*range(1, 10_001)], "prompt text", "error text"
529+
)
530+
531+
output_lines = stdout_buf.getvalue().splitlines()
532+
533+
assert output_lines[3] == " 1 - 1"
534+
assert output_lines[11] == " 9 - 9"
535+
assert output_lines[12] == " 10 - 10"
536+
assert output_lines[101] == " 99 - 99"
537+
assert output_lines[102] == " 100 - 100"
538+
assert output_lines[1001] == " 999 - 999"
539+
assert output_lines[1002] == " 1000 - 1000"
540+
assert output_lines[10_001] == " 9999 - 9999"
541+
assert output_lines[10_002] == " 10000 - 10000"
542+
543+
def test_default_thing_spacing_with_current(self, monkeypatch):
544+
stdout_buf = io.StringIO()
545+
monkeypatch.setattr("sys.stdin", io.StringIO("1\n"))
546+
547+
with contextlib.redirect_stdout(stdout_buf):
548+
_default_thing_input(
549+
"foo\n",
550+
[*range(1, 10)],
551+
"prompt text",
552+
"error text",
553+
current_value="foo",
554+
)
555+
556+
output_lines = stdout_buf.getvalue().splitlines()
557+
558+
print(output_lines)
559+
assert output_lines[4] == " 2 - 1"
560+
assert output_lines[11] == " 9 - 8"
561+
assert output_lines[12] == " 10 - 9"
562+
522563
def test_default_text_input_optional(self, monkeypatch):
523564
# No value specified
524565
stdout_buf = io.StringIO()

0 commit comments

Comments
 (0)