Skip to content

fix: change swap_size to pointer type and update related logic#418

Open
zliang-akamai wants to merge 4 commits intodevfrom
zhiwei/fix-swap-size-null
Open

fix: change swap_size to pointer type and update related logic#418
zliang-akamai wants to merge 4 commits intodevfrom
zhiwei/fix-swap-size-null

Conversation

@zliang-akamai
Copy link
Copy Markdown
Member

📝 Description

When swap_size is not configured, we should not include it in the request payload. Update it to be a pointer type to achieve it.

✔️ How to Test

make unit-test

@zliang-akamai zliang-akamai requested review from a team as code owners March 27, 2026 02:47
@zliang-akamai zliang-akamai requested review from dawiddzhafarov, jriddle-linode and psnoch-akamai and removed request for a team March 27, 2026 02:47
@zliang-akamai zliang-akamai added the bugfix for any bug fixes in the changelog. label Mar 27, 2026
@dawiddzhafarov
Copy link
Copy Markdown

Isn't that a breaking change?

Copy link
Copy Markdown
Contributor

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

Updates the Linode builder config so swap_size can be omitted from the Linode API request payload when not configured, aligning request behavior with optional configuration semantics.

Changes:

  • Changed Config.SwapSize from int to *int to distinguish “unset” vs “set to 0”.
  • Updated instance creation to pass SwapSize through as a pointer (allowing omission when nil).
  • Added unit tests and updated generated docs to reflect the new optional/pointer behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
builder/linode/step_create_linode.go Passes swap size as a pointer so it can be omitted when unset.
builder/linode/config.go Changes swap_size to *int and updates validation logic to handle nil safely.
builder/linode/builder_test.go Adds tests for swap_size omitted vs explicitly set to 0.
.web-docs/components/builder/linode/README.md Updates generated docs type display for swap_size.

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

zliang-akamai and others added 2 commits April 1, 2026 13:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@zliang-akamai zliang-akamai requested a review from Copilot April 1, 2026 20:16
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


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

`linode/debian13`, `linode/ubuntu24.04`, `linode/arch`, and `private/12345`.

- `swap_size` (int) - The disk size (MiB) allocated for swap space.
- `swap_size` (\*int) - The disk size (MiB) allocated for swap space.
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

The docs now show swap_size as (*int), which is a Go implementation detail and doesn’t reflect how users configure this field in Packer templates (they provide a number, not a pointer). Consider keeping the rendered type as int (and optionally adding a note that omitting swap_size will omit it from the API payload) so the documentation remains user-focused and consistent with the rest of the top-level config fields.

Suggested change
- `swap_size` (\*int) - The disk size (MiB) allocated for swap space.
- `swap_size` (int) - The disk size (MiB) allocated for swap space. If omitted, no swap size is sent in the API payload.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix for any bug fixes in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants