Skip to content

Commit

Permalink
fix: marshal empty public IPs (#89)
Browse files Browse the repository at this point in the history
* feat: k8s node pool public ips supported

* fix: required false comment added

* fix: docs updated with the PublicIps KubernetesNodePoolProperties member

* fix: k8s unit test updated with publicIps, gofmt

* fix: docs updated - using PublicIPs instead of PublicIps

* fix: considering a missing publicIps field for being able to issue a PUT request

* fix: docs updated

* fix: useless pointer removed

* fix: redefining PublicIPs as pointer to allow omitempty to include empty arrays but exclude missing fields

* fix: checking for nil

Co-authored-by: Florin Mihalache <florin.mihalache@ionos.com>
Co-authored-by: Alex <1201551+pennycoders@users.noreply.github.com>
  • Loading branch information
3 people committed Dec 10, 2020
1 parent 3a396aa commit aa5a558
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,7 @@ GetResourceByType(resourcetype, resourceId)
| AutoScaling | no | [\*AutoScaling](#AutoScaling-resource-object) | Whether this Node Pool should autoscale. Comprised of a minimum and a maximum number of nodes |
| LANs | **no** | \*\[\][KubernetesNodePoolLAN](#KubernetesNodePoolLAN-Resource-Object) | A list of Local Area Networks the nodes in the pool should be a part of |
| MaintenanceWindow | **no** | [MaintenanceWindow](#MaintenanceWindow-resource-object) | An optional object with 2 keys: dayOfTheWeek and time. |
| PublicIPs | **no** | \[\]string | An optional array of strings with public IPs associated with the node pool. |
| PublicIPs | **no** | \*\[\]string | An optional array of strings with public IPs associated with the node pool. |
### Create Cluster
Expand Down
2 changes: 1 addition & 1 deletion k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ type KubernetesNodePoolProperties struct {

// Public Ips
// Required: false
PublicIPs []string `json:"publicIps,omitempty"`
PublicIPs *[]string `json:"publicIps,omitempty"`
}

type KubernetesNodePools struct {
Expand Down
5 changes: 4 additions & 1 deletion k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ func (s *SuiteKubernetesCluster) Test_GetKubernetesNodepool() {
s.NotEmpty(np.Properties.StorageType)
s.NotEmpty(np.Properties.AutoScaling)
s.NotEmpty(np.Properties.MaintenanceWindow)
s.Len(np.Properties.PublicIPs, 3)
if s.NotNil(np.Properties.PublicIPs) {
s.Len(*np.Properties.PublicIPs, 3)
}

}

func (s *SuiteKubernetesCluster) Test_ListKubernetesNodes() {
Expand Down

0 comments on commit aa5a558

Please sign in to comment.