Skip to content

Commit a50ce24

Browse files
Merge pull request #797 from linode/dev
Release v5.60.0
2 parents cc6307d + d5136db commit a50ce24

File tree

79 files changed

+4417
-5119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4417
-5119
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # pin@v3.6.0
4343

4444
- name: Set up Docker Buildx
45-
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # pin@v3.10.0
45+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # pin@v3.11.1
4646

4747
- name: Login to Docker Hub
4848
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # pin@v3.4.0

.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@da05d552573ad5aba039eaac05058a918a7bf631 # pin@v2.2.2
69+
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # pin@v2.3.2
7070
with:
7171
target_commitish: 'main'
7272
token: ${{ steps.generate_token.outputs.token }}

linodecli/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
8080
cli.page = parsed.page
8181
cli.page_size = parsed.page_size
8282
cli.debug_request = parsed.debug
83+
cli.raw_body = parsed.raw_body
8384

8485
if parsed.as_user and not skip_config:
8586
cli.config.set_user(parsed.as_user)

linodecli/api_request.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,21 +348,49 @@ def _build_request_body(
348348
349349
:return: A JSON string representing the request body, or None if not applicable.
350350
"""
351-
if operation.method == "get":
352-
# Get operations don't have a body
351+
if operation.method in ("get", "delete"):
352+
# GET and DELETE operations don't have a body
353+
if ctx.raw_body is not None:
354+
print(
355+
f"--raw-body cannot be specified for actions with method {operation.method}",
356+
file=sys.stderr,
357+
)
358+
sys.exit(ExitCodes.ARGUMENT_ERROR)
359+
353360
return None
354361

362+
param_names = {param.name for param in operation.params}
363+
364+
# Returns whether the given argument should be included in the request body
365+
def __should_include(key: str, value: Any) -> bool:
366+
return value is not None and key not in param_names
367+
368+
# If the user has specified the --raw-body argument,
369+
# return it.
370+
if ctx.raw_body is not None:
371+
specified_keys = [
372+
k for k, v in vars(parsed_args).items() if __should_include(k, v)
373+
]
374+
375+
if len(specified_keys) > 0:
376+
print(
377+
"--raw-body cannot be specified with action arguments: "
378+
+ ", ".join(sorted(f"--{key}" for key in specified_keys)),
379+
file=sys.stderr,
380+
)
381+
sys.exit(ExitCodes.ARGUMENT_ERROR)
382+
383+
return ctx.raw_body
384+
355385
# Merge defaults into body if applicable
356386
if ctx.defaults:
357387
parsed_args = ctx.config.update(parsed_args, operation.allowed_defaults)
358388

359-
param_names = {param.name for param in operation.params}
360-
361389
expanded_json = {}
362390

363391
# Expand dotted keys into nested dictionaries
364392
for k, v in vars(parsed_args).items():
365-
if v is None or k in param_names:
393+
if not __should_include(k, v):
366394
continue
367395

368396
path_segments = get_path_segments(k)

linodecli/arg_helpers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ def register_args(parser: ArgumentParser) -> ArgumentParser:
8181
help="The alias to set or remove.",
8282
)
8383

84+
parser.add_argument(
85+
"--raw-body",
86+
type=str,
87+
help="The raw JSON to use as the request body of an action. "
88+
+ "This argument cannot be used if action-specific arguments are specified. "
89+
+ "Additionally, this argument can only be used with POST and PUT actions.",
90+
)
91+
8492
# Register shared argument groups
8593
register_output_args_shared(parser)
8694
register_pagination_args_shared(parser)

linodecli/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def __init__(self, version, base_url, skip_config=False):
4444
self.base_url = base_url
4545
self.spec_version = "None"
4646
self.suppress_warnings = False
47+
self.raw_body = None
4748

4849
self.output_handler = OutputHandler()
4950
self.config = CLIConfig(self.base_url, skip_config=skip_config)

linodecli/plugins/get-kubeconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _get_kubeconfig_by_label(cluster_label, client):
130130
# Loads a yaml file
131131
def _load_config(filepath):
132132
with open(filepath, "r", encoding="utf-8") as file_descriptor:
133-
data = yaml.load(file_descriptor, Loader=yaml.Loader)
133+
data = yaml.safe_load(file_descriptor)
134134

135135
if not data:
136136
print(f"Could not load file at {filepath}", file=sys.stderr)

0 commit comments

Comments
 (0)