Skip to content

fix: add missing --network flag for ip static-nat enable command - #45

Merged
ditahkk merged 1 commit into
zsoftly:mainfrom
cokerrd:fix/enable-static-nat
Aug 21, 2026
Merged

fix: add missing --network flag for ip static-nat enable command#45
ditahkk merged 1 commit into
zsoftly:mainfrom
cokerrd:fix/enable-static-nat

Conversation

@cokerrd

@cokerrd cokerrd commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Addresses #44

  • Added --network flag which now passes the correct request to the api
  • Corrected the help text example
  • Updated test to include network
  • Corrected output on enabling static-nat

Previous output
Screenshot 2026-07-23 at 00 13 51

corrected output
Screenshot 2026-07-23 at 00 53 09

Demo

Screen.Recording.2026-07-23.at.00.36.53.mov

Summary by CodeRabbit

  • New Features

    • Static NAT enablement now requires a target network in addition to the instance.
    • Public IPs are associated with both the selected instance and network.
  • Improvements

    • Command output now provides a simplified status and message summary.
    • Success responses are reported more clearly after enabling Static NAT.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c1b5e875-a664-44da-87d2-b1bceeb363d2

📝 Walkthrough

Walkthrough

Static NAT enablement now requires a network slug, includes it in the API request, returns the response envelope, and displays the resulting status and message in the CLI.

Changes

Static NAT network association

Layer / File(s) Summary
Static NAT API contract
pkg/api/ipaddress/ipaddress.go, pkg/api/ipaddress/ipaddress_test.go
The request includes network, EnableStaticNAT accepts the network slug and returns the response envelope, and tests validate the updated request and success status.
CLI network wiring and output
internal/commands/ip.go
The command requires --network, forwards it to the API service, and prints STATUS/MESSAGE output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Suggested reviewers: ditahm6, ditahkk, godsonten, clintonche

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding the missing --network flag to ip static-nat enable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/api/ipaddress/ipaddress_test.go (1)

191-198: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the response message used by the CLI.

The updated command renders ip.Message, but this test only verifies Status; populate Message in the fixture and assert result.Message so the response-envelope/output contract is covered.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/ipaddress/ipaddress_test.go` around lines 191 - 198, Update the
response fixture used by this test to populate the Message field, then add an
assertion for result.Message alongside the existing result.Status check. Verify
the expected message emitted by the CLI response envelope while preserving the
current body assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/api/ipaddress/ipaddress_test.go`:
- Around line 191-198: Update the response fixture used by this test to populate
the Message field, then add an assertion for result.Message alongside the
existing result.Status check. Verify the expected message emitted by the CLI
response envelope while preserving the current body assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fef6a324-2442-4c88-8535-3a64fc8b855b

📥 Commits

Reviewing files that changed from the base of the PR and between b9d121c and ef62931.

📒 Files selected for processing (3)
  • internal/commands/ip.go
  • pkg/api/ipaddress/ipaddress.go
  • pkg/api/ipaddress/ipaddress_test.go

@ditahkk

ditahkk commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

We will also need some updates to the docs here https://github.com/zsoftly/zcp-cli/blob/main/docs/commands.md?plain=1#L233; The example here still omits --network. Update it if you have time. Otherwise we will fix it in a follow-up.

@ditahkk

ditahkk commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Addresses #44

  • Added --network flag which now passes the correct request to the api
  • Corrected the help text example
  • Updated test to include network
  • Corrected output on enabling static-nat

Previous output Screenshot 2026-07-23 at 00 13 51

corrected output Screenshot 2026-07-23 at 00 53 09

Demo

Screen.Recording.2026-07-23.at.00.36.53.mov

Summary by CodeRabbit

  • New Features

    • Static NAT enablement now requires a target network in addition to the instance.
    • Public IPs are associated with both the selected instance and network.
  • Improvements

    • Command output now provides a simplified status and message summary.
    • Success responses are reported more clearly after enabling Static NAT.

Thanks for the fix. The flag, help text, and test line up with the bug in #44. Two items before merge:

  1. See the inline note on the return type.
  2. We added a DCO sign-off requirement after you opened this PR. See CONTRIBUTING.md. Rebase with --signoff and force-push to pass the new check.

Comment thread pkg/api/ipaddress/ipaddress.go Outdated
// vmSlug is the virtual machine slug.
func (s *Service) EnableStaticNAT(ctx context.Context, ipSlug, vmSlug string) (*IPAddress, error) {
body := StaticNATRequest{VirtualMachine: vmSlug}
func (s *Service) EnableStaticNAT(ctx context.Context, ipSlug, vmSlug, networkSlug string) (*singleResponse, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

EnableStaticNAT is exported but now returns the unexported singleResponse type. Callers outside the package cannot name it, and Go lint flags it. Other services here return exported result types. Please return an exported type. The shape is your call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

got it, would make the update

Comment thread internal/commands/ip.go
{"VM", ip.VirtualMachineName},
{"Network ID", ip.NetworkID},
}
headers := []string{"STATUS", "MESSAGE"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the API return useful data on success? The error case in #44 shows data null. If success is the same, dropping the detail table is right. A quick confirmation here is enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, it doesn't return any useful data, only the "status" and "message" fields are returned in the response

Signed-off-by: Coker Richard <82083946+cokerrd@users.noreply.github.com>
@cokerrd
cokerrd force-pushed the fix/enable-static-nat branch from 630b766 to 2651dbf Compare August 20, 2026 00:02
@cokerrd

cokerrd commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@ditahkk changes have been pushed but am I to address the failing security analysis step ? or would you or the other maintainers address it?

@ditahkk
ditahkk merged commit 7839ab8 into zsoftly:main Aug 21, 2026
12 of 13 checks passed
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