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

feat: handle VRF Gateways in "metal gateway list" #479

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

displague
Copy link
Member

@displague displague commented Aug 7, 2024

Adds metal gateway list support for VRF Gateways.

Why is this needed?

$ metal gateway get
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xad902e]

goroutine 1 [running]:
github.com/equinix/metal-cli/internal/gateway.(*Client).Retrieve.func1(0xc00021c308?, {0x12e08e0?, 0x0?, 0x0?})
        /home/runner/work/metal-cli/metal-cli/internal/gateway/retrieve.go:70 +0x56e
github.com/spf13/cobra.(*Command).execute(0xc00021c308, {0x12e08e0, 0x0, 0x0})
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000134608)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0xc0000061c0?)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039 +0x13
main.main()
        /home/runner/work/metal-cli/metal-cli/cmd/metal/main.go:32 +0x1b

@displague
Copy link
Member Author

displague commented Aug 7, 2024

metal-cli % PACKNGO_DEBUG=1 go run ./cmd/metal/ gateways list                              
GET /metal/v1//projects/{project_id}/metal-gateways?include=virtual_network%2Cip_reservation HTTP/1.1
Host: api.equinix.com
User-Agent: metal-cli/(devel) equinix-sdk-go/0.42.0
Accept: application/json
X-Auth-Token: **REDACTED**
Accept-Encoding: gzip

HTTP/1.1 404 Not Found
Content-Type: application/json; charset=utf-8

{"errors":["Not found"]}
Error: Could not list Project Metal Gateways: 404 Not Found Not found

@displague
Copy link
Member Author

displague commented Aug 7, 2024

My default project ID was old (no longer exists).

Updated to a valid one:

go run ./cmd/metal/ gateways list -p $METAL_PROJECT_ID 
+---------------+-------+-------+------------------+--------+-------------------------------+-----------------+
|         ID    | METRO | VXLAN |    ADDRESSES     | STATE  |            CREATED            |      TYPE       |
+---------------+-------+-------+------------------+--------+-------------------------------+-----------------+
| redacted-uuid | am    | 1002  | 192.168.100.2/22 | active | 2024-08-02 18:16:23 +0000 UTC | VrfMetalGateway |
+---------------+-------+-------+------------------+--------+-------------------------------+-----------------+

@displague
Copy link
Member Author

displague commented Aug 8, 2024

Output with a VRF and non-VRF Gateway:

$ go run ./cmd/metal/ gateways list -p $METAL_PROJECT_ID
+--------------------------------------+-------+-------+------------------+--------+-------------------------------+-------------------+
|                  ID                  | METRO | VXLAN |    ADDRESSES     | STATE  |            CREATED            |        VRF        |
+--------------------------------------+-------+-------+------------------+--------+-------------------------------+-------------------+
| 48492792-aa66-4857-aac3-abcd12345678 | am    | 1000  | 10.12.0.242/29   | ready  | 2024-08-08 18:44:48 +0000 UTC |                   |
| bd3162f4-4162-408b-8670-abcd12345678 | am    | 1002  | 192.168.100.2/22 | active | 2024-08-02 18:16:23 +0000 UTC | nutanix-vrf-bRkYc |
+--------------------------------------+-------+-------+------------------+--------+-------------------------------+-------------------+

gway := n.MetalGateway
metalGways = append(metalGways, gway)
for _, gwaysInner := range gways {
gway := newGatewayish(gwaysInner)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this really count as getting rid of the if block within the for loop?

@ctreatma ctreatma merged commit e6743b0 into main Aug 8, 2024
8 checks passed
@ctreatma ctreatma deleted the get_gateway_with_vrf branch August 8, 2024 20:15
Copy link

This issue has been resolved in version 0.25.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants