Skip to content

Commit

Permalink
fix(acl): fix all relevant fields to be pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Nov 27, 2023
1 parent 114453a commit 317c408
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
14 changes: 7 additions & 7 deletions fastly/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
type ACL struct {
CreatedAt *time.Time `mapstructure:"created_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
ID string `mapstructure:"id"`
Name string `mapstructure:"name"`
ServiceID string `mapstructure:"service_id"`
ServiceVersion int `mapstructure:"version"`
ID *string `mapstructure:"id"`
Name *string `mapstructure:"name"`
ServiceID *string `mapstructure:"service_id"`
ServiceVersion *int `mapstructure:"version"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
}

Expand All @@ -33,7 +33,7 @@ func (s ACLsByName) Swap(i, j int) {

// Less implements the sortable interface.
func (s ACLsByName) Less(i, j int) bool {
return s[i].Name < s[j].Name
return *s[i].Name < *s[j].Name
}

// ListACLsInput is used as input to the ListACLs function.
Expand Down Expand Up @@ -70,7 +70,7 @@ func (c *Client) ListACLs(i *ListACLsInput) ([]*ACL, error) {

// CreateACLInput is used as input to the CreateACL function.
type CreateACLInput struct {
// Name is the name of the ACL to create (required)
// Name is the name of the ACL to create.
Name *string `url:"name,omitempty"`
// ServiceID is the ID of the service (required).
ServiceID string `url:"-"`
Expand Down Expand Up @@ -180,7 +180,7 @@ func (c *Client) GetACL(i *GetACLInput) (*ACL, error) {
type UpdateACLInput struct {
// Name is the name of the ACL to update (required).
Name string
// NewName is the new name of the ACL to update (required).
// NewName is the new name of the ACL to update.
NewName *string `url:"name,omitempty"`
// ServiceID is the ID of the service (required).
ServiceID string `url:"-"`
Expand Down
20 changes: 10 additions & 10 deletions fastly/acl_entries_batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestClient_BatchModifyACLEntries_Create(t *testing.T) {

batchCreateOperations := &BatchModifyACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
Entries: []*BatchACLEntry{
{
Operation: CreateBatchOperation,
Expand Down Expand Up @@ -53,7 +53,7 @@ func TestClient_BatchModifyACLEntries_Create(t *testing.T) {
record(t, fixtureBase+"list_after_create", func(c *Client) {
actualACLEntries, err = c.ListACLEntries(&ListACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
})
})
if err != nil {
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestClient_BatchModifyACLEntries_Delete(t *testing.T) {

batchCreateOperations := &BatchModifyACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
Entries: []*BatchACLEntry{
{
Operation: CreateBatchOperation,
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestClient_BatchModifyACLEntries_Delete(t *testing.T) {
record(t, fixtureBase+"list_before_delete", func(client *Client) {
createdACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
})
})
if err != nil {
Expand All @@ -161,7 +161,7 @@ func TestClient_BatchModifyACLEntries_Delete(t *testing.T) {
// When: I execute the batch delete operations against the Fastly API,
batchDeleteOperations := &BatchModifyACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
Entries: []*BatchACLEntry{
{
Operation: DeleteBatchOperation,
Expand All @@ -182,7 +182,7 @@ func TestClient_BatchModifyACLEntries_Delete(t *testing.T) {
record(t, fixtureBase+"list_after_delete", func(client *Client) {
actualACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
})
})
if err != nil {
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestClient_BatchModifyACLEntries_Update(t *testing.T) {

batchCreateOperations := &BatchModifyACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
Entries: []*BatchACLEntry{
{
Operation: CreateBatchOperation,
Expand Down Expand Up @@ -246,7 +246,7 @@ func TestClient_BatchModifyACLEntries_Update(t *testing.T) {
record(t, fixtureBase+"list_before_update", func(client *Client) {
createdACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
})
})
if err != nil {
Expand All @@ -260,7 +260,7 @@ func TestClient_BatchModifyACLEntries_Update(t *testing.T) {
// When: I execute the batch update operations against the Fastly API,
batchUpdateOperations := &BatchModifyACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
Entries: []*BatchACLEntry{
{
Operation: UpdateBatchOperation,
Expand All @@ -285,7 +285,7 @@ func TestClient_BatchModifyACLEntries_Update(t *testing.T) {
record(t, fixtureBase+"list_after_update", func(client *Client) {
actualACLEntries, err = client.ListACLEntries(&ListACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
})
})
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions fastly/acl_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestClient_ACLEntries(t *testing.T) {
record(t, fixtureBase+"create", func(c *Client) {
e, err = c.CreateACLEntry(&CreateACLEntryInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
IP: ToPointer("10.0.0.3"),
Subnet: ToPointer(8),
Negated: ToPointer(Compatibool(false)),
Expand Down Expand Up @@ -53,7 +53,7 @@ func TestClient_ACLEntries(t *testing.T) {
var es []*ACLEntry
record(t, fixtureBase+"list", func(c *Client) {
es, err = c.ListACLEntries(&ListACLEntriesInput{
ACLID: testACL.ID,
ACLID: *testACL.ID,
Direction: "descend",
Page: 1,
PerPage: 1,
Expand All @@ -75,7 +75,7 @@ func TestClient_ACLEntries(t *testing.T) {
record(t, fixtureBase+"list2", func(c *Client) {
paginator = c.NewListACLEntriesPaginator(&ListACLEntriesInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
})
es2, err = paginator.GetNext()
})
Expand All @@ -96,7 +96,7 @@ func TestClient_ACLEntries(t *testing.T) {
record(t, fixtureBase+"get", func(c *Client) {
ne, err = c.GetACLEntry(&GetACLEntryInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
ID: e.ID,
})
})
Expand All @@ -122,7 +122,7 @@ func TestClient_ACLEntries(t *testing.T) {
record(t, fixtureBase+"update", func(c *Client) {
ue, err = c.UpdateACLEntry(&UpdateACLEntryInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
ID: e.ID,
IP: ToPointer("10.0.0.4"),
Negated: ToPointer(Compatibool(true)),
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestClient_ACLEntries(t *testing.T) {
record(t, fixtureBase+"delete", func(c *Client) {
err = c.DeleteACLEntry(&DeleteACLEntryInput{
ServiceID: testService.ID,
ACLID: testACL.ID,
ACLID: *testACL.ID,
ID: e.ID,
})
})
Expand Down
16 changes: 8 additions & 8 deletions fastly/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func TestClient_ACLs(t *testing.T) {
})
}()

if a.Name != "test_acl" {
t.Errorf("bad name: %q", a.Name)
if *a.Name != "test_acl" {
t.Errorf("bad name: %q", *a.Name)
}

// List
Expand Down Expand Up @@ -85,8 +85,8 @@ func TestClient_ACLs(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if a.Name != na.Name {
t.Errorf("bad name: %q (%q)", a.Name, na.Name)
if *a.Name != *na.Name {
t.Errorf("bad name: %q (%q)", *a.Name, *na.Name)
}

// Update
Expand All @@ -102,12 +102,12 @@ func TestClient_ACLs(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if ua.Name != "new_test_acl" {
t.Errorf("Bad name after update %s", ua.Name)
if *ua.Name != "new_test_acl" {
t.Errorf("Bad name after update %s", *ua.Name)
}

if a.ID != ua.ID {
t.Errorf("bad ACL id: %q (%q)", a.ID, ua.ID)
if *a.ID != *ua.ID {
t.Errorf("bad ACL id: %q (%q)", *a.ID, *ua.ID)
}

// Delete
Expand Down
6 changes: 3 additions & 3 deletions fastly/fastly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ func deleteTestACL(t *testing.T, acl *ACL, deleteFixture string) {

record(t, deleteFixture, func(client *Client) {
err = client.DeleteACL(&DeleteACLInput{
ServiceID: acl.ServiceID,
ServiceVersion: acl.ServiceVersion,
Name: acl.Name,
ServiceID: *acl.ServiceID,
ServiceVersion: *acl.ServiceVersion,
Name: *acl.Name,
})
})
if err != nil {
Expand Down

0 comments on commit 317c408

Please sign in to comment.