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

Fix: Allow modifying NFS Export with valid zero values #186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions nfs_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ type NFSExportCreate struct {
type NFSExportModify struct {
// An optional description for the host.
// The description should not be more than 256 UTF-8 characters long and should not have any unprintable characters.
Description string `json:"description,omitempty"`
// Empty string is a valid description value, so omitempty should not be used.
Description string `json:"description"`

// Read-Write
// Hosts to add to the current read_write_hosts list. Hosts can be entered by Hostname, IP addresses
Expand Down Expand Up @@ -103,23 +104,30 @@ type NFSExportModify struct {
// NFS enforced security type for users accessing an NFS Export.
MinSecurity string `json:"min_security,omitempty"`
// Hosts with no access to the NFS export or its snapshots.
NoAccessHosts []string `json:"no_access_hosts,omitempty"`
// Empty list is a valid value, so omitempty should not be used.
NoAccessHosts []string `json:"no_access_hosts"`
Copy link
Contributor

@santhoshatdell santhoshatdell Mar 11, 2025

Choose a reason for hiding this comment

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

Hi,
For all the hosts list, there are 'add' and 'remove' lists in NFSExportModify. Could you check if you can make use of those fields to add or remove a host from the list during modify operation.?
Removing omitempty for these lists have an effect on other Client library users.

// Hosts with read-only access to the NFS export and its snapshots.
ReadOnlyHosts []string `json:"read_only_hosts,omitempty"`
// Empty list is a valid value, so omitempty should not be used.
ReadOnlyHosts []string `json:"read_only_hosts"`
// Hosts with read-only and read-only for root user access to the NFS Export and its snapshots.
ReadOnlyRootHosts []string `json:"read_only_root_hosts,omitempty"`
// Empty list is a valid value, so omitempty should not be used.
ReadOnlyRootHosts []string `json:"read_only_root_hosts"`
// Hosts with read and write access to the NFS export and its snapshots.
ReadWriteHosts []string `json:"read_write_hosts,omitempty"`
// Empty list is a valid value, so omitempty should not be used.
ReadWriteHosts []string `json:"read_write_hosts"`
// Hosts with read and write and read and write for root user access to the NFS Export and its snapshots.
ReadWriteRootHosts []string `json:"read_write_root_hosts,omitempty"`
// Empty list is a valid value, so omitempty should not be used.
ReadWriteRootHosts []string `json:"read_write_root_hosts"`
// Specifies the user ID of the anonymous account.
AnonymousUID int32 `json:"anonymous_UID,omitempty"`
// Zero ID is a valid value, so omitempty should not be used.
AnonymousUID int32 `json:"anonymous_UID"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if one can unset AnonymousUID and GID. If that is not allowed, let's not remove 'omitempty'.

// Specifies the group ID of the anonymous account.
AnonymousGID int32 `json:"anonymous_GID,omitempty"`
// Zero ID is a valid value, so omitempty should not be used.
AnonymousGID int32 `json:"anonymous_GID"`
// If set, do not allow access to set SUID. Otherwise, allow access.
IsNoSUID bool `json:"is_no_SUID"`
// (*Applies to NFS shares of VMware NFS storage resources.*) Default owner of the NFS Export associated with the datastore. Required if secure NFS enabled. For NFSv3 or NFSv4 without Kerberos, the default owner is root. Was added in version 3.0.0.0.
NFSOwnerUsername string `json:"nfs_owner_usernamestring,omitempty"`
NFSOwnerUsername string `json:"nfs_owner_username,omitempty"`
}

// NFSServerCreate details about creation of new NFS server
Expand Down