Skip to content

Commit 47c640f

Browse files
Updated non-pointer omitempty fields to be pointers (#681)
* Updated all omitempty fields to pointers * Removed pointers on list fields * Addressed PR comments
1 parent 8694525 commit 47c640f

File tree

88 files changed

+936
-888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+936
-888
lines changed

account.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,34 @@ type Account struct {
3434

3535
// AccountUpdateOptions fields are those accepted by UpdateAccount
3636
type AccountUpdateOptions struct {
37-
Address1 string `json:"address_1,omitempty"`
38-
Address2 string `json:"address_2,omitempty"`
39-
City string `json:"city,omitempty"`
40-
Company string `json:"company,omitempty"`
41-
Country string `json:"country,omitempty"`
42-
Email string `json:"email,omitempty"`
43-
FirstName string `json:"first_name,omitempty"`
44-
LastName string `json:"last_name,omitempty"`
45-
Phone string `json:"phone,omitempty"`
46-
State string `json:"state,omitempty"`
47-
TaxID string `json:"tax_id,omitempty"`
48-
Zip string `json:"zip,omitempty"`
37+
Address1 *string `json:"address_1,omitempty"`
38+
Address2 *string `json:"address_2,omitempty"`
39+
City *string `json:"city,omitempty"`
40+
Company *string `json:"company,omitempty"`
41+
Country *string `json:"country,omitempty"`
42+
Email *string `json:"email,omitempty"`
43+
FirstName *string `json:"first_name,omitempty"`
44+
LastName *string `json:"last_name,omitempty"`
45+
Phone *string `json:"phone,omitempty"`
46+
State *string `json:"state,omitempty"`
47+
TaxID *string `json:"tax_id,omitempty"`
48+
Zip *string `json:"zip,omitempty"`
4949
}
5050

5151
// GetUpdateOptions converts an Account to AccountUpdateOptions for use in UpdateAccount
5252
func (i Account) GetUpdateOptions() (o AccountUpdateOptions) {
53-
o.Address1 = i.Address1
54-
o.Address2 = i.Address2
55-
o.City = i.City
56-
o.Company = i.Company
57-
o.Country = i.Country
58-
o.Email = i.Email
59-
o.FirstName = i.FirstName
60-
o.LastName = i.LastName
61-
o.Phone = i.Phone
62-
o.State = i.State
63-
o.TaxID = i.TaxID
64-
o.Zip = i.Zip
53+
o.Address1 = &i.Address1
54+
o.Address2 = &i.Address2
55+
o.City = &i.City
56+
o.Company = &i.Company
57+
o.Country = &i.Country
58+
o.Email = &i.Email
59+
o.FirstName = &i.FirstName
60+
o.LastName = &i.LastName
61+
o.Phone = &i.Phone
62+
o.State = &i.State
63+
o.TaxID = &i.TaxID
64+
o.Zip = &i.Zip
6565

6666
return
6767
}

account_agreements.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ type AccountAgreements struct {
1111

1212
// AccountAgreementsUpdateOptions fields are those accepted by UpdateAccountAgreements
1313
type AccountAgreementsUpdateOptions struct {
14-
EUModel bool `json:"eu_model,omitempty"`
15-
MasterServiceAgreement bool `json:"master_service_agreement,omitempty"`
16-
PrivacyPolicy bool `json:"privacy_policy,omitempty"`
14+
EUModel *bool `json:"eu_model,omitempty"`
15+
MasterServiceAgreement *bool `json:"master_service_agreement,omitempty"`
16+
PrivacyPolicy *bool `json:"privacy_policy,omitempty"`
1717
}
1818

1919
// GetUpdateOptions converts an AccountAgreements to AccountAgreementsUpdateOptions for use in UpdateAccountAgreements
2020
func (i AccountAgreements) GetUpdateOptions() (o AccountAgreementsUpdateOptions) {
21-
o.EUModel = i.EUModel
22-
o.MasterServiceAgreement = i.MasterServiceAgreement
23-
o.PrivacyPolicy = i.PrivacyPolicy
21+
o.EUModel = copyBool(&i.EUModel)
22+
o.MasterServiceAgreement = copyBool(&i.MasterServiceAgreement)
23+
o.PrivacyPolicy = copyBool(&i.PrivacyPolicy)
2424

2525
return
2626
}

account_payments.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Payment struct {
2323
// PaymentCreateOptions fields are those accepted by CreatePayment
2424
type PaymentCreateOptions struct {
2525
// CVV (Card Verification Value) of the credit card to be used for the Payment
26-
CVV string `json:"cvv,omitempty"`
26+
CVV *string `json:"cvv,omitempty"`
2727

2828
// The amount, in US dollars, of the Payment
2929
USD json.Number `json:"usd"`

account_users.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ type UserCreateOptions struct {
4545

4646
// UserUpdateOptions fields are those accepted by UpdateUser
4747
type UserUpdateOptions struct {
48-
Username string `json:"username,omitempty"`
49-
Restricted *bool `json:"restricted,omitempty"`
50-
Email string `json:"email,omitempty"`
48+
Username *string `json:"username,omitempty"`
49+
Restricted *bool `json:"restricted,omitempty"`
50+
Email *string `json:"email,omitempty"`
5151
}
5252

5353
// UnmarshalJSON implements the json.Unmarshaler interface
@@ -101,9 +101,9 @@ func (i User) GetCreateOptions() (o UserCreateOptions) {
101101

102102
// GetUpdateOptions converts a User to UserUpdateOptions for use in UpdateUser
103103
func (i User) GetUpdateOptions() (o UserUpdateOptions) {
104-
o.Username = i.Username
104+
o.Username = &i.Username
105105
o.Restricted = copyBool(&i.Restricted)
106-
o.Email = i.Email
106+
o.Email = &i.Email
107107

108108
return
109109
}

databases.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ type Database struct {
9999

100100
// DatabaseHost for Primary/Secondary of Database
101101
type DatabaseHost struct {
102-
Primary string `json:"primary"`
103-
Secondary string `json:"secondary,omitempty"`
102+
Primary string `json:"primary"`
103+
Secondary *string `json:"secondary,omitempty"`
104104
}
105105

106106
// DatabaseEngine is information about Engines supported by Linode Managed Databases

domain_records.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ type DomainRecordCreateOptions struct {
3535
Port *int `json:"port,omitempty"`
3636
Service *string `json:"service,omitempty"`
3737
Protocol *string `json:"protocol,omitempty"`
38-
TTLSec int `json:"ttl_sec,omitempty"` // 0 is not accepted by Linode, so can be omitted
38+
TTLSec *int `json:"ttl_sec,omitempty"`
3939
Tag *string `json:"tag,omitempty"`
4040
}
4141

4242
// DomainRecordUpdateOptions fields are those accepted by UpdateDomainRecord
4343
type DomainRecordUpdateOptions struct {
44-
Type DomainRecordType `json:"type,omitempty"`
45-
Name string `json:"name,omitempty"`
46-
Target string `json:"target,omitempty"`
47-
Priority *int `json:"priority,omitempty"` // 0 is valid, so omit only nil values
48-
Weight *int `json:"weight,omitempty"` // 0 is valid, so omit only nil values
49-
Port *int `json:"port,omitempty"` // 0 is valid to spec, so omit only nil values
50-
Service *string `json:"service,omitempty"`
51-
Protocol *string `json:"protocol,omitempty"`
52-
TTLSec int `json:"ttl_sec,omitempty"` // 0 is not accepted by Linode, so can be omitted
53-
Tag *string `json:"tag,omitempty"`
44+
Type *DomainRecordType `json:"type,omitempty"`
45+
Name *string `json:"name,omitempty"`
46+
Target *string `json:"target,omitempty"`
47+
Priority *int `json:"priority,omitempty"`
48+
Weight *int `json:"weight,omitempty"`
49+
Port *int `json:"port,omitempty"`
50+
Service *string `json:"service,omitempty"`
51+
Protocol *string `json:"protocol,omitempty"`
52+
TTLSec *int `json:"ttl_sec,omitempty"`
53+
Tag *string `json:"tag,omitempty"`
5454
}
5555

5656
// DomainRecordType constants start with RecordType and include Linode API Domain Record Types
@@ -92,15 +92,15 @@ func (d *DomainRecord) UnmarshalJSON(b []byte) error {
9292

9393
// GetUpdateOptions converts a DomainRecord to DomainRecordUpdateOptions for use in UpdateDomainRecord
9494
func (d DomainRecord) GetUpdateOptions() (du DomainRecordUpdateOptions) {
95-
du.Type = d.Type
96-
du.Name = d.Name
97-
du.Target = d.Target
95+
du.Type = &d.Type
96+
du.Name = &d.Name
97+
du.Target = &d.Target
9898
du.Priority = copyInt(&d.Priority)
9999
du.Weight = copyInt(&d.Weight)
100100
du.Port = copyInt(&d.Port)
101101
du.Service = copyString(d.Service)
102102
du.Protocol = copyString(d.Protocol)
103-
du.TTLSec = d.TTLSec
103+
du.TTLSec = &d.TTLSec
104104
du.Tag = copyString(d.Tag)
105105

106106
return

domains.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,21 @@ type DomainCreateOptions struct {
6565
Type DomainType `json:"type"`
6666

6767
// Deprecated: The group this Domain belongs to. This is for display purposes only.
68-
Group string `json:"group,omitempty"`
68+
Group *string `json:"group,omitempty"`
6969

7070
// Used to control whether this Domain is currently being rendered.
7171
// Enum:"disabled" "active" "edit_mode" "has_errors"
72-
Status DomainStatus `json:"status,omitempty"`
72+
Status *DomainStatus `json:"status,omitempty"`
7373

7474
// A description for this Domain. This is for display purposes only.
75-
Description string `json:"description,omitempty"`
75+
Description *string `json:"description,omitempty"`
7676

7777
// Start of Authority email address. This is required for master Domains.
78-
SOAEmail string `json:"soa_email,omitempty"`
78+
SOAEmail *string `json:"soa_email,omitempty"`
7979

8080
// The interval, in seconds, at which a failed refresh should be retried.
8181
// Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
82-
RetrySec int `json:"retry_sec,omitempty"`
82+
RetrySec *int `json:"retry_sec,omitempty"`
8383

8484
// The IP addresses representing the master DNS for this Domain.
8585
MasterIPs []string `json:"master_ips"`
@@ -91,40 +91,40 @@ type DomainCreateOptions struct {
9191
Tags []string `json:"tags"`
9292

9393
// The amount of time in seconds that may pass before this Domain is no longer authoritative. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
94-
ExpireSec int `json:"expire_sec,omitempty"`
94+
ExpireSec *int `json:"expire_sec,omitempty"`
9595

9696
// The amount of time in seconds before this Domain should be refreshed. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
97-
RefreshSec int `json:"refresh_sec,omitempty"`
97+
RefreshSec *int `json:"refresh_sec,omitempty"`
9898

9999
// "Time to Live" - the amount of time in seconds that this Domain's records may be cached by resolvers or other domain servers. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
100-
TTLSec int `json:"ttl_sec,omitempty"`
100+
TTLSec *int `json:"ttl_sec,omitempty"`
101101
}
102102

103103
// DomainUpdateOptions converts a Domain to DomainUpdateOptions for use in UpdateDomain
104104
type DomainUpdateOptions struct {
105105
// The domain this Domain represents. These must be unique in our system; you cannot have two Domains representing the same domain.
106-
Domain string `json:"domain,omitempty"`
106+
Domain *string `json:"domain,omitempty"`
107107

108108
// If this Domain represents the authoritative source of information for the domain it describes, or if it is a read-only copy of a master (also called a slave).
109109
// Enum:"master" "slave"
110-
Type DomainType `json:"type,omitempty"`
110+
Type *DomainType `json:"type,omitempty"`
111111

112112
// Deprecated: The group this Domain belongs to. This is for display purposes only.
113-
Group string `json:"group,omitempty"`
113+
Group *string `json:"group,omitempty"`
114114

115115
// Used to control whether this Domain is currently being rendered.
116116
// Enum:"disabled" "active" "edit_mode" "has_errors"
117-
Status DomainStatus `json:"status,omitempty"`
117+
Status *DomainStatus `json:"status,omitempty"`
118118

119119
// A description for this Domain. This is for display purposes only.
120-
Description string `json:"description,omitempty"`
120+
Description *string `json:"description,omitempty"`
121121

122122
// Start of Authority email address. This is required for master Domains.
123-
SOAEmail string `json:"soa_email,omitempty"`
123+
SOAEmail *string `json:"soa_email,omitempty"`
124124

125125
// The interval, in seconds, at which a failed refresh should be retried.
126126
// Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
127-
RetrySec int `json:"retry_sec,omitempty"`
127+
RetrySec *int `json:"retry_sec,omitempty"`
128128

129129
// The IP addresses representing the master DNS for this Domain.
130130
MasterIPs []string `json:"master_ips"`
@@ -136,13 +136,13 @@ type DomainUpdateOptions struct {
136136
Tags []string `json:"tags"`
137137

138138
// The amount of time in seconds that may pass before this Domain is no longer authoritative. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
139-
ExpireSec int `json:"expire_sec,omitempty"`
139+
ExpireSec *int `json:"expire_sec,omitempty"`
140140

141141
// The amount of time in seconds before this Domain should be refreshed. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
142-
RefreshSec int `json:"refresh_sec,omitempty"`
142+
RefreshSec *int `json:"refresh_sec,omitempty"`
143143

144144
// "Time to Live" - the amount of time in seconds that this Domain's records may be cached by resolvers or other domain servers. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
145-
TTLSec int `json:"ttl_sec,omitempty"`
145+
TTLSec *int `json:"ttl_sec,omitempty"`
146146
}
147147

148148
// DomainType constants start with DomainType and include Linode API Domain Type values
@@ -176,19 +176,19 @@ type DomainImportOptions struct {
176176

177177
// GetUpdateOptions converts a Domain to DomainUpdateOptions for use in UpdateDomain
178178
func (d Domain) GetUpdateOptions() (du DomainUpdateOptions) {
179-
du.Domain = d.Domain
180-
du.Type = d.Type
181-
du.Group = d.Group
182-
du.Status = d.Status
183-
du.Description = d.Description
184-
du.SOAEmail = d.SOAEmail
185-
du.RetrySec = d.RetrySec
179+
du.Domain = &d.Domain
180+
du.Type = &d.Type
181+
du.Group = &d.Group
182+
du.Status = &d.Status
183+
du.Description = &d.Description
184+
du.SOAEmail = &d.SOAEmail
185+
du.RetrySec = &d.RetrySec
186186
du.MasterIPs = d.MasterIPs
187187
du.AXfrIPs = d.AXfrIPs
188188
du.Tags = d.Tags
189-
du.ExpireSec = d.ExpireSec
190-
du.RefreshSec = d.RefreshSec
191-
du.TTLSec = d.TTLSec
189+
du.ExpireSec = &d.ExpireSec
190+
du.RefreshSec = &d.RefreshSec
191+
du.TTLSec = &d.TTLSec
192192

193193
return
194194
}

firewall_rules.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ const (
1717

1818
// NetworkAddresses are arrays of ipv4 and v6 addresses
1919
type NetworkAddresses struct {
20-
IPv4 *[]string `json:"ipv4,omitempty"`
21-
IPv6 *[]string `json:"ipv6,omitempty"`
20+
IPv4 []string `json:"ipv4,omitempty"`
21+
IPv6 []string `json:"ipv6,omitempty"`
2222
}
2323

2424
// A FirewallRule is a whitelist of ports, protocols, and addresses for which traffic should be allowed.
2525
type FirewallRule struct {
2626
Action string `json:"action"`
2727
Label string `json:"label"`
28-
Description string `json:"description,omitempty"`
29-
Ports string `json:"ports,omitempty"`
28+
Description *string `json:"description,omitempty"`
29+
Ports *string `json:"ports,omitempty"`
3030
Protocol NetworkProtocol `json:"protocol"`
3131
Addresses NetworkAddresses `json:"addresses"`
3232
}

firewalls.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,25 @@ type DevicesCreationOptions struct {
3737

3838
// FirewallCreateOptions fields are those accepted by CreateFirewall
3939
type FirewallCreateOptions struct {
40-
Label string `json:"label,omitempty"`
41-
Rules FirewallRuleSet `json:"rules"`
42-
Tags []string `json:"tags,omitempty"`
43-
Devices DevicesCreationOptions `json:"devices,omitempty"`
40+
Label *string `json:"label,omitempty"`
41+
Rules FirewallRuleSet `json:"rules"`
42+
Tags []string `json:"tags,omitempty"`
43+
Devices *DevicesCreationOptions `json:"devices,omitempty"`
4444
}
4545

4646
// FirewallUpdateOptions is an options struct used when Updating a Firewall
4747
type FirewallUpdateOptions struct {
48-
Label string `json:"label,omitempty"`
49-
Status FirewallStatus `json:"status,omitempty"`
50-
Tags *[]string `json:"tags,omitempty"`
48+
Label *string `json:"label,omitempty"`
49+
Status *FirewallStatus `json:"status,omitempty"`
50+
Tags []string `json:"tags,omitempty"`
5151
}
5252

5353
// GetUpdateOptions converts a Firewall to FirewallUpdateOptions for use in Client.UpdateFirewall.
5454
func (f *Firewall) GetUpdateOptions() FirewallUpdateOptions {
5555
return FirewallUpdateOptions{
56-
Label: f.Label,
57-
Status: f.Status,
58-
Tags: &f.Tags,
56+
Label: &f.Label,
57+
Status: &f.Status,
58+
Tags: f.Tags,
5959
}
6060
}
6161

0 commit comments

Comments
 (0)