Skip to content

feat(vpc-gw): add interactive question to delete the IP when deleting gw#5296

Open
remyleone wants to merge 3 commits intoscaleway:mainfrom
remyleone:vpc_gw_delete
Open

feat(vpc-gw): add interactive question to delete the IP when deleting gw#5296
remyleone wants to merge 3 commits intoscaleway:mainfrom
remyleone:vpc_gw_delete

Conversation

@remyleone
Copy link
Member

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Release note for CHANGELOG:


@remyleone remyleone requested a review from a team as a code owner January 28, 2026 10:02
Copilot AI review requested due to automatic review settings January 28, 2026 10:02
@github-actions github-actions bot added the vpcgw label Jan 28, 2026
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.82%. Comparing base (a9232ac) to head (1a0e900).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
internal/namespaces/vpcgw/v2/custom_gateway.go 0.00% 62 Missing ⚠️
internal/namespaces/vpcgw/v2/custom.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5296      +/-   ##
==========================================
- Coverage   55.86%   55.82%   -0.05%     
==========================================
  Files         317      317              
  Lines       71645    71708      +63     
==========================================
  Hits        40028    40028              
- Misses      30123    30186      +63     
  Partials     1494     1494              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an interactive confirmation prompt when deleting a VPC gateway to optionally delete the attached IP as part of the delete operation.

Changes:

  • Overrides vpc-gw gateway delete to support a tri-state with-ip={prompt,true,false} flag and prompt when applicable.
  • Fetches gateway details prior to deletion to determine whether an IP is attached and whether prompting is needed.
  • Updates CLI docs to reflect the new with-ip argument.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
internal/namespaces/vpcgw/v2/custom_gateway.go Adds a custom delete command implementation with interactive IP deletion confirmation.
internal/namespaces/vpcgw/v2/custom.go Wires the generated gateway delete command to the new custom builder.
docs/commands/vpc-gw.md Updates documented args for vpc-gw gateway delete to use with-ip.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +119 to +125
// Get gateway info to check if it has an IP
gateway, err := api.GetGateway(&vpcgw.GetGatewayRequest{
Zone: args.Zone,
GatewayID: args.GatewayID,
})
if err != nil {
return nil, err
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

GetGateway is called unconditionally before deleting. If with-ip is explicitly true or false, this extra API call is unnecessary and can introduce extra latency / permission failures. Consider only fetching the gateway (and prompting) when with-ip=prompt is selected (or when using the deprecated alias, if kept).

Suggested change
// Get gateway info to check if it has an IP
gateway, err := api.GetGateway(&vpcgw.GetGatewayRequest{
Zone: args.Zone,
GatewayID: args.GatewayID,
})
if err != nil {
return nil, err
var gateway *vpcgw.Gateway
var err error
// Only fetch gateway info when we may need to prompt about deleting the IP
if args.WithIP == withIPPrompt {
gateway, err = api.GetGateway(&vpcgw.GetGatewayRequest{
Zone: args.Zone,
GatewayID: args.GatewayID,
})
if err != nil {
return nil, err
}

Copilot uses AI. Check for mistakes.
Comment on lines +167 to +169
default:
return false, nil
}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

In shouldDeleteIP, the default case silently returns (false, nil). This can hide unexpected values and change behavior without surfacing an error. Other tri-state flags in the codebase return an error for unsupported values (e.g. internal/namespaces/instance/v1/custom_server_action.go with-block handling). Return a descriptive error here instead of silently defaulting.

Copilot uses AI. Check for mistakes.
Comment on lines 368 to 370
| gateway-id | Required | ID of the gateway to delete |
| delete-ip | | Defines whether the PGW's IP should be deleted |
| with-ip | Default: `prompt`<br />One of: `prompt`, `true`, `false` | Delete the IP attached to the gateway |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config |
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

Docs replace delete-ip with with-ip. If delete-ip is already released, this is a breaking CLI change for users following existing docs/scripts; consider documenting delete-ip as a deprecated alias (or keeping it) to preserve backward compatibility.

Copilot uses AI. Check for mistakes.
type customDeleteGatewayRequest struct {
Zone scw.Zone
GatewayID string
DeleteIP bool
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

customDeleteGatewayRequest defines DeleteIP but the field is never read and there is no ArgSpec for delete-ip, so it is currently dead code. Either remove this field, or reintroduce delete-ip as a deprecated alias (ideally as *bool so you can distinguish “not set” from “set to false”) and map it to the new behavior.

Suggested change
DeleteIP bool

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +101
Name: "with-ip",
Short: "Delete the IP attached to the gateway",
Default: core.DefaultValueSetter(withIPPrompt),
EnumValues: []string{
withIPPrompt,
withIPTrue,
withIPFalse,
},
},
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

This override renames the CLI arg from delete-ip (generated command) to with-ip, which will break existing scripts. Consider keeping delete-ip as a deprecated alias (e.g., same OneOfGroup as with-ip to prevent both being set) and translating it to with-ip=true/false behavior internally.

Suggested change
Name: "with-ip",
Short: "Delete the IP attached to the gateway",
Default: core.DefaultValueSetter(withIPPrompt),
EnumValues: []string{
withIPPrompt,
withIPTrue,
withIPFalse,
},
},
Name: "with-ip",
Short: "Delete the IP attached to the gateway",
Default: core.DefaultValueSetter(withIPPrompt),
EnumValues: []string{
withIPPrompt,
withIPTrue,
withIPFalse,
},
OneOfGroup: "gateway-delete-ip-mode",
},
{
Name: "delete-ip",
Short: "Delete the IP attached to the gateway (deprecated, use with-ip instead)",
Deprecated: "use with-ip instead",
OneOfGroup: "gateway-delete-ip-mode",
},

Copilot uses AI. Check for mistakes.
|------|---|-------------|
| gateway-id | Required | ID of the gateway to delete |
| delete-ip | | Defines whether the PGW's IP should be deleted |
| with-ip | Default: `prompt`<br />One of: `prompt`, `true`, `false` | Delete the IP attached to the gateway |
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe there is a way to avoid a breaking change here

@yfodil yfodil changed the base branch from master to main February 27, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants