Skip to content

fix: Use pointers for integer fields in GTM, LTM, and Sys structs to support explicit zero values - #131

Open
waltzbucks wants to merge 1 commit into
f5devcentral:masterfrom
waltzbucks:issue#130
Open

fix: Use pointers for integer fields in GTM, LTM, and Sys structs to support explicit zero values#131
waltzbucks wants to merge 1 commit into
f5devcentral:masterfrom
waltzbucks:issue#130

Conversation

@waltzbucks

Copy link
Copy Markdown

Summary

This PR addresses an issue where integer fields with a value of 0 were being omitted from JSON payloads sent to the BIG-IP API
due to the omitempty struct tag. This behavior caused problems in newer BIG-IP versions where default values for certain fields
(like GTM pool member ratio) have changed from 0 to 1. By changing these fields from int to *int, the SDK can now distinguish
between a missing value (nil) and an explicit zero (0), ensuring the intended configuration is applied.

Problem

In recent BIG-IP versions (e.g., 11.6.1 HF1+), the default value for GTM pool member ratio changed to 1. When a user explicitly
set ratio = 0:

  1. The SDK saw 0 as the "Zero Value" for the int type.
  2. The omitempty tag caused the field to be removed from the JSON request.
  3. BIG-IP received the request without the ratio field and applied its internal default of 1.

This issue also affected other fields such as member_order, QoS settings, and LTM node/member ratios.

Changes

  • gtm.go:
    • Updated GtmPoolMembers struct: Ratio and MemberOrder changed to *int.

Impact

  • Users can now explicitly set 0 for these fields, and it will be correctly sent to the BIG-IP API.
  • This change is backward compatible for most use cases but improves stability across different BIG-IP versions.
  • Fixes issues where Terraform or other SDK consumers could not set certain values to zero.

Related Issue

(#130) Change GTM Pool Member Ratio to *int to support explicit 0 values

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.

1 participant