Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Support specifying arrays nested in complex lists as JSON #577

Merged
merged 3 commits into from
Feb 14, 2024

Conversation

lgarber-akamai
Copy link
Contributor

@lgarber-akamai lgarber-akamai commented Feb 9, 2024

📝 Description

This change allows users to specify deeply nested array fields (e.g. --interfaces.ip_ranges) as JSON. These fields previously could not be specified at all due to limitations with how the CLI differentiates between objects in complex lists.

This PR also adds a new suffix for fields on command help pages that identifies whether an argument expects JSON.

NOTE: The failing metadata plugin unit tests are not relevant to this PR and can be ignored, see TPT-2691.

✔️ How to Test

The following test steps assume you have pulled down this change locally and run make install.

E2E Testing

make INTEGRATION_TEST_PATH=linodes/test_interfaces.py testint

Unit Testing

make testunit

Manual Testing

  1. Create a VPC and VPC subnet:
export VPC_ID=$(linode-cli vpcs create --label test-vpc --region us-mia --json | jq '.[0].id')
export SUBNET_ID=$(linode-cli vpcs subnet-create --label test-subnet --ipv4 '10.0.0.0/24' ${VPC_ID} --json | jq '.[0].id')
  1. Attempt to create a Linode with an interface with an explicit ip_ranges field:
linode-cli linodes create \
  --label test-instance \
  --region us-mia \
  --image linode/alpine3.19 \
  --root_pass 'testp4ssw0rd!!!!!!23123' \
  --type g6-nanode-1 \
  --interfaces.primary true --interfaces.purpose vpc --interfaces.subnet_id ${SUBNET_ID} --interfaces.ip_ranges '["10.0.0.5/32"]' \
  --interfaces.purpose=public \
  --debug
  1. Ensure the ip_ranges field has been properly included in the debug output request body.
  2. Navigate to the instance in Cloud Manager and ensure all fields match the creation command.

📷 Preview

Command Help Page

linode-cli_–_arg_helpers_py

@lgarber-akamai lgarber-akamai marked this pull request as ready for review February 9, 2024 16:09
@lgarber-akamai lgarber-akamai requested a review from a team as a code owner February 9, 2024 16:09
@lgarber-akamai lgarber-akamai requested review from zliang-akamai and yec-akamai and removed request for a team February 9, 2024 16:09
@zliang-akamai
Copy link
Member

Unit test failing?

@lgarber-akamai
Copy link
Contributor Author

Unit test failing?

@zliang-akamai The failing unit tests are related to the Metadata SSH user issue discussed last week. I think we plan on fixing that in a separate PR 👍

See: TPT-2691

Copy link
Member

@zliang-akamai zliang-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Local tests passed.

Copy link
Contributor

@yec-akamai yec-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! All related tests passed locally!

@lgarber-akamai lgarber-akamai merged commit 287d6c5 into linode:dev Feb 14, 2024
4 of 6 checks passed
@jriddle-linode jriddle-linode added the new-feature for new features in the changelog. label Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature for new features in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants