From f2219b4c1f6bf809d08391213f51f92995faae12 Mon Sep 17 00:00:00 2001 From: Lena Garber Date: Mon, 29 Apr 2024 13:31:04 -0400 Subject: [PATCH] Make enabled a *bool --- lke_clusters_acl.go | 2 +- .../fixtures/TestLKECluster_withACL.yaml | 26 +++++++++---------- test/integration/lke_clusters_acl_test.go | 12 +++++---- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/lke_clusters_acl.go b/lke_clusters_acl.go index e6c3646d4..74dda1d60 100644 --- a/lke_clusters_acl.go +++ b/lke_clusters_acl.go @@ -12,7 +12,7 @@ type LKEClusterControlPlaneACLAddresses struct { // LKEClusterControlPlaneACL describes the ACL configuration // for an LKE cluster's control plane. type LKEClusterControlPlaneACL struct { - Enabled bool `json:"enabled,omitempty"` + Enabled *bool `json:"enabled,omitempty"` Addresses *LKEClusterControlPlaneACLAddresses `json:"addresses,omitempty"` } diff --git a/test/integration/fixtures/TestLKECluster_withACL.yaml b/test/integration/fixtures/TestLKECluster_withACL.yaml index 690198c4c..24d2c2a83 100644 --- a/test/integration/fixtures/TestLKECluster_withACL.yaml +++ b/test/integration/fixtures/TestLKECluster_withACL.yaml @@ -269,7 +269,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 29 Apr 2024 17:01:06 GMT + - Mon, 29 Apr 2024 17:28:41 GMT Pragma: - no-cache Strict-Transport-Security: @@ -307,7 +307,7 @@ interactions: url: https://api.linode.com/v4beta/lke/clusters method: POST response: - body: '{"id": 173783, "status": "ready", "created": "2018-01-02T03:04:05", "updated": + body: '{"id": 173796, "status": "ready", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "label": "go-test-def", "region": "ap-west", "k8s_version": "1.29", "control_plane": {"high_availability": false}, "tags": ["testing"]}' headers: @@ -332,7 +332,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 29 Apr 2024 17:01:34 GMT + - Mon, 29 Apr 2024 17:29:09 GMT Pragma: - no-cache Strict-Transport-Security: @@ -365,7 +365,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/lke/clusters/173783/control_plane_acl + url: https://api.linode.com/v4beta/lke/clusters/173796/control_plane_acl method: GET response: body: '{"acl": {"enabled": true, "addresses": {"ipv4": ["10.0.0.1/32"], "ipv6": @@ -392,7 +392,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 29 Apr 2024 17:01:35 GMT + - Mon, 29 Apr 2024 17:29:10 GMT Pragma: - no-cache Strict-Transport-Security: @@ -426,7 +426,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/lke/clusters/173783/control_plane_acl + url: https://api.linode.com/v4beta/lke/clusters/173796/control_plane_acl method: PUT response: body: '{"acl": {"enabled": true, "addresses": {"ipv4": ["10.0.0.2/32"]}}}' @@ -452,7 +452,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 29 Apr 2024 17:01:38 GMT + - Mon, 29 Apr 2024 17:29:13 GMT Pragma: - no-cache Strict-Transport-Security: @@ -485,7 +485,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/lke/clusters/173783/control_plane_acl + url: https://api.linode.com/v4beta/lke/clusters/173796/control_plane_acl method: DELETE response: body: '{}' @@ -511,7 +511,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 29 Apr 2024 17:01:41 GMT + - Mon, 29 Apr 2024 17:29:15 GMT Pragma: - no-cache Strict-Transport-Security: @@ -544,7 +544,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/lke/clusters/173783/control_plane_acl + url: https://api.linode.com/v4beta/lke/clusters/173796/control_plane_acl method: GET response: body: '{"acl": {"enabled": false, "addresses": null}}' @@ -570,7 +570,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 29 Apr 2024 17:01:41 GMT + - Mon, 29 Apr 2024 17:29:16 GMT Pragma: - no-cache Strict-Transport-Security: @@ -604,7 +604,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/lke/clusters/173783 + url: https://api.linode.com/v4beta/lke/clusters/173796 method: DELETE response: body: '{}' @@ -630,7 +630,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 29 Apr 2024 17:02:04 GMT + - Mon, 29 Apr 2024 17:29:38 GMT Pragma: - no-cache Strict-Transport-Security: diff --git a/test/integration/lke_clusters_acl_test.go b/test/integration/lke_clusters_acl_test.go index 234e2d8b4..26cb1d907 100644 --- a/test/integration/lke_clusters_acl_test.go +++ b/test/integration/lke_clusters_acl_test.go @@ -11,13 +11,15 @@ import ( ) func TestLKECluster_withACL(t *testing.T) { + valueTrue := true + client, cluster, teardown, err := setupLKECluster( t, []clusterModifier{ func(options *linodego.LKEClusterCreateOptions) { options.ControlPlane = &linodego.LKEClusterControlPlane{ ACL: &linodego.LKEClusterControlPlaneACL{ - Enabled: true, + Enabled: &valueTrue, Addresses: &linodego.LKEClusterControlPlaneACLAddresses{ IPv4: []string{"10.0.0.1/32"}, IPv6: []string{"1234::5678"}, @@ -39,7 +41,7 @@ func TestLKECluster_withACL(t *testing.T) { acl, err := client.GetLKEClusterControlPlaneACL(context.Background(), cluster.ID) assert.NoError(t, err) - require.Equal(t, true, acl.ACL.Enabled) + require.Equal(t, true, *acl.ACL.Enabled) require.Equal(t, "10.0.0.1/32", acl.ACL.Addresses.IPv4[0]) require.Equal(t, "1234::5678/128", acl.ACL.Addresses.IPv6[0]) @@ -48,7 +50,7 @@ func TestLKECluster_withACL(t *testing.T) { cluster.ID, linodego.LKEClusterControlPlaneACLUpdateOptions{ ACL: linodego.LKEClusterControlPlaneACL{ - Enabled: true, + Enabled: &valueTrue, Addresses: &linodego.LKEClusterControlPlaneACLAddresses{ IPv4: []string{"10.0.0.2/32"}, IPv6: []string{}, @@ -58,7 +60,7 @@ func TestLKECluster_withACL(t *testing.T) { ) require.NoError(t, err) - require.Equal(t, true, acl.ACL.Enabled) + require.Equal(t, true, *acl.ACL.Enabled) require.Equal(t, "10.0.0.2/32", acl.ACL.Addresses.IPv4[0]) require.Equal(t, 0, len(acl.ACL.Addresses.IPv6)) @@ -68,5 +70,5 @@ func TestLKECluster_withACL(t *testing.T) { acl, err = client.GetLKEClusterControlPlaneACL(context.Background(), cluster.ID) assert.NoError(t, err) - assert.Equal(t, false, acl.ACL.Enabled) + assert.Equal(t, false, *acl.ACL.Enabled) }