Skip to content

Commit 0b915fb

Browse files
Merge pull request #452 from linode/dev
Release v5.37.0
2 parents 0857e40 + fcaaf50 commit 0b915fb

17 files changed

+187
-144
lines changed

.github/workflows/e2e-suite-pr-command.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,10 @@ jobs:
99
runs-on: ubuntu-latest
1010
if: ${{ github.event.issue.pull_request }}
1111
steps:
12-
- name: Generate App Installation Token
13-
id: generate_token
14-
uses: tibdex/github-app-token@v1
15-
with:
16-
app_id: ${{ secrets.DX_ACCTEST_APP_ID }}
17-
private_key: ${{ secrets.DX_ACCTEST_PRIV_KEY }}
18-
1912
- name: Slash Command Dispatch
20-
uses: peter-evans/slash-command-dispatch@v1
21-
env:
22-
TOKEN: ${{ steps.generate_token.outputs.token }}
13+
uses: peter-evans/slash-command-dispatch@v3
2314
with:
24-
token: ${{ env.TOKEN }}
25-
reaction-token: ${{ secrets.GITHUB_TOKEN }}
15+
token: ${{ secrets.GITHUB_TOKEN }}
2616
issue-type: pull-request
2717
commands: acctest
2818
named-args: true

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
python-version: '3.x'
2121

2222
- name: Install Python wheel
23-
run: pip install wheel boto3
23+
run: pip install wheel boto3 mock
2424

2525
- name: Update cert
2626
run: pip install certifi -U

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ clean:
4646
testunit: export LINODE_CLI_TEST_MODE = 1
4747
testunit:
4848
pytest tests/unit
49-
python -m unittest tests/unit/*.py
5049

5150
.PHONY: testint
5251
testint:

README.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ Using an existing config file::
3838

3939
docker run --rm -it -v $HOME/.config/linode-cli:/home/cli/.config/linode-cli linode/cli:latest linodes list
4040

41+
GitHub Actions
42+
^^^^^^^^^^^^^^
43+
44+
The Linode CLI can be automatically installed and authenticated in a GitHub actions environment using
45+
the `Setup Linode CLI`_ GitHub Action::
46+
47+
- name: Install the Linode CLI
48+
uses: linode/action-linode-cli@v1
49+
with:
50+
token: ${{ secrets.LINODE_TOKEN }}
51+
52+
.. _Setup Linode CLI: https://github.com/marketplace/actions/setup-linode-cli
53+
4154
Upgrading
4255
---------
4356

linodecli/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from sys import argv
1010

1111
import pkg_resources
12-
from terminaltables import SingleTable
12+
from rich import print as rprint
13+
from rich.table import Table
1314

1415
from linodecli import plugins
1516

@@ -234,8 +235,10 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
234235
for action, op in cli.ops[parsed.command].items()
235236
]
236237

237-
table = SingleTable([["action", "summary"]] + content)
238-
print(table.table)
238+
table = Table("action", "summary")
239+
for row in content:
240+
table.add_row(*row)
241+
rprint(table)
239242
sys.exit(0)
240243

241244
if parsed.command is not None and parsed.action is not None:

linodecli/arg_helpers.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
import requests
1111
import yaml
12-
from terminaltables import SingleTable
12+
from rich import print as rprint
13+
from rich.table import Table
1314

1415
from linodecli import plugins
1516

@@ -233,23 +234,26 @@ def help_with_ops(ops, config):
233234
# commands to manage CLI users (don't call out to API)
234235
print("\nCLI user management commands:")
235236
um_commands = [["configure", "set-user", "show-users"], ["remove-user"]]
236-
table = SingleTable(um_commands)
237-
table.inner_heading_row_border = False
238-
print(table.table)
237+
table = Table(show_header=False)
238+
for cmd in um_commands:
239+
table.add_row(*cmd)
240+
rprint(table)
239241

240242
# commands to manage plugins (don't call out to API)
241243
print("\nCLI Plugin management commands:")
242244
pm_commands = [["register-plugin", "remove-plugin"]]
243-
table = SingleTable(pm_commands)
244-
table.inner_heading_row_border = False
245-
print(table.table)
245+
table = Table(show_header=False)
246+
for cmd in pm_commands:
247+
table.add_row(*cmd)
248+
rprint(table)
246249

247250
# other CLI commands
248251
print("\nOther CLI commands:")
249252
other_commands = [["completion"]]
250-
table = SingleTable(other_commands)
251-
table.inner_heading_row_border = False
252-
print(table.table)
253+
table = Table(show_header=False)
254+
for cmd in other_commands:
255+
table.add_row(*cmd)
256+
rprint(table)
253257

254258
# commands generated from the spec (call the API directly)
255259
print("\nAvailable commands:")
@@ -261,9 +265,10 @@ def help_with_ops(ops, config):
261265
if content[i + 3 :]:
262266
proc.append(content[i + 3 :])
263267

264-
table = SingleTable(proc)
265-
table.inner_heading_row_border = False
266-
print(table.table)
268+
table = Table(show_header=False)
269+
for cmd in proc:
270+
table.add_row(*cmd)
271+
rprint(table)
267272

268273
# plugins registered to the CLI (do arbitrary things)
269274
if plugins.available(config):
@@ -278,10 +283,10 @@ def help_with_ops(ops, config):
278283
if plugin_content[i + 3 :]:
279284
plugin_proc.append(plugin_content[i + 3 :])
280285

281-
plugin_table = SingleTable(plugin_proc)
282-
plugin_table.inner_heading_row_border = False
283-
284-
print(plugin_table.table)
286+
plugin_table = Table(show_header=False)
287+
for plugin in plugin_proc:
288+
plugin_table.add_row(*plugin)
289+
rprint(plugin_table)
285290

286291
print("\nTo reconfigure, call `linode-cli configure`")
287292
print(

linodecli/output.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
from enum import Enum
77
from sys import stdout
88

9-
from terminaltables import SingleTable
9+
from rich import box
10+
from rich import print as rprint
11+
from rich.table import Table
12+
from rich.text import Text
1013

1114

1215
class OutputMode(Enum):
@@ -134,15 +137,18 @@ def _table_output(
134137
),
135138
)
136139

137-
tab = SingleTable(content)
140+
tab = Table(*content[0], header_style="", box=box.SQUARE)
141+
for row in content[1:]:
142+
row = [Text.from_ansi(item) for item in row]
143+
tab.add_row(*row)
138144

139145
if title is not None:
140146
tab.title = title
141147

142148
if not self.headers:
143-
tab.inner_heading_row_border = False
149+
tab.show_header = False
144150

145-
print(tab.table, file=to)
151+
rprint(tab, file=to)
146152

147153
def _delimited_output(self, header, data, columns, to):
148154
"""

linodecli/plugins/firewall-editor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
from ipaddress import IPv4Address, ip_address
1111
from typing import Callable
1212

13-
from terminaltables import PorcelainTable
13+
from rich import box
14+
from rich import print as rprint
15+
from rich.table import Table
1416

1517
from linodecli.plugins import inherit_plugin_args
1618

@@ -272,9 +274,11 @@ def print_rules_table(rules):
272274
]
273275
)
274276

275-
tab = PorcelainTable([header] + rows)
276-
tab.inner_heading_row_border = True
277-
print(tab.table)
277+
tab = Table(*header, box=box.ASCII, show_edge=False)
278+
for row in rows:
279+
row = [str(r) for r in row]
280+
tab.add_row(*row)
281+
rprint(tab)
278282

279283

280284
def draw_rules(rules):

linodecli/plugins/obj/__init__.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from pathlib import Path
1818
from typing import List
1919

20-
from terminaltables import SingleTable
20+
from rich import print as rprint
21+
from rich.table import Table
2122

2223
from linodecli.cli import CLI
2324
from linodecli.configuration import _do_get_request
@@ -121,20 +122,29 @@ def list_objects_or_buckets(
121122
if key == prefix:
122123
continue
123124

124-
data.append((obj.get("LastModified"), obj.get("Size"), key))
125+
data.append(
126+
(
127+
_convert_datetime(obj.get("LastModified")),
128+
obj.get("Size"),
129+
key,
130+
)
131+
)
125132

126133
if data:
127134
tab = _borderless_table(data)
128-
print(tab.table)
135+
rprint(tab)
129136

130137
sys.exit(0)
131138
else:
132139
# list buckets
133140
buckets = client.list_buckets().get("Buckets", [])
134-
data = [[b.get("CreationDate"), b.get("Name")] for b in buckets]
141+
data = [
142+
[_convert_datetime(b.get("CreationDate")), b.get("Name")]
143+
for b in buckets
144+
]
135145

136146
tab = _borderless_table(data)
137-
print(tab.table)
147+
rprint(tab)
138148

139149
sys.exit(0)
140150

@@ -388,7 +398,7 @@ def show_usage(get_client, args):
388398
tab = _borderless_table(
389399
[[_pad_to(total, length=7), f"{obj_count} objects", b]]
390400
)
391-
print(tab.table)
401+
rprint(tab)
392402

393403
if len(bucket_names) > 1:
394404
print("--------")
@@ -486,9 +496,10 @@ def print_help(parser: ArgumentParser):
486496
for name, func in sorted(COMMAND_MAP.items())
487497
]
488498

489-
tab = SingleTable(command_help_map)
490-
tab.inner_heading_row_border = False
491-
print(tab.table)
499+
tab = Table(show_header=False)
500+
for row in command_help_map:
501+
tab.add_row(*row)
502+
rprint(tab)
492503
print()
493504
print(
494505
"Additionally, you can regenerate your Object Storage keys using the "

linodecli/plugins/obj/helpers.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from argparse import ArgumentTypeError
55
from datetime import datetime
66

7-
from terminaltables import SingleTable
7+
from rich.table import Table
8+
from rich.text import Text
89

910
from linodecli.plugins.obj.config import DATE_FORMAT
1011

@@ -120,13 +121,11 @@ def _denominate(total):
120121
# helper functions for output
121122
def _borderless_table(data):
122123
"""
123-
Returns a terminaltables.SingleTable object with no borders and correct padding
124+
Returns a rich.Table object with no borders and correct padding
124125
"""
125-
tab = SingleTable(data)
126-
tab.inner_heading_row_border = False
127-
tab.inner_column_border = False
128-
tab.outer_border = False
129-
tab.padding_left = 0
130-
tab.padding_right = 2
126+
tab = Table.grid(padding=(0, 2, 0, 2))
127+
for row in data:
128+
row = [Text.from_ansi(str(item)) for item in row]
129+
tab.add_row(*row)
131130

132131
return tab

0 commit comments

Comments
 (0)