diff --git a/account.go b/account.go index a743e7785..c47663cf0 100644 --- a/account.go +++ b/account.go @@ -34,34 +34,34 @@ type Account struct { // AccountUpdateOptions fields are those accepted by UpdateAccount type AccountUpdateOptions struct { - Address1 string `json:"address_1,omitempty"` - Address2 string `json:"address_2,omitempty"` - City string `json:"city,omitempty"` - Company string `json:"company,omitempty"` - Country string `json:"country,omitempty"` - Email string `json:"email,omitempty"` - FirstName string `json:"first_name,omitempty"` - LastName string `json:"last_name,omitempty"` - Phone string `json:"phone,omitempty"` - State string `json:"state,omitempty"` - TaxID string `json:"tax_id,omitempty"` - Zip string `json:"zip,omitempty"` + Address1 *string `json:"address_1,omitempty"` + Address2 *string `json:"address_2,omitempty"` + City *string `json:"city,omitempty"` + Company *string `json:"company,omitempty"` + Country *string `json:"country,omitempty"` + Email *string `json:"email,omitempty"` + FirstName *string `json:"first_name,omitempty"` + LastName *string `json:"last_name,omitempty"` + Phone *string `json:"phone,omitempty"` + State *string `json:"state,omitempty"` + TaxID *string `json:"tax_id,omitempty"` + Zip *string `json:"zip,omitempty"` } // GetUpdateOptions converts an Account to AccountUpdateOptions for use in UpdateAccount func (i Account) GetUpdateOptions() (o AccountUpdateOptions) { - o.Address1 = i.Address1 - o.Address2 = i.Address2 - o.City = i.City - o.Company = i.Company - o.Country = i.Country - o.Email = i.Email - o.FirstName = i.FirstName - o.LastName = i.LastName - o.Phone = i.Phone - o.State = i.State - o.TaxID = i.TaxID - o.Zip = i.Zip + o.Address1 = &i.Address1 + o.Address2 = &i.Address2 + o.City = &i.City + o.Company = &i.Company + o.Country = &i.Country + o.Email = &i.Email + o.FirstName = &i.FirstName + o.LastName = &i.LastName + o.Phone = &i.Phone + o.State = &i.State + o.TaxID = &i.TaxID + o.Zip = &i.Zip return } diff --git a/account_agreements.go b/account_agreements.go index d7437b4aa..be9f498e5 100644 --- a/account_agreements.go +++ b/account_agreements.go @@ -11,16 +11,16 @@ type AccountAgreements struct { // AccountAgreementsUpdateOptions fields are those accepted by UpdateAccountAgreements type AccountAgreementsUpdateOptions struct { - EUModel bool `json:"eu_model,omitempty"` - MasterServiceAgreement bool `json:"master_service_agreement,omitempty"` - PrivacyPolicy bool `json:"privacy_policy,omitempty"` + EUModel *bool `json:"eu_model,omitempty"` + MasterServiceAgreement *bool `json:"master_service_agreement,omitempty"` + PrivacyPolicy *bool `json:"privacy_policy,omitempty"` } // GetUpdateOptions converts an AccountAgreements to AccountAgreementsUpdateOptions for use in UpdateAccountAgreements func (i AccountAgreements) GetUpdateOptions() (o AccountAgreementsUpdateOptions) { - o.EUModel = i.EUModel - o.MasterServiceAgreement = i.MasterServiceAgreement - o.PrivacyPolicy = i.PrivacyPolicy + o.EUModel = copyBool(&i.EUModel) + o.MasterServiceAgreement = copyBool(&i.MasterServiceAgreement) + o.PrivacyPolicy = copyBool(&i.PrivacyPolicy) return } diff --git a/account_payments.go b/account_payments.go index 57be4aa68..ffdde4f53 100644 --- a/account_payments.go +++ b/account_payments.go @@ -23,7 +23,7 @@ type Payment struct { // PaymentCreateOptions fields are those accepted by CreatePayment type PaymentCreateOptions struct { // CVV (Card Verification Value) of the credit card to be used for the Payment - CVV string `json:"cvv,omitempty"` + CVV *string `json:"cvv,omitempty"` // The amount, in US dollars, of the Payment USD json.Number `json:"usd"` diff --git a/account_users.go b/account_users.go index 594fedfed..9bfe33557 100644 --- a/account_users.go +++ b/account_users.go @@ -45,9 +45,9 @@ type UserCreateOptions struct { // UserUpdateOptions fields are those accepted by UpdateUser type UserUpdateOptions struct { - Username string `json:"username,omitempty"` - Restricted *bool `json:"restricted,omitempty"` - Email string `json:"email,omitempty"` + Username *string `json:"username,omitempty"` + Restricted *bool `json:"restricted,omitempty"` + Email *string `json:"email,omitempty"` } // UnmarshalJSON implements the json.Unmarshaler interface @@ -101,9 +101,9 @@ func (i User) GetCreateOptions() (o UserCreateOptions) { // GetUpdateOptions converts a User to UserUpdateOptions for use in UpdateUser func (i User) GetUpdateOptions() (o UserUpdateOptions) { - o.Username = i.Username + o.Username = &i.Username o.Restricted = copyBool(&i.Restricted) - o.Email = i.Email + o.Email = &i.Email return } diff --git a/databases.go b/databases.go index b38935fa6..8d59305c0 100644 --- a/databases.go +++ b/databases.go @@ -99,8 +99,8 @@ type Database struct { // DatabaseHost for Primary/Secondary of Database type DatabaseHost struct { - Primary string `json:"primary"` - Secondary string `json:"secondary,omitempty"` + Primary string `json:"primary"` + Secondary *string `json:"secondary,omitempty"` } // DatabaseEngine is information about Engines supported by Linode Managed Databases diff --git a/domain_records.go b/domain_records.go index 073dccb8e..2c4f78ab3 100644 --- a/domain_records.go +++ b/domain_records.go @@ -35,22 +35,22 @@ type DomainRecordCreateOptions struct { Port *int `json:"port,omitempty"` Service *string `json:"service,omitempty"` Protocol *string `json:"protocol,omitempty"` - TTLSec int `json:"ttl_sec,omitempty"` // 0 is not accepted by Linode, so can be omitted + TTLSec *int `json:"ttl_sec,omitempty"` Tag *string `json:"tag,omitempty"` } // DomainRecordUpdateOptions fields are those accepted by UpdateDomainRecord type DomainRecordUpdateOptions struct { - Type DomainRecordType `json:"type,omitempty"` - Name string `json:"name,omitempty"` - Target string `json:"target,omitempty"` - Priority *int `json:"priority,omitempty"` // 0 is valid, so omit only nil values - Weight *int `json:"weight,omitempty"` // 0 is valid, so omit only nil values - Port *int `json:"port,omitempty"` // 0 is valid to spec, so omit only nil values - Service *string `json:"service,omitempty"` - Protocol *string `json:"protocol,omitempty"` - TTLSec int `json:"ttl_sec,omitempty"` // 0 is not accepted by Linode, so can be omitted - Tag *string `json:"tag,omitempty"` + Type *DomainRecordType `json:"type,omitempty"` + Name *string `json:"name,omitempty"` + Target *string `json:"target,omitempty"` + Priority *int `json:"priority,omitempty"` + Weight *int `json:"weight,omitempty"` + Port *int `json:"port,omitempty"` + Service *string `json:"service,omitempty"` + Protocol *string `json:"protocol,omitempty"` + TTLSec *int `json:"ttl_sec,omitempty"` + Tag *string `json:"tag,omitempty"` } // DomainRecordType constants start with RecordType and include Linode API Domain Record Types @@ -92,15 +92,15 @@ func (d *DomainRecord) UnmarshalJSON(b []byte) error { // GetUpdateOptions converts a DomainRecord to DomainRecordUpdateOptions for use in UpdateDomainRecord func (d DomainRecord) GetUpdateOptions() (du DomainRecordUpdateOptions) { - du.Type = d.Type - du.Name = d.Name - du.Target = d.Target + du.Type = &d.Type + du.Name = &d.Name + du.Target = &d.Target du.Priority = copyInt(&d.Priority) du.Weight = copyInt(&d.Weight) du.Port = copyInt(&d.Port) du.Service = copyString(d.Service) du.Protocol = copyString(d.Protocol) - du.TTLSec = d.TTLSec + du.TTLSec = &d.TTLSec du.Tag = copyString(d.Tag) return diff --git a/domains.go b/domains.go index 7e04b4eed..8f69665a9 100644 --- a/domains.go +++ b/domains.go @@ -65,21 +65,21 @@ type DomainCreateOptions struct { Type DomainType `json:"type"` // Deprecated: The group this Domain belongs to. This is for display purposes only. - Group string `json:"group,omitempty"` + Group *string `json:"group,omitempty"` // Used to control whether this Domain is currently being rendered. // Enum:"disabled" "active" "edit_mode" "has_errors" - Status DomainStatus `json:"status,omitempty"` + Status *DomainStatus `json:"status,omitempty"` // A description for this Domain. This is for display purposes only. - Description string `json:"description,omitempty"` + Description *string `json:"description,omitempty"` // Start of Authority email address. This is required for master Domains. - SOAEmail string `json:"soa_email,omitempty"` + SOAEmail *string `json:"soa_email,omitempty"` // The interval, in seconds, at which a failed refresh should be retried. // 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. - RetrySec int `json:"retry_sec,omitempty"` + RetrySec *int `json:"retry_sec,omitempty"` // The IP addresses representing the master DNS for this Domain. MasterIPs []string `json:"master_ips"` @@ -91,40 +91,40 @@ type DomainCreateOptions struct { Tags []string `json:"tags"` // 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. - ExpireSec int `json:"expire_sec,omitempty"` + ExpireSec *int `json:"expire_sec,omitempty"` // 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. - RefreshSec int `json:"refresh_sec,omitempty"` + RefreshSec *int `json:"refresh_sec,omitempty"` // "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. - TTLSec int `json:"ttl_sec,omitempty"` + TTLSec *int `json:"ttl_sec,omitempty"` } // DomainUpdateOptions converts a Domain to DomainUpdateOptions for use in UpdateDomain type DomainUpdateOptions struct { // The domain this Domain represents. These must be unique in our system; you cannot have two Domains representing the same domain. - Domain string `json:"domain,omitempty"` + Domain *string `json:"domain,omitempty"` // 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). // Enum:"master" "slave" - Type DomainType `json:"type,omitempty"` + Type *DomainType `json:"type,omitempty"` // Deprecated: The group this Domain belongs to. This is for display purposes only. - Group string `json:"group,omitempty"` + Group *string `json:"group,omitempty"` // Used to control whether this Domain is currently being rendered. // Enum:"disabled" "active" "edit_mode" "has_errors" - Status DomainStatus `json:"status,omitempty"` + Status *DomainStatus `json:"status,omitempty"` // A description for this Domain. This is for display purposes only. - Description string `json:"description,omitempty"` + Description *string `json:"description,omitempty"` // Start of Authority email address. This is required for master Domains. - SOAEmail string `json:"soa_email,omitempty"` + SOAEmail *string `json:"soa_email,omitempty"` // The interval, in seconds, at which a failed refresh should be retried. // 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. - RetrySec int `json:"retry_sec,omitempty"` + RetrySec *int `json:"retry_sec,omitempty"` // The IP addresses representing the master DNS for this Domain. MasterIPs []string `json:"master_ips"` @@ -136,13 +136,13 @@ type DomainUpdateOptions struct { Tags []string `json:"tags"` // 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. - ExpireSec int `json:"expire_sec,omitempty"` + ExpireSec *int `json:"expire_sec,omitempty"` // 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. - RefreshSec int `json:"refresh_sec,omitempty"` + RefreshSec *int `json:"refresh_sec,omitempty"` // "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. - TTLSec int `json:"ttl_sec,omitempty"` + TTLSec *int `json:"ttl_sec,omitempty"` } // DomainType constants start with DomainType and include Linode API Domain Type values @@ -176,19 +176,19 @@ type DomainImportOptions struct { // GetUpdateOptions converts a Domain to DomainUpdateOptions for use in UpdateDomain func (d Domain) GetUpdateOptions() (du DomainUpdateOptions) { - du.Domain = d.Domain - du.Type = d.Type - du.Group = d.Group - du.Status = d.Status - du.Description = d.Description - du.SOAEmail = d.SOAEmail - du.RetrySec = d.RetrySec + du.Domain = &d.Domain + du.Type = &d.Type + du.Group = &d.Group + du.Status = &d.Status + du.Description = &d.Description + du.SOAEmail = &d.SOAEmail + du.RetrySec = &d.RetrySec du.MasterIPs = d.MasterIPs du.AXfrIPs = d.AXfrIPs du.Tags = d.Tags - du.ExpireSec = d.ExpireSec - du.RefreshSec = d.RefreshSec - du.TTLSec = d.TTLSec + du.ExpireSec = &d.ExpireSec + du.RefreshSec = &d.RefreshSec + du.TTLSec = &d.TTLSec return } diff --git a/firewall_rules.go b/firewall_rules.go index e36d8e41f..8c74b084a 100644 --- a/firewall_rules.go +++ b/firewall_rules.go @@ -17,16 +17,16 @@ const ( // NetworkAddresses are arrays of ipv4 and v6 addresses type NetworkAddresses struct { - IPv4 *[]string `json:"ipv4,omitempty"` - IPv6 *[]string `json:"ipv6,omitempty"` + IPv4 []string `json:"ipv4,omitempty"` + IPv6 []string `json:"ipv6,omitempty"` } // A FirewallRule is a whitelist of ports, protocols, and addresses for which traffic should be allowed. type FirewallRule struct { Action string `json:"action"` Label string `json:"label"` - Description string `json:"description,omitempty"` - Ports string `json:"ports,omitempty"` + Description *string `json:"description,omitempty"` + Ports *string `json:"ports,omitempty"` Protocol NetworkProtocol `json:"protocol"` Addresses NetworkAddresses `json:"addresses"` } diff --git a/firewalls.go b/firewalls.go index 4eb35dd60..aee7686e0 100644 --- a/firewalls.go +++ b/firewalls.go @@ -37,25 +37,25 @@ type DevicesCreationOptions struct { // FirewallCreateOptions fields are those accepted by CreateFirewall type FirewallCreateOptions struct { - Label string `json:"label,omitempty"` - Rules FirewallRuleSet `json:"rules"` - Tags []string `json:"tags,omitempty"` - Devices DevicesCreationOptions `json:"devices,omitempty"` + Label *string `json:"label,omitempty"` + Rules FirewallRuleSet `json:"rules"` + Tags []string `json:"tags,omitempty"` + Devices *DevicesCreationOptions `json:"devices,omitempty"` } // FirewallUpdateOptions is an options struct used when Updating a Firewall type FirewallUpdateOptions struct { - Label string `json:"label,omitempty"` - Status FirewallStatus `json:"status,omitempty"` - Tags *[]string `json:"tags,omitempty"` + Label *string `json:"label,omitempty"` + Status *FirewallStatus `json:"status,omitempty"` + Tags []string `json:"tags,omitempty"` } // GetUpdateOptions converts a Firewall to FirewallUpdateOptions for use in Client.UpdateFirewall. func (f *Firewall) GetUpdateOptions() FirewallUpdateOptions { return FirewallUpdateOptions{ - Label: f.Label, - Status: f.Status, - Tags: &f.Tags, + Label: &f.Label, + Status: &f.Status, + Tags: f.Tags, } } diff --git a/images.go b/images.go index dd8074f6f..7c413d939 100644 --- a/images.go +++ b/images.go @@ -67,14 +67,14 @@ type Image struct { type ImageCreateOptions struct { DiskID int `json:"disk_id"` Label string `json:"label"` - Description string `json:"description,omitempty"` - CloudInit bool `json:"cloud_init,omitempty"` + Description *string `json:"description,omitempty"` + CloudInit *bool `json:"cloud_init,omitempty"` Tags *[]string `json:"tags,omitempty"` } // ImageUpdateOptions fields are those accepted by UpdateImage type ImageUpdateOptions struct { - Label string `json:"label,omitempty"` + Label *string `json:"label,omitempty"` Description *string `json:"description,omitempty"` Tags *[]string `json:"tags,omitempty"` } @@ -95,8 +95,8 @@ type ImageCreateUploadResponse struct { type ImageCreateUploadOptions struct { Region string `json:"region"` Label string `json:"label"` - Description string `json:"description,omitempty"` - CloudInit bool `json:"cloud_init,omitempty"` + Description *string `json:"description,omitempty"` + CloudInit *bool `json:"cloud_init,omitempty"` Tags *[]string `json:"tags,omitempty"` } @@ -104,7 +104,7 @@ type ImageCreateUploadOptions struct { type ImageUploadOptions struct { Region string `json:"region"` Label string `json:"label"` - Description string `json:"description,omitempty"` + Description *string `json:"description,omitempty"` CloudInit bool `json:"cloud_init"` Tags *[]string `json:"tags,omitempty"` Image io.Reader @@ -138,7 +138,7 @@ func (i *Image) UnmarshalJSON(b []byte) error { // GetUpdateOptions converts an Image to ImageUpdateOptions for use in UpdateImage func (i Image) GetUpdateOptions() (iu ImageUpdateOptions) { - iu.Label = i.Label + iu.Label = &i.Label iu.Description = copyString(&i.Description) return } @@ -265,7 +265,7 @@ func (c *Client) UploadImage(ctx context.Context, opts ImageUploadOptions) (*Ima Label: opts.Label, Region: opts.Region, Description: opts.Description, - CloudInit: opts.CloudInit, + CloudInit: &opts.CloudInit, Tags: opts.Tags, }) if err != nil { diff --git a/instance_config_interfaces.go b/instance_config_interfaces.go index b662d1a0a..3d14aa482 100644 --- a/instance_config_interfaces.go +++ b/instance_config_interfaces.go @@ -19,24 +19,24 @@ type InstanceConfigInterface struct { } type VPCIPv4 struct { - VPC string `json:"vpc,omitempty"` + VPC *string `json:"vpc,omitempty"` NAT1To1 *string `json:"nat_1_1,omitempty"` } type InstanceConfigInterfaceCreateOptions struct { - IPAMAddress string `json:"ipam_address,omitempty"` - Label string `json:"label,omitempty"` - Purpose ConfigInterfacePurpose `json:"purpose,omitempty"` - Primary bool `json:"primary,omitempty"` - SubnetID *int `json:"subnet_id,omitempty"` - IPv4 *VPCIPv4 `json:"ipv4,omitempty"` - IPRanges []string `json:"ip_ranges,omitempty"` + IPAMAddress *string `json:"ipam_address,omitempty"` + Label *string `json:"label,omitempty"` + Purpose *ConfigInterfacePurpose `json:"purpose,omitempty"` + Primary *bool `json:"primary,omitempty"` + SubnetID *int `json:"subnet_id,omitempty"` + IPv4 *VPCIPv4 `json:"ipv4,omitempty"` + IPRanges []string `json:"ip_ranges,omitempty"` } type InstanceConfigInterfaceUpdateOptions struct { - Primary bool `json:"primary,omitempty"` - IPv4 *VPCIPv4 `json:"ipv4,omitempty"` - IPRanges *[]string `json:"ip_ranges,omitempty"` + Primary *bool `json:"primary,omitempty"` + IPv4 *VPCIPv4 `json:"ipv4,omitempty"` + IPRanges []string `json:"ip_ranges,omitempty"` } type InstanceConfigInterfacesReorderOptions struct { @@ -55,9 +55,9 @@ func getInstanceConfigInterfacesCreateOptionsList( func (i InstanceConfigInterface) GetCreateOptions() InstanceConfigInterfaceCreateOptions { opts := InstanceConfigInterfaceCreateOptions{ - Label: i.Label, - Purpose: i.Purpose, - Primary: i.Primary, + Label: &i.Label, + Purpose: &i.Purpose, + Primary: &i.Primary, SubnetID: i.SubnetID, } @@ -72,14 +72,14 @@ func (i InstanceConfigInterface) GetCreateOptions() InstanceConfigInterfaceCreat } } - opts.IPAMAddress = i.IPAMAddress + opts.IPAMAddress = &i.IPAMAddress return opts } func (i InstanceConfigInterface) GetUpdateOptions() InstanceConfigInterfaceUpdateOptions { opts := InstanceConfigInterfaceUpdateOptions{ - Primary: i.Primary, + Primary: &i.Primary, } if i.Purpose == InterfacePurposeVPC && i.IPv4 != nil { @@ -95,7 +95,7 @@ func (i InstanceConfigInterface) GetUpdateOptions() InstanceConfigInterfaceUpdat copiedIPRanges := make([]string, len(i.IPRanges)) copy(copiedIPRanges, i.IPRanges) - opts.IPRanges = &copiedIPRanges + opts.IPRanges = copiedIPRanges } return opts diff --git a/instance_configs.go b/instance_configs.go index 3925f58d2..e06ea5d9b 100644 --- a/instance_configs.go +++ b/instance_configs.go @@ -28,8 +28,8 @@ type InstanceConfig struct { // InstanceConfigDevice contains either the DiskID or VolumeID assigned to a Config Device type InstanceConfigDevice struct { - DiskID int `json:"disk_id,omitempty"` - VolumeID int `json:"volume_id,omitempty"` + DiskID *int `json:"disk_id,omitempty"` + VolumeID *int `json:"volume_id,omitempty"` } // InstanceConfigDeviceMap contains SDA-SDH InstanceConfigDevice settings @@ -64,34 +64,34 @@ const ( // InstanceConfigCreateOptions are InstanceConfig settings that can be used at creation type InstanceConfigCreateOptions struct { - Label string `json:"label,omitempty"` - Comments string `json:"comments,omitempty"` + Label *string `json:"label,omitempty"` + Comments *string `json:"comments,omitempty"` Devices InstanceConfigDeviceMap `json:"devices"` Helpers *InstanceConfigHelpers `json:"helpers,omitempty"` Interfaces []InstanceConfigInterfaceCreateOptions `json:"interfaces"` - MemoryLimit int `json:"memory_limit,omitempty"` - Kernel string `json:"kernel,omitempty"` - InitRD int `json:"init_rd,omitempty"` + MemoryLimit *int `json:"memory_limit,omitempty"` + Kernel *string `json:"kernel,omitempty"` + InitRD *int `json:"init_rd,omitempty"` RootDevice *string `json:"root_device,omitempty"` - RunLevel string `json:"run_level,omitempty"` - VirtMode string `json:"virt_mode,omitempty"` + RunLevel *string `json:"run_level,omitempty"` + VirtMode *string `json:"virt_mode,omitempty"` } // InstanceConfigUpdateOptions are InstanceConfig settings that can be used in updates type InstanceConfigUpdateOptions struct { - Label string `json:"label,omitempty"` + Label *string `json:"label,omitempty"` Comments string `json:"comments"` Devices *InstanceConfigDeviceMap `json:"devices,omitempty"` Helpers *InstanceConfigHelpers `json:"helpers,omitempty"` Interfaces []InstanceConfigInterfaceCreateOptions `json:"interfaces"` // MemoryLimit 0 means unlimitted, this is not omitted - MemoryLimit int `json:"memory_limit"` - Kernel string `json:"kernel,omitempty"` + MemoryLimit int `json:"memory_limit"` + Kernel *string `json:"kernel,omitempty"` // InitRD is nullable, permit the sending of null - InitRD *int `json:"init_rd"` - RootDevice string `json:"root_device,omitempty"` - RunLevel string `json:"run_level,omitempty"` - VirtMode string `json:"virt_mode,omitempty"` + InitRD *int `json:"init_rd"` + RootDevice *string `json:"root_device,omitempty"` + RunLevel *string `json:"run_level,omitempty"` + VirtMode *string `json:"virt_mode,omitempty"` } // UnmarshalJSON implements the json.Unmarshaler interface @@ -123,34 +123,34 @@ func (i InstanceConfig) GetCreateOptions() InstanceConfigCreateOptions { initrd = *i.InitRD } return InstanceConfigCreateOptions{ - Label: i.Label, - Comments: i.Comments, + Label: &i.Label, + Comments: &i.Comments, Devices: *i.Devices, Helpers: i.Helpers, Interfaces: getInstanceConfigInterfacesCreateOptionsList(i.Interfaces), - MemoryLimit: i.MemoryLimit, - Kernel: i.Kernel, - InitRD: initrd, + MemoryLimit: &i.MemoryLimit, + Kernel: &i.Kernel, + InitRD: &initrd, RootDevice: copyString(&i.RootDevice), - RunLevel: i.RunLevel, - VirtMode: i.VirtMode, + RunLevel: &i.RunLevel, + VirtMode: &i.VirtMode, } } // GetUpdateOptions converts a InstanceConfig to InstanceConfigUpdateOptions for use in UpdateInstanceConfig func (i InstanceConfig) GetUpdateOptions() InstanceConfigUpdateOptions { return InstanceConfigUpdateOptions{ - Label: i.Label, + Label: &i.Label, Comments: i.Comments, Devices: i.Devices, Helpers: i.Helpers, Interfaces: getInstanceConfigInterfacesCreateOptionsList(i.Interfaces), MemoryLimit: i.MemoryLimit, - Kernel: i.Kernel, + Kernel: &i.Kernel, InitRD: copyInt(i.InitRD), - RootDevice: i.RootDevice, - RunLevel: i.RunLevel, - VirtMode: i.VirtMode, + RootDevice: &i.RootDevice, + RunLevel: &i.RunLevel, + VirtMode: &i.VirtMode, } } @@ -179,7 +179,7 @@ func (c *Client) UpdateInstanceConfig(ctx context.Context, linodeID int, configI // RenameInstanceConfig renames an InstanceConfig func (c *Client) RenameInstanceConfig(ctx context.Context, linodeID int, configID int, label string) (*InstanceConfig, error) { - return c.UpdateInstanceConfig(ctx, linodeID, configID, InstanceConfigUpdateOptions{Label: label}) + return c.UpdateInstanceConfig(ctx, linodeID, configID, InstanceConfigUpdateOptions{Label: &label}) } // DeleteInstanceConfig deletes a Linode InstanceConfig diff --git a/instance_disks.go b/instance_disks.go index 2531bdd69..e52baeda9 100644 --- a/instance_disks.go +++ b/instance_disks.go @@ -50,13 +50,13 @@ type InstanceDiskCreateOptions struct { Size int `json:"size"` // Image is optional, but requires RootPass if provided - Image string `json:"image,omitempty"` - RootPass string `json:"root_pass,omitempty"` + Image *string `json:"image,omitempty"` + RootPass *string `json:"root_pass,omitempty"` - Filesystem string `json:"filesystem,omitempty"` + Filesystem *string `json:"filesystem,omitempty"` AuthorizedKeys []string `json:"authorized_keys,omitempty"` AuthorizedUsers []string `json:"authorized_users,omitempty"` - StackscriptID int `json:"stackscript_id,omitempty"` + StackscriptID *int `json:"stackscript_id,omitempty"` StackscriptData map[string]string `json:"stackscript_data,omitempty"` } diff --git a/instances.go b/instances.go index 00e810836..081c4b939 100644 --- a/instances.go +++ b/instances.go @@ -91,12 +91,12 @@ type InstanceAlert struct { // InstanceBackup represents backup settings for an instance type InstanceBackup struct { - Available bool `json:"available,omitempty"` // read-only - Enabled bool `json:"enabled,omitempty"` // read-only + Available *bool `json:"available,omitempty"` // read-only + Enabled *bool `json:"enabled,omitempty"` // read-only LastSuccessful *time.Time `json:"-"` // read-only - Schedule struct { - Day string `json:"day,omitempty"` - Window string `json:"window,omitempty"` + Schedule *struct { + Day *string `json:"day,omitempty"` + Window *string `json:"window,omitempty"` } `json:"schedule,omitempty"` } @@ -145,7 +145,7 @@ type InstancePlacementGroup struct { // that relate to the Linode Metadata service. type InstanceMetadataOptions struct { // UserData expects a Base64-encoded string - UserData string `json:"user_data,omitempty"` + UserData *string `json:"user_data,omitempty"` } // InstancePasswordResetOptions specifies the new password for the Linode @@ -157,23 +157,23 @@ type InstancePasswordResetOptions struct { type InstanceCreateOptions struct { Region string `json:"region"` Type string `json:"type"` - Label string `json:"label,omitempty"` - RootPass string `json:"root_pass,omitempty"` + Label *string `json:"label,omitempty"` + RootPass *string `json:"root_pass,omitempty"` AuthorizedKeys []string `json:"authorized_keys,omitempty"` AuthorizedUsers []string `json:"authorized_users,omitempty"` - StackScriptID int `json:"stackscript_id,omitempty"` + StackScriptID *int `json:"stackscript_id,omitempty"` StackScriptData map[string]string `json:"stackscript_data,omitempty"` - BackupID int `json:"backup_id,omitempty"` - Image string `json:"image,omitempty"` + BackupID *int `json:"backup_id,omitempty"` + Image *string `json:"image,omitempty"` Interfaces []InstanceConfigInterfaceCreateOptions `json:"interfaces,omitempty"` - BackupsEnabled bool `json:"backups_enabled,omitempty"` - PrivateIP bool `json:"private_ip,omitempty"` + BackupsEnabled *bool `json:"backups_enabled,omitempty"` + PrivateIP *bool `json:"private_ip,omitempty"` Tags []string `json:"tags,omitempty"` Metadata *InstanceMetadataOptions `json:"metadata,omitempty"` - FirewallID int `json:"firewall_id,omitempty"` + FirewallID *int `json:"firewall_id,omitempty"` // NOTE: Disk encryption may not currently be available to all users. - DiskEncryption InstanceDiskEncryption `json:"disk_encryption,omitempty"` + DiskEncryption *InstanceDiskEncryption `json:"disk_encryption,omitempty"` PlacementGroup *InstanceCreatePlacementGroupOptions `json:"placement_group,omitempty"` @@ -182,7 +182,7 @@ type InstanceCreateOptions struct { Booted *bool `json:"booted,omitempty"` // Deprecated: group is a deprecated property denoting a group label for the Linode. - Group string `json:"group,omitempty"` + Group *string `json:"group,omitempty"` IPv4 []string `json:"ipv4,omitempty"` } @@ -196,11 +196,11 @@ type InstanceCreatePlacementGroupOptions struct { // InstanceUpdateOptions is an options struct used when Updating an Instance type InstanceUpdateOptions struct { - Label string `json:"label,omitempty"` + Label *string `json:"label,omitempty"` Backups *InstanceBackup `json:"backups,omitempty"` Alerts *InstanceAlert `json:"alerts,omitempty"` WatchdogEnabled *bool `json:"watchdog_enabled,omitempty"` - Tags *[]string `json:"tags,omitempty"` + Tags []string `json:"tags,omitempty"` // Deprecated: group is a deprecated property denoting a group label for the Linode. Group *string `json:"group,omitempty"` @@ -251,38 +251,38 @@ func (backup *InstanceBackup) UnmarshalJSON(b []byte) error { // GetUpdateOptions converts an Instance to InstanceUpdateOptions for use in UpdateInstance func (i *Instance) GetUpdateOptions() InstanceUpdateOptions { return InstanceUpdateOptions{ - Label: i.Label, + Label: &i.Label, Group: &i.Group, Backups: i.Backups, Alerts: i.Alerts, WatchdogEnabled: &i.WatchdogEnabled, - Tags: &i.Tags, + Tags: i.Tags, } } // InstanceCloneOptions is an options struct sent when Cloning an Instance type InstanceCloneOptions struct { - Region string `json:"region,omitempty"` - Type string `json:"type,omitempty"` + Region *string `json:"region,omitempty"` + Type *string `json:"type,omitempty"` // LinodeID is an optional existing instance to use as the target of the clone - LinodeID int `json:"linode_id,omitempty"` - Label string `json:"label,omitempty"` + LinodeID *int `json:"linode_id,omitempty"` + Label *string `json:"label,omitempty"` BackupsEnabled bool `json:"backups_enabled"` Disks []int `json:"disks,omitempty"` Configs []int `json:"configs,omitempty"` - PrivateIP bool `json:"private_ip,omitempty"` + PrivateIP *bool `json:"private_ip,omitempty"` Metadata *InstanceMetadataOptions `json:"metadata,omitempty"` PlacementGroup *InstanceCreatePlacementGroupOptions `json:"placement_group,omitempty"` // Deprecated: group is a deprecated property denoting a group label for the Linode. - Group string `json:"group,omitempty"` + Group *string `json:"group,omitempty"` } // InstanceResizeOptions is an options struct used when resizing an instance type InstanceResizeOptions struct { - Type string `json:"type"` - MigrationType InstanceMigrationType `json:"migration_type,omitempty"` + Type string `json:"type"` + MigrationType *InstanceMigrationType `json:"migration_type,omitempty"` // When enabled, an instance resize will also resize a data disk if the instance has no more than one data disk and one swap disk AllowAutoDiskResize *bool `json:"allow_auto_disk_resize,omitempty"` @@ -290,9 +290,9 @@ type InstanceResizeOptions struct { // InstanceMigrateOptions is an options struct used when migrating an instance type InstanceMigrateOptions struct { - Type InstanceMigrationType `json:"type,omitempty"` - Region string `json:"region,omitempty"` - Upgrade *bool `json:"upgrade,omitempty"` + Type *InstanceMigrationType `json:"type,omitempty"` + Region *string `json:"region,omitempty"` + Upgrade *bool `json:"upgrade,omitempty"` PlacementGroup *InstanceCreatePlacementGroupOptions `json:"placement_group,omitempty"` } @@ -333,7 +333,7 @@ func (c *Client) UpdateInstance(ctx context.Context, linodeID int, opts Instance // RenameInstance renames an Instance func (c *Client) RenameInstance(ctx context.Context, linodeID int, label string) (*Instance, error) { - return c.UpdateInstance(ctx, linodeID, InstanceUpdateOptions{Label: label}) + return c.UpdateInstance(ctx, linodeID, InstanceUpdateOptions{Label: &label}) } // DeleteInstance deletes a Linode instance @@ -382,18 +382,18 @@ func (c *Client) RebootInstance(ctx context.Context, linodeID int, configID int) // InstanceRebuildOptions is a struct representing the options to send to the rebuild linode endpoint type InstanceRebuildOptions struct { - Image string `json:"image,omitempty"` - RootPass string `json:"root_pass,omitempty"` + Image *string `json:"image,omitempty"` + RootPass *string `json:"root_pass,omitempty"` AuthorizedKeys []string `json:"authorized_keys,omitempty"` AuthorizedUsers []string `json:"authorized_users,omitempty"` - StackScriptID int `json:"stackscript_id,omitempty"` + StackScriptID *int `json:"stackscript_id,omitempty"` StackScriptData map[string]string `json:"stackscript_data,omitempty"` Booted *bool `json:"booted,omitempty"` Metadata *InstanceMetadataOptions `json:"metadata,omitempty"` - Type string `json:"type,omitempty"` + Type *string `json:"type,omitempty"` // NOTE: Disk encryption may not currently be available to all users. - DiskEncryption InstanceDiskEncryption `json:"disk_encryption,omitempty"` + DiskEncryption *InstanceDiskEncryption `json:"disk_encryption,omitempty"` } // RebuildInstance Deletes all Disks and Configs on this Linode, diff --git a/lke_clusters.go b/lke_clusters.go index 5fe77670e..99702215f 100644 --- a/lke_clusters.go +++ b/lke_clusters.go @@ -47,17 +47,17 @@ type LKEClusterCreateOptions struct { ControlPlane *LKEClusterControlPlaneOptions `json:"control_plane,omitempty"` // NOTE: Tier may not currently be available to all users and can only be used with v4beta. - Tier string `json:"tier,omitempty"` + Tier *string `json:"tier,omitempty"` // NOTE: APLEnabled is currently in beta and may only function with API version v4beta. - APLEnabled bool `json:"apl_enabled,omitempty"` + APLEnabled *bool `json:"apl_enabled,omitempty"` } // LKEClusterUpdateOptions fields are those accepted by UpdateLKECluster type LKEClusterUpdateOptions struct { - K8sVersion string `json:"k8s_version,omitempty"` - Label string `json:"label,omitempty"` - Tags *[]string `json:"tags,omitempty"` + K8sVersion *string `json:"k8s_version,omitempty"` + Label *string `json:"label,omitempty"` + Tags []string `json:"tags,omitempty"` ControlPlane *LKEClusterControlPlaneOptions `json:"control_plane,omitempty"` } @@ -129,9 +129,9 @@ func (i LKECluster) GetCreateOptions() (o LKEClusterCreateOptions) { // GetUpdateOptions converts a LKECluster to LKEClusterUpdateOptions for use in UpdateLKECluster func (i LKECluster) GetUpdateOptions() (o LKEClusterUpdateOptions) { - o.K8sVersion = i.K8sVersion - o.Label = i.Label - o.Tags = &i.Tags + o.K8sVersion = &i.K8sVersion + o.Label = &i.Label + o.Tags = i.Tags isHA := i.ControlPlane.HighAvailability diff --git a/lke_clusters_control_plane.go b/lke_clusters_control_plane.go index 24bed1cbf..d8b2cd77c 100644 --- a/lke_clusters_control_plane.go +++ b/lke_clusters_control_plane.go @@ -20,14 +20,14 @@ type LKEClusterControlPlaneACLAddresses struct { type LKEClusterControlPlaneACL struct { Enabled bool `json:"enabled"` Addresses *LKEClusterControlPlaneACLAddresses `json:"addresses"` - RevisionID string `json:"revision_id,omitempty"` + RevisionID *string `json:"revision_id,omitempty"` } // LKEClusterControlPlaneACLAddressesOptions are the options used to // specify the allowed IP ranges for an LKE cluster's control plane. type LKEClusterControlPlaneACLAddressesOptions struct { - IPv4 *[]string `json:"ipv4,omitempty"` - IPv6 *[]string `json:"ipv6,omitempty"` + IPv4 []string `json:"ipv4,omitempty"` + IPv6 []string `json:"ipv6,omitempty"` } // LKEClusterControlPlaneACLOptions represents the options used when diff --git a/lke_node_pools.go b/lke_node_pools.go index 174890b28..81196282d 100644 --- a/lke_node_pools.go +++ b/lke_node_pools.go @@ -45,7 +45,7 @@ const ( // LKENodePoolTaint represents a corev1.Taint to add to an LKENodePool type LKENodePoolTaint struct { Key string `json:"key"` - Value string `json:"value,omitempty"` + Value *string `json:"value,omitempty"` Effect LKENodePoolTaintEffect `json:"effect"` } @@ -66,7 +66,7 @@ type LKENodePool struct { Autoscaler LKENodePoolAutoscaler `json:"autoscaler"` // NOTE: Disk encryption may not currently be available to all users. - DiskEncryption InstanceDiskEncryption `json:"disk_encryption,omitempty"` + DiskEncryption *InstanceDiskEncryption `json:"disk_encryption,omitempty"` } // LKENodePoolCreateOptions fields are those accepted by CreateLKENodePool @@ -83,10 +83,10 @@ type LKENodePoolCreateOptions struct { // LKENodePoolUpdateOptions fields are those accepted by UpdateLKENodePoolUpdate type LKENodePoolUpdateOptions struct { - Count int `json:"count,omitempty"` - Tags *[]string `json:"tags,omitempty"` - Labels *LKENodePoolLabels `json:"labels,omitempty"` - Taints *[]LKENodePoolTaint `json:"taints,omitempty"` + Count *int `json:"count,omitempty"` + Tags []string `json:"tags,omitempty"` + Labels *LKENodePoolLabels `json:"labels,omitempty"` + Taints []LKENodePoolTaint `json:"taints,omitempty"` Autoscaler *LKENodePoolAutoscaler `json:"autoscaler,omitempty"` } @@ -105,10 +105,10 @@ func (l LKENodePool) GetCreateOptions() (o LKENodePoolCreateOptions) { // GetUpdateOptions converts a LKENodePool to LKENodePoolUpdateOptions for use in UpdateLKENodePoolUpdate func (l LKENodePool) GetUpdateOptions() (o LKENodePoolUpdateOptions) { - o.Count = l.Count - o.Tags = &l.Tags + o.Count = &l.Count + o.Tags = l.Tags o.Labels = &l.Labels - o.Taints = &l.Taints + o.Taints = l.Taints o.Autoscaler = &l.Autoscaler return } diff --git a/mysql.go b/mysql.go index 5a950547b..1ec7e8341 100644 --- a/mysql.go +++ b/mysql.go @@ -81,26 +81,26 @@ type MySQLCreateOptions struct { Type string `json:"type"` Engine string `json:"engine"` AllowList []string `json:"allow_list,omitempty"` - ClusterSize int `json:"cluster_size,omitempty"` + ClusterSize *int `json:"cluster_size,omitempty"` // Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2. - ReplicationType string `json:"replication_type,omitempty"` + ReplicationType *string `json:"replication_type,omitempty"` // Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2. - Encrypted bool `json:"encrypted,omitempty"` + Encrypted *bool `json:"encrypted,omitempty"` // Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2. - SSLConnection bool `json:"ssl_connection,omitempty"` + SSLConnection *bool `json:"ssl_connection,omitempty"` Fork *DatabaseFork `json:"fork,omitempty"` } // MySQLUpdateOptions fields are used when altering the existing MySQL Database type MySQLUpdateOptions struct { - Label string `json:"label,omitempty"` - AllowList *[]string `json:"allow_list,omitempty"` + Label *string `json:"label,omitempty"` + AllowList []string `json:"allow_list,omitempty"` Updates *DatabaseMaintenanceWindow `json:"updates,omitempty"` - Type string `json:"type,omitempty"` - ClusterSize int `json:"cluster_size,omitempty"` - Version string `json:"version,omitempty"` + Type *string `json:"type,omitempty"` + ClusterSize *int `json:"cluster_size,omitempty"` + Version *string `json:"version,omitempty"` } // MySQLDatabaseBackup is information for interacting with a backup for the existing MySQL Database diff --git a/network_ips.go b/network_ips.go index 8cebabb42..8a425a3b1 100644 --- a/network_ips.go +++ b/network_ips.go @@ -29,11 +29,11 @@ type LinodeIPAssignment struct { } type AllocateReserveIPOptions struct { - Type string `json:"type"` - Public bool `json:"public"` - Reserved bool `json:"reserved,omitempty"` - Region string `json:"region,omitempty"` - LinodeID int `json:"linode_id,omitempty"` + Type string `json:"type"` + Public bool `json:"public"` + Reserved *bool `json:"reserved,omitempty"` + Region *string `json:"region,omitempty"` + LinodeID *int `json:"linode_id,omitempty"` } // LinodesAssignIPsOptions fields are those accepted by InstancesAssignIPs. diff --git a/network_ranges.go b/network_ranges.go index 00350b604..8c4f9471f 100644 --- a/network_ranges.go +++ b/network_ranges.go @@ -6,9 +6,9 @@ import ( // IPv6RangeCreateOptions fields are those accepted by CreateIPv6Range type IPv6RangeCreateOptions struct { - LinodeID int `json:"linode_id,omitempty"` - PrefixLength int `json:"prefix_length"` - RouteTarget string `json:"route_target,omitempty"` + LinodeID *int `json:"linode_id,omitempty"` + PrefixLength int `json:"prefix_length"` + RouteTarget *string `json:"route_target,omitempty"` } // ListIPv6Ranges lists IPv6Ranges diff --git a/nodebalancer.go b/nodebalancer.go index d209ff011..127c75464 100644 --- a/nodebalancer.go +++ b/nodebalancer.go @@ -47,18 +47,18 @@ type NodeBalancerTransfer struct { // NodeBalancerCreateOptions are the options permitted for CreateNodeBalancer type NodeBalancerCreateOptions struct { Label *string `json:"label,omitempty"` - Region string `json:"region,omitempty"` + Region *string `json:"region,omitempty"` ClientConnThrottle *int `json:"client_conn_throttle,omitempty"` Configs []*NodeBalancerConfigCreateOptions `json:"configs,omitempty"` Tags []string `json:"tags"` - FirewallID int `json:"firewall_id,omitempty"` + FirewallID *int `json:"firewall_id,omitempty"` } // NodeBalancerUpdateOptions are the options permitted for UpdateNodeBalancer type NodeBalancerUpdateOptions struct { - Label *string `json:"label,omitempty"` - ClientConnThrottle *int `json:"client_conn_throttle,omitempty"` - Tags *[]string `json:"tags,omitempty"` + Label *string `json:"label,omitempty"` + ClientConnThrottle *int `json:"client_conn_throttle,omitempty"` + Tags []string `json:"tags,omitempty"` } // UnmarshalJSON implements the json.Unmarshaler interface @@ -87,7 +87,7 @@ func (i *NodeBalancer) UnmarshalJSON(b []byte) error { func (i NodeBalancer) GetCreateOptions() NodeBalancerCreateOptions { return NodeBalancerCreateOptions{ Label: i.Label, - Region: i.Region, + Region: &i.Region, ClientConnThrottle: &i.ClientConnThrottle, Tags: i.Tags, } @@ -98,7 +98,7 @@ func (i NodeBalancer) GetUpdateOptions() NodeBalancerUpdateOptions { return NodeBalancerUpdateOptions{ Label: i.Label, ClientConnThrottle: &i.ClientConnThrottle, - Tags: &i.Tags, + Tags: i.Tags, } } diff --git a/nodebalancer_config_nodes.go b/nodebalancer_config_nodes.go index 200b3fa9e..621c2598b 100644 --- a/nodebalancer_config_nodes.go +++ b/nodebalancer_config_nodes.go @@ -35,18 +35,18 @@ var ( // NodeBalancerNodeCreateOptions fields are those accepted by CreateNodeBalancerNode type NodeBalancerNodeCreateOptions struct { - Address string `json:"address"` - Label string `json:"label"` - Weight int `json:"weight,omitempty"` - Mode NodeMode `json:"mode,omitempty"` + Address string `json:"address"` + Label string `json:"label"` + Weight *int `json:"weight,omitempty"` + Mode *NodeMode `json:"mode,omitempty"` } // NodeBalancerNodeUpdateOptions fields are those accepted by UpdateNodeBalancerNode type NodeBalancerNodeUpdateOptions struct { - Address string `json:"address,omitempty"` - Label string `json:"label,omitempty"` - Weight int `json:"weight,omitempty"` - Mode NodeMode `json:"mode,omitempty"` + Address *string `json:"address,omitempty"` + Label *string `json:"label,omitempty"` + Weight *int `json:"weight,omitempty"` + Mode *NodeMode `json:"mode,omitempty"` } // GetCreateOptions converts a NodeBalancerNode to NodeBalancerNodeCreateOptions for use in CreateNodeBalancerNode @@ -54,18 +54,18 @@ func (i NodeBalancerNode) GetCreateOptions() NodeBalancerNodeCreateOptions { return NodeBalancerNodeCreateOptions{ Address: i.Address, Label: i.Label, - Weight: i.Weight, - Mode: i.Mode, + Weight: &i.Weight, + Mode: &i.Mode, } } // GetUpdateOptions converts a NodeBalancerNode to NodeBalancerNodeUpdateOptions for use in UpdateNodeBalancerNode func (i NodeBalancerNode) GetUpdateOptions() NodeBalancerNodeUpdateOptions { return NodeBalancerNodeUpdateOptions{ - Address: i.Address, - Label: i.Label, - Weight: i.Weight, - Mode: i.Mode, + Address: &i.Address, + Label: &i.Label, + Weight: &i.Weight, + Mode: &i.Mode, } } diff --git a/nodebalancer_configs.go b/nodebalancer_configs.go index 68c273023..5e02340fd 100644 --- a/nodebalancer_configs.go +++ b/nodebalancer_configs.go @@ -97,40 +97,40 @@ type NodeBalancerNodeStatus struct { // NodeBalancerConfigCreateOptions are permitted by CreateNodeBalancerConfig type NodeBalancerConfigCreateOptions struct { Port int `json:"port"` - Protocol ConfigProtocol `json:"protocol,omitempty"` - ProxyProtocol ConfigProxyProtocol `json:"proxy_protocol,omitempty"` - Algorithm ConfigAlgorithm `json:"algorithm,omitempty"` - Stickiness ConfigStickiness `json:"stickiness,omitempty"` - Check ConfigCheck `json:"check,omitempty"` - CheckInterval int `json:"check_interval,omitempty"` - CheckAttempts int `json:"check_attempts,omitempty"` - CheckPath string `json:"check_path,omitempty"` - CheckBody string `json:"check_body,omitempty"` + Protocol *ConfigProtocol `json:"protocol,omitempty"` + ProxyProtocol *ConfigProxyProtocol `json:"proxy_protocol,omitempty"` + Algorithm *ConfigAlgorithm `json:"algorithm,omitempty"` + Stickiness *ConfigStickiness `json:"stickiness,omitempty"` + Check *ConfigCheck `json:"check,omitempty"` + CheckInterval *int `json:"check_interval,omitempty"` + CheckAttempts *int `json:"check_attempts,omitempty"` + CheckPath *string `json:"check_path,omitempty"` + CheckBody *string `json:"check_body,omitempty"` CheckPassive *bool `json:"check_passive,omitempty"` - CheckTimeout int `json:"check_timeout,omitempty"` - CipherSuite ConfigCipher `json:"cipher_suite,omitempty"` - SSLCert string `json:"ssl_cert,omitempty"` - SSLKey string `json:"ssl_key,omitempty"` + CheckTimeout *int `json:"check_timeout,omitempty"` + CipherSuite *ConfigCipher `json:"cipher_suite,omitempty"` + SSLCert *string `json:"ssl_cert,omitempty"` + SSLKey *string `json:"ssl_key,omitempty"` Nodes []NodeBalancerNodeCreateOptions `json:"nodes,omitempty"` } // NodeBalancerConfigRebuildOptions used by RebuildNodeBalancerConfig type NodeBalancerConfigRebuildOptions struct { Port int `json:"port"` - Protocol ConfigProtocol `json:"protocol,omitempty"` - ProxyProtocol ConfigProxyProtocol `json:"proxy_protocol,omitempty"` - Algorithm ConfigAlgorithm `json:"algorithm,omitempty"` - Stickiness ConfigStickiness `json:"stickiness,omitempty"` - Check ConfigCheck `json:"check,omitempty"` - CheckInterval int `json:"check_interval,omitempty"` - CheckAttempts int `json:"check_attempts,omitempty"` - CheckPath string `json:"check_path,omitempty"` - CheckBody string `json:"check_body,omitempty"` + Protocol *ConfigProtocol `json:"protocol,omitempty"` + ProxyProtocol *ConfigProxyProtocol `json:"proxy_protocol,omitempty"` + Algorithm *ConfigAlgorithm `json:"algorithm,omitempty"` + Stickiness *ConfigStickiness `json:"stickiness,omitempty"` + Check *ConfigCheck `json:"check,omitempty"` + CheckInterval *int `json:"check_interval,omitempty"` + CheckAttempts *int `json:"check_attempts,omitempty"` + CheckPath *string `json:"check_path,omitempty"` + CheckBody *string `json:"check_body,omitempty"` CheckPassive *bool `json:"check_passive,omitempty"` - CheckTimeout int `json:"check_timeout,omitempty"` - CipherSuite ConfigCipher `json:"cipher_suite,omitempty"` - SSLCert string `json:"ssl_cert,omitempty"` - SSLKey string `json:"ssl_key,omitempty"` + CheckTimeout *int `json:"check_timeout,omitempty"` + CipherSuite *ConfigCipher `json:"cipher_suite,omitempty"` + SSLCert *string `json:"ssl_cert,omitempty"` + SSLKey *string `json:"ssl_key,omitempty"` Nodes []NodeBalancerConfigRebuildNodeOptions `json:"nodes"` } @@ -139,7 +139,7 @@ type NodeBalancerConfigRebuildOptions struct { type NodeBalancerConfigRebuildNodeOptions struct { NodeBalancerNodeCreateOptions - ID int `json:"id,omitempty"` + ID *int `json:"id,omitempty"` } // NodeBalancerConfigUpdateOptions are permitted by UpdateNodeBalancerConfig @@ -149,20 +149,20 @@ type NodeBalancerConfigUpdateOptions NodeBalancerConfigCreateOptions func (i NodeBalancerConfig) GetCreateOptions() NodeBalancerConfigCreateOptions { return NodeBalancerConfigCreateOptions{ Port: i.Port, - Protocol: i.Protocol, - ProxyProtocol: i.ProxyProtocol, - Algorithm: i.Algorithm, - Stickiness: i.Stickiness, - Check: i.Check, - CheckInterval: i.CheckInterval, - CheckAttempts: i.CheckAttempts, - CheckTimeout: i.CheckTimeout, - CheckPath: i.CheckPath, - CheckBody: i.CheckBody, + Protocol: &i.Protocol, + ProxyProtocol: &i.ProxyProtocol, + Algorithm: &i.Algorithm, + Stickiness: &i.Stickiness, + Check: &i.Check, + CheckInterval: &i.CheckInterval, + CheckAttempts: &i.CheckAttempts, + CheckTimeout: &i.CheckTimeout, + CheckPath: &i.CheckPath, + CheckBody: &i.CheckBody, CheckPassive: copyBool(&i.CheckPassive), - CipherSuite: i.CipherSuite, - SSLCert: i.SSLCert, - SSLKey: i.SSLKey, + CipherSuite: &i.CipherSuite, + SSLCert: &i.SSLCert, + SSLKey: &i.SSLKey, } } @@ -170,20 +170,20 @@ func (i NodeBalancerConfig) GetCreateOptions() NodeBalancerConfigCreateOptions { func (i NodeBalancerConfig) GetUpdateOptions() NodeBalancerConfigUpdateOptions { return NodeBalancerConfigUpdateOptions{ Port: i.Port, - Protocol: i.Protocol, - ProxyProtocol: i.ProxyProtocol, - Algorithm: i.Algorithm, - Stickiness: i.Stickiness, - Check: i.Check, - CheckInterval: i.CheckInterval, - CheckAttempts: i.CheckAttempts, - CheckPath: i.CheckPath, - CheckBody: i.CheckBody, + Protocol: &i.Protocol, + ProxyProtocol: &i.ProxyProtocol, + Algorithm: &i.Algorithm, + Stickiness: &i.Stickiness, + Check: &i.Check, + CheckInterval: &i.CheckInterval, + CheckAttempts: &i.CheckAttempts, + CheckPath: &i.CheckPath, + CheckBody: &i.CheckBody, CheckPassive: copyBool(&i.CheckPassive), - CheckTimeout: i.CheckTimeout, - CipherSuite: i.CipherSuite, - SSLCert: i.SSLCert, - SSLKey: i.SSLKey, + CheckTimeout: &i.CheckTimeout, + CipherSuite: &i.CipherSuite, + SSLCert: &i.SSLCert, + SSLKey: &i.SSLKey, } } @@ -191,20 +191,20 @@ func (i NodeBalancerConfig) GetUpdateOptions() NodeBalancerConfigUpdateOptions { func (i NodeBalancerConfig) GetRebuildOptions() NodeBalancerConfigRebuildOptions { return NodeBalancerConfigRebuildOptions{ Port: i.Port, - Protocol: i.Protocol, - ProxyProtocol: i.ProxyProtocol, - Algorithm: i.Algorithm, - Stickiness: i.Stickiness, - Check: i.Check, - CheckInterval: i.CheckInterval, - CheckAttempts: i.CheckAttempts, - CheckTimeout: i.CheckTimeout, - CheckPath: i.CheckPath, - CheckBody: i.CheckBody, + Protocol: &i.Protocol, + ProxyProtocol: &i.ProxyProtocol, + Algorithm: &i.Algorithm, + Stickiness: &i.Stickiness, + Check: &i.Check, + CheckInterval: &i.CheckInterval, + CheckAttempts: &i.CheckAttempts, + CheckTimeout: &i.CheckTimeout, + CheckPath: &i.CheckPath, + CheckBody: &i.CheckBody, CheckPassive: copyBool(&i.CheckPassive), - CipherSuite: i.CipherSuite, - SSLCert: i.SSLCert, - SSLKey: i.SSLKey, + CipherSuite: &i.CipherSuite, + SSLCert: &i.SSLCert, + SSLKey: &i.SSLKey, Nodes: make([]NodeBalancerConfigRebuildNodeOptions, 0), } } diff --git a/object_storage_buckets.go b/object_storage_buckets.go index 7557dad8e..b61967434 100644 --- a/object_storage_buckets.go +++ b/object_storage_buckets.go @@ -88,21 +88,21 @@ type ObjectStorageBucketCreateOptions struct { // Going forward, the 'Region' field will be the supported way to designate where an // Object Storage Bucket should be created. For example, a 'Cluster' value of `us-mia-1` // will translate to a Region value of `us-mia`. - Cluster string `json:"cluster,omitempty"` - Region string `json:"region,omitempty"` + Cluster *string `json:"cluster,omitempty"` + Region *string `json:"region,omitempty"` - Label string `json:"label"` - S3Endpoint string `json:"s3_endpoint,omitempty"` - EndpointType ObjectStorageEndpointType `json:"endpoint_type,omitempty"` + Label string `json:"label"` + S3Endpoint *string `json:"s3_endpoint,omitempty"` + EndpointType *ObjectStorageEndpointType `json:"endpoint_type,omitempty"` - ACL ObjectStorageACL `json:"acl,omitempty"` - CorsEnabled *bool `json:"cors_enabled,omitempty"` + ACL *ObjectStorageACL `json:"acl,omitempty"` + CorsEnabled *bool `json:"cors_enabled,omitempty"` } // ObjectStorageBucketUpdateAccessOptions fields are those accepted by UpdateObjectStorageBucketAccess type ObjectStorageBucketUpdateAccessOptions struct { - ACL ObjectStorageACL `json:"acl,omitempty"` - CorsEnabled *bool `json:"cors_enabled,omitempty"` + ACL *ObjectStorageACL `json:"acl,omitempty"` + CorsEnabled *bool `json:"cors_enabled,omitempty"` } // ObjectStorageBucketListContentsParams fields are the query parameters for ListObjectStorageBucketContents diff --git a/object_storage_keys.go b/object_storage_keys.go index cfc2ef480..6bf3cdd2c 100644 --- a/object_storage_keys.go +++ b/object_storage_keys.go @@ -26,8 +26,8 @@ type ObjectStorageKeyBucketAccess struct { // Deprecated: Cluster field has been deprecated. // Please consider switching to use the 'Region' field. // If your Cluster is `us-mia-1`, then the region would be `us-mia`. - Cluster string `json:"cluster,omitempty"` - Region string `json:"region,omitempty"` + Cluster *string `json:"cluster,omitempty"` + Region *string `json:"region,omitempty"` BucketName string `json:"bucket_name"` Permissions string `json:"permissions"` @@ -42,7 +42,7 @@ type ObjectStorageKeyCreateOptions struct { // ObjectStorageKeyUpdateOptions fields are those accepted by UpdateObjectStorageKey type ObjectStorageKeyUpdateOptions struct { - Label string `json:"label,omitempty"` + Label *string `json:"label,omitempty"` Regions []string `json:"regions,omitempty"` } diff --git a/object_storage_object.go b/object_storage_object.go index 61fd93e14..0a64c6d37 100644 --- a/object_storage_object.go +++ b/object_storage_object.go @@ -5,11 +5,11 @@ import ( ) type ObjectStorageObjectURLCreateOptions struct { - Name string `json:"name"` - Method string `json:"method"` - ContentType string `json:"content_type,omitempty"` - ContentDisposition string `json:"content_disposition,omitempty"` - ExpiresIn *int `json:"expires_in,omitempty"` + Name string `json:"name"` + Method string `json:"method"` + ContentType *string `json:"content_type,omitempty"` + ContentDisposition *string `json:"content_disposition,omitempty"` + ExpiresIn *int `json:"expires_in,omitempty"` } type ObjectStorageObjectURL struct { diff --git a/placement_groups.go b/placement_groups.go index 189b3ace1..98aa1ad0b 100644 --- a/placement_groups.go +++ b/placement_groups.go @@ -61,7 +61,7 @@ type PlacementGroupCreateOptions struct { // PlacementGroupUpdateOptions represents the options to use // when updating a placement group. type PlacementGroupUpdateOptions struct { - Label string `json:"label,omitempty"` + Label *string `json:"label,omitempty"` } // PlacementGroupAssignOptions represents options used when diff --git a/postgres.go b/postgres.go index 5d2ad59c4..d265be6d5 100644 --- a/postgres.go +++ b/postgres.go @@ -99,28 +99,28 @@ type PostgresCreateOptions struct { Type string `json:"type"` Engine string `json:"engine"` AllowList []string `json:"allow_list,omitempty"` - ClusterSize int `json:"cluster_size,omitempty"` + ClusterSize *int `json:"cluster_size,omitempty"` // Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2. - Encrypted bool `json:"encrypted,omitempty"` + Encrypted *bool `json:"encrypted,omitempty"` // Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2. - SSLConnection bool `json:"ssl_connection,omitempty"` + SSLConnection *bool `json:"ssl_connection,omitempty"` // Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2. - ReplicationType PostgresReplicationType `json:"replication_type,omitempty"` + ReplicationType *PostgresReplicationType `json:"replication_type,omitempty"` // Deprecated: ReplicationCommitType is a deprecated property, as it is no longer supported in DBaaS V2. - ReplicationCommitType PostgresCommitType `json:"replication_commit_type,omitempty"` + ReplicationCommitType *PostgresCommitType `json:"replication_commit_type,omitempty"` Fork *DatabaseFork `json:"fork,omitempty"` } // PostgresUpdateOptions fields are used when altering the existing Postgres Database type PostgresUpdateOptions struct { - Label string `json:"label,omitempty"` - AllowList *[]string `json:"allow_list,omitempty"` + Label *string `json:"label,omitempty"` + AllowList []string `json:"allow_list,omitempty"` Updates *DatabaseMaintenanceWindow `json:"updates,omitempty"` - Type string `json:"type,omitempty"` - ClusterSize int `json:"cluster_size,omitempty"` - Version string `json:"version,omitempty"` + Type *string `json:"type,omitempty"` + ClusterSize *int `json:"cluster_size,omitempty"` + Version *string `json:"version,omitempty"` } // PostgresDatabaseSSL is the SSL Certificate to access the Linode Managed Postgres Database diff --git a/profile.go b/profile.go index ec227b6d1..957988b97 100644 --- a/profile.go +++ b/profile.go @@ -38,28 +38,28 @@ type Profile struct { Referrals ProfileReferrals `json:"referrals"` AuthorizedKeys []string `json:"authorized_keys"` AuthenticationType string `json:"authentication_type"` - VerifiedPhoneNumber string `json:"verified_phone_number,omitempty"` + VerifiedPhoneNumber *string `json:"verified_phone_number,omitempty"` } // ProfileUpdateOptions fields are those accepted by UpdateProfile type ProfileUpdateOptions struct { - Email string `json:"email,omitempty"` - Timezone string `json:"timezone,omitempty"` - EmailNotifications *bool `json:"email_notifications,omitempty"` - IPWhitelistEnabled *bool `json:"ip_whitelist_enabled,omitempty"` - LishAuthMethod LishAuthMethod `json:"lish_auth_method,omitempty"` - AuthorizedKeys *[]string `json:"authorized_keys,omitempty"` - TwoFactorAuth *bool `json:"two_factor_auth,omitempty"` - Restricted *bool `json:"restricted,omitempty"` + Email *string `json:"email,omitempty"` + Timezone *string `json:"timezone,omitempty"` + EmailNotifications *bool `json:"email_notifications,omitempty"` + IPWhitelistEnabled *bool `json:"ip_whitelist_enabled,omitempty"` + LishAuthMethod *LishAuthMethod `json:"lish_auth_method,omitempty"` + AuthorizedKeys *[]string `json:"authorized_keys,omitempty"` + TwoFactorAuth *bool `json:"two_factor_auth,omitempty"` + Restricted *bool `json:"restricted,omitempty"` } // GetUpdateOptions converts a Profile to ProfileUpdateOptions for use in UpdateProfile func (i Profile) GetUpdateOptions() (o ProfileUpdateOptions) { - o.Email = i.Email - o.Timezone = i.Timezone + o.Email = &i.Email + o.Timezone = &i.Timezone o.EmailNotifications = copyBool(&i.EmailNotifications) o.IPWhitelistEnabled = copyBool(&i.IPWhitelistEnabled) - o.LishAuthMethod = i.LishAuthMethod + o.LishAuthMethod = &i.LishAuthMethod authorizedKeys := make([]string, len(i.AuthorizedKeys)) copy(authorizedKeys, i.AuthorizedKeys) o.AuthorizedKeys = &authorizedKeys diff --git a/stackscripts.go b/stackscripts.go index aa1a4dcf7..6f8dc11ed 100644 --- a/stackscripts.go +++ b/stackscripts.go @@ -41,13 +41,13 @@ type StackscriptUDF struct { Example string `json:"example"` // A list of acceptable single values for the field. - OneOf string `json:"oneOf,omitempty"` + OneOf *string `json:"oneOf,omitempty"` // A list of acceptable values for the field in any quantity, combination or order. - ManyOf string `json:"manyOf,omitempty"` + ManyOf *string `json:"manyOf,omitempty"` // The default value. If not specified, this value will be used. - Default string `json:"default,omitempty"` + Default *string `json:"default,omitempty"` } // StackscriptCreateOptions fields are those accepted by CreateStackscript diff --git a/test/integration/account_events_test.go b/test/integration/account_events_test.go index 7c305034d..6dbb8e394 100644 --- a/test/integration/account_events_test.go +++ b/test/integration/account_events_test.go @@ -14,7 +14,7 @@ func TestAccountEvents_List_smoke(t *testing.T) { t.Error(err) } configOpts := linodego.InstanceConfigCreateOptions{ - Label: "test-config", + Label: linodego.Pointer("test-config"), } instanceConfig, err := client.CreateInstanceConfig(context.Background(), instance.ID, configOpts) if err != nil { diff --git a/test/integration/account_settings_test.go b/test/integration/account_settings_test.go index ecba9393d..92a604c8e 100644 --- a/test/integration/account_settings_test.go +++ b/test/integration/account_settings_test.go @@ -22,8 +22,8 @@ func TestAccountSettings_Get(t *testing.T) { BackupsEnabled: true, Managed: true, NetworkHelper: true, - LongviewSubscription: String("longview-3"), - ObjectStorage: String("active"), + LongviewSubscription: linodego.Pointer("longview-3"), + ObjectStorage: linodego.Pointer("active"), } mockResponse, _ := json.Marshal(mockSettings) @@ -51,15 +51,15 @@ func TestAccountSettings_Update(t *testing.T) { defer httpmock.DeactivateAndReset() opts := linodego.AccountSettingsUpdateOptions{ - BackupsEnabled: Bool(false), - LongviewSubscription: String("longview-10"), - NetworkHelper: Bool(false), + BackupsEnabled: linodego.Pointer(false), + LongviewSubscription: linodego.Pointer("longview-10"), + NetworkHelper: linodego.Pointer(false), } mockSettings := linodego.AccountSettings{ BackupsEnabled: false, NetworkHelper: false, - LongviewSubscription: String("longview-10"), + LongviewSubscription: linodego.Pointer("longview-10"), } mockResponse, _ := json.Marshal(mockSettings) @@ -74,6 +74,3 @@ func TestAccountSettings_Update(t *testing.T) { require.NotNil(t, settings.LongviewSubscription, "Expected LongviewSubscription to be non-nil") require.Equal(t, "longview-10", *settings.LongviewSubscription, "Expected LongviewSubscription to be 'longview-10'") } - -func Bool(v bool) *bool { return &v } -func String(v string) *string { return &v } diff --git a/test/integration/account_user_grants_test.go b/test/integration/account_user_grants_test.go index 45cdd0dae..2b3e4a3c5 100644 --- a/test/integration/account_user_grants_test.go +++ b/test/integration/account_user_grants_test.go @@ -20,10 +20,8 @@ func TestUserGrants_Update(t *testing.T) { }, "fixtures/TestUserGrants_Update") defer teardown() - accessLevel := linodego.AccessLevelReadOnly - globalGrants := linodego.GlobalUserGrants{ - AccountAccess: &accessLevel, + AccountAccess: linodego.Pointer(linodego.AccessLevelReadOnly), AddDomains: false, AddDatabases: true, AddFirewalls: true, diff --git a/test/integration/account_users_test.go b/test/integration/account_users_test.go index 18204e930..8e14366d1 100644 --- a/test/integration/account_users_test.go +++ b/test/integration/account_users_test.go @@ -87,10 +87,10 @@ func TestUser_Update(t *testing.T) { defer teardown() updatedUsername := username + "-updated" - restricted = true + updateOpts := UserUpdateOptions{ - Username: updatedUsername, - Restricted: &restricted, + Username: linodego.Pointer(updatedUsername), + Restricted: linodego.Pointer(true), } updated, err := client.UpdateUser(context.TODO(), username, updateOpts) diff --git a/test/integration/domain_records_test.go b/test/integration/domain_records_test.go index 6e9bb2d8e..059512c4f 100644 --- a/test/integration/domain_records_test.go +++ b/test/integration/domain_records_test.go @@ -44,7 +44,7 @@ func TestDomainRecord_Update(t *testing.T) { assertDateSet(t, record.Updated) updateOpts := linodego.DomainRecordUpdateOptions{ - Name: "renamed", + Name: linodego.Pointer("renamed"), } recordUpdated, err := client.UpdateDomainRecord(context.Background(), domain.ID, record.ID, updateOpts) if err != nil { diff --git a/test/integration/domains_test.go b/test/integration/domains_test.go index 74342c61e..cde598e94 100644 --- a/test/integration/domains_test.go +++ b/test/integration/domains_test.go @@ -9,7 +9,7 @@ import ( var testDomainCreateOpts = linodego.DomainCreateOptions{ Type: linodego.DomainTypeMaster, - SOAEmail: "example@example.com", + SOAEmail: linodego.Pointer("example@example.com"), } func TestDomain_Create_smoke(t *testing.T) { @@ -21,7 +21,7 @@ func TestDomain_Create_smoke(t *testing.T) { } // when comparing fixtures to random value Domain will differ - if domain.SOAEmail != testDomainCreateOpts.SOAEmail { + if testDomainCreateOpts.SOAEmail == nil || domain.SOAEmail != *testDomainCreateOpts.SOAEmail { t.Errorf("Domain returned does not match domain create request") } } @@ -34,12 +34,12 @@ func TestDomain_Update(t *testing.T) { } updateOpts := linodego.DomainUpdateOptions{ - Domain: "linodego-renamed-domain.com", + Domain: linodego.Pointer("linodego-renamed-domain.com"), } domain, err = client.UpdateDomain(context.Background(), domain.ID, updateOpts) if err != nil { t.Errorf("Error renaming domain, %s", err) - } else if domain.Domain != updateOpts.Domain { + } else if updateOpts.Domain == nil || domain.Domain != *updateOpts.Domain { t.Errorf("Error renaming domain: Domain does not match") } } diff --git a/test/integration/example_nodebalancers_test.go b/test/integration/example_nodebalancers_test.go index 03712ee10..ed93ae0a6 100644 --- a/test/integration/example_nodebalancers_test.go +++ b/test/integration/example_nodebalancers_test.go @@ -57,11 +57,10 @@ func ExampleClient_CreateNodeBalancerConfig() { defer teardown() fmt.Println("## NodeBalancer create") - clientConnThrottle := 20 nb, err := linodeClient.CreateNodeBalancer(context.Background(), linodego.NodeBalancerCreateOptions{ - ClientConnThrottle: &clientConnThrottle, - Region: "us-southeast", - FirewallID: GetFirewallID(), + ClientConnThrottle: linodego.Pointer(20), + Region: linodego.Pointer("us-southeast"), + FirewallID: linodego.Pointer(GetFirewallID()), }) if err != nil { log.Fatal(err) @@ -77,9 +76,9 @@ func ExampleClient_CreateNodeBalancerConfig() { Check: linodego.CheckHTTP, CipherSuite: linodego.CipherRecommended, */ - CheckTimeout: 5, - CheckInterval: 30, - CheckAttempts: 5, + CheckTimeout: linodego.Pointer(5), + CheckInterval: linodego.Pointer(30), + CheckAttempts: linodego.Pointer(5), } nbc, err := linodeClient.CreateNodeBalancerConfig(context.Background(), nb.ID, createOpts) if err != nil { @@ -134,11 +133,10 @@ func ExampleClient_CreateNodeBalancerNode() { defer teardown() fmt.Println("## NodeBalancer create") - clientConnThrottle := 20 nb, err := linodeClient.CreateNodeBalancer(context.Background(), linodego.NodeBalancerCreateOptions{ - ClientConnThrottle: &clientConnThrottle, - Region: "us-southeast", - FirewallID: GetFirewallID(), + ClientConnThrottle: linodego.Pointer(20), + Region: linodego.Pointer("us-southeast"), + FirewallID: linodego.Pointer(GetFirewallID()), }) if err != nil { log.Fatal(err) @@ -154,13 +152,13 @@ func ExampleClient_CreateNodeBalancerNode() { } instanceOpts := linodego.InstanceCreateOptions{ - Label: "nodebalancer-example-instance", - RootPass: randPassword(), + Label: linodego.Pointer("nodebalancer-example-instance"), + RootPass: linodego.Pointer(randPassword()), Region: "us-southeast", Type: "g6-nanode-1", - Image: "linode/debian9", + Image: linodego.Pointer("linode/debian9"), Booted: linodego.Pointer(false), - FirewallID: GetFirewallID(), + FirewallID: linodego.Pointer(GetFirewallID()), } instance, err := linodeClient.CreateInstance(context.Background(), instanceOpts) if err != nil { @@ -185,7 +183,7 @@ func ExampleClient_CreateNodeBalancerNode() { fmt.Println("## NodeBalancer Node update") updateOpts := nbn.GetUpdateOptions() - updateOpts.Address = fmt.Sprintf("%s:8080", ip.Address) + updateOpts.Address = linodego.Pointer(fmt.Sprintf("%s:8080", ip.Address)) nbn, err = linodeClient.UpdateNodeBalancerNode(context.Background(), nb.ID, nbc.ID, nbn.ID, updateOpts) if err != nil { log.Fatal(err) diff --git a/test/integration/firewall_rules_test.go b/test/integration/firewall_rules_test.go index a597eed5e..f296894df 100644 --- a/test/integration/firewall_rules_test.go +++ b/test/integration/firewall_rules_test.go @@ -12,11 +12,11 @@ var ( testFirewallRule = linodego.FirewallRule{ Label: "go-fwrule-test", Action: "ACCEPT", - Ports: "22", + Ports: linodego.Pointer("22"), Protocol: "TCP", Addresses: linodego.NetworkAddresses{ - IPv4: &[]string{"0.0.0.0/0"}, - IPv6: &[]string{"::0/0"}, + IPv4: []string{"0.0.0.0/0"}, + IPv6: []string{"::0/0"}, }, } @@ -58,11 +58,11 @@ func TestFirewallRules_Update(t *testing.T) { { Label: testFirewallRule.Label + "_r", Action: "DROP", - Ports: "22", + Ports: linodego.Pointer("22"), Protocol: "TCP", Addresses: linodego.NetworkAddresses{ - IPv4: &[]string{"0.0.0.0/0"}, - IPv6: &[]string{"::0/0"}, + IPv4: []string{"0.0.0.0/0"}, + IPv6: []string{"::0/0"}, }, }, }, diff --git a/test/integration/firewalls_devices_test.go b/test/integration/firewalls_devices_test.go index 93559cf7e..1284f43ea 100644 --- a/test/integration/firewalls_devices_test.go +++ b/test/integration/firewalls_devices_test.go @@ -17,6 +17,9 @@ func TestFirewallDevices_List_smoke(t *testing.T) { defer teardown() firewall, teardownFirewall, err := createFirewall(t, client, func(opts *linodego.FirewallCreateOptions) { + if opts.Devices == nil { + opts.Devices = &linodego.DevicesCreationOptions{} + } opts.Devices.Linodes = []int{instance.ID} }) if err != nil { diff --git a/test/integration/firewalls_test.go b/test/integration/firewalls_test.go index 666760e34..bd58257d8 100644 --- a/test/integration/firewalls_test.go +++ b/test/integration/firewalls_test.go @@ -10,7 +10,7 @@ import ( ) var testFirewallCreateOpts = linodego.FirewallCreateOptions{ - Label: "linodego-fw-test", + Label: linodego.Pointer("linodego-fw-test"), Rules: testFirewallRuleSet, // borrowed from firewall_rules.test.go Tags: []string{"testing"}, } @@ -26,7 +26,7 @@ var ignoreFirewallTimestamps = cmpopts.IgnoreFields(linodego.Firewall{}, "Create func TestFirewalls_List_smoke(t *testing.T) { client, _, teardown, err := setupFirewall(t, []firewallModifier{ func(createOpts *linodego.FirewallCreateOptions) { - createOpts.Label = "linodego-fw-test" + createOpts.Label = linodego.Pointer("linodego-fw-test") }, }, "fixtures/TestFirewalls_List") if err != nil { @@ -52,8 +52,8 @@ func TestFirewall_Get(t *testing.T) { Action: "DROP", Protocol: linodego.ICMP, Addresses: linodego.NetworkAddresses{ - IPv4: &[]string{"0.0.0.0/0"}, - IPv6: &[]string{"::/0"}, + IPv4: []string{"0.0.0.0/0"}, + IPv6: []string{"::/0"}, }, }, }, @@ -62,7 +62,7 @@ func TestFirewall_Get(t *testing.T) { } client, created, teardown, err := setupFirewall(t, []firewallModifier{ func(createOpts *linodego.FirewallCreateOptions) { - createOpts.Label = "linodego-fw-test" + createOpts.Label = linodego.Pointer("linodego-fw-test") createOpts.Rules = rules }, }, "fixtures/TestFirewall_Get") @@ -90,7 +90,7 @@ func TestFirewall_Update(t *testing.T) { Action: "DROP", Protocol: linodego.ICMP, Addresses: linodego.NetworkAddresses{ - IPv4: &[]string{"0.0.0.0/0"}, + IPv4: []string{"0.0.0.0/0"}, }, }, }, @@ -99,7 +99,7 @@ func TestFirewall_Update(t *testing.T) { client, firewall, teardown, err := setupFirewall(t, []firewallModifier{ func(createOpts *linodego.FirewallCreateOptions) { - createOpts.Label = "linodego-fw-test" + createOpts.Label = linodego.Pointer("linodego-fw-test") createOpts.Rules = rules createOpts.Tags = []string{"test"} }, @@ -110,23 +110,23 @@ func TestFirewall_Update(t *testing.T) { defer teardown() updateOpts := firewall.GetUpdateOptions() - updateOpts.Status = linodego.FirewallDisabled - updateOpts.Label = firewall.Label + "-updated" - updateOpts.Tags = &[]string{} + updateOpts.Status = linodego.Pointer(linodego.FirewallDisabled) + updateOpts.Label = linodego.Pointer(firewall.Label + "-updated") + updateOpts.Tags = []string{} updated, err := client.UpdateFirewall(context.Background(), firewall.ID, updateOpts) if err != nil { t.Error(err) } - if !cmp.Equal(updated.Tags, *updateOpts.Tags) { - t.Errorf("expected tags to be updated: %s", cmp.Diff(updated.Tags, *updateOpts.Tags)) + if !cmp.Equal(updated.Tags, updateOpts.Tags) { + t.Errorf("expected tags to be updated: %s", cmp.Diff(updated.Tags, updateOpts.Tags)) } - if updated.Status != updateOpts.Status { - t.Errorf("expected status %s but got %s", updateOpts.Status, updated.Status) + if updateOpts.Status == nil || updated.Status != *updateOpts.Status { + t.Errorf("expected status %s but got %s", *updateOpts.Status, updated.Status) } - if updated.Label != updateOpts.Label { - t.Errorf(`expected label to be "%s" but got "%s"`, updateOpts.Label, updated.Label) + if updateOpts.Label == nil || updated.Label != *updateOpts.Label { + t.Errorf(`expected label to be "%s" but got "%s"`, *updateOpts.Label, updated.Label) } } diff --git a/test/integration/fixtures/TestObjectStorageKeys_Limited.yaml b/test/integration/fixtures/TestObjectStorageKeys_Limited.yaml index 1b0984136..72a290754 100644 --- a/test/integration/fixtures/TestObjectStorageKeys_Limited.yaml +++ b/test/integration/fixtures/TestObjectStorageKeys_Limited.yaml @@ -14,7 +14,7 @@ interactions: url: https://api.linode.com/v4beta/object-storage/keys method: POST response: - body: '{"id": 1654586, "label": "go-test-def", "access_key": "[SANITIZED]", "secret_key": + body: '{"id": 1776813, "label": "go-test-def", "access_key": "[SANITIZED]", "secret_key": "[SANITIZED]", "limited": true, "bucket_access": [{"cluster": "us-east-1", "bucket_name": "go-bucket-test-def", "permissions": "read_only", "region": "us-east"}, {"cluster": "us-east-1", "bucket_name": "go-bucket-test-def", "permissions": "read_write", @@ -44,7 +44,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Jan 2025 06:04:05 GMT + - Wed, 19 Feb 2025 18:29:41 GMT Pragma: - no-cache Strict-Transport-Security: @@ -77,7 +77,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/object-storage/keys/1654586 + url: https://api.linode.com/v4beta/object-storage/keys/1776813 method: DELETE response: body: '{}' @@ -105,7 +105,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Jan 2025 06:04:07 GMT + - Wed, 19 Feb 2025 18:29:44 GMT Pragma: - no-cache Strict-Transport-Security: diff --git a/test/integration/fixtures/TestObjectStorageKeys_Limited_Bucket.yaml b/test/integration/fixtures/TestObjectStorageKeys_Limited_Bucket.yaml index 1c01b5723..84692ae37 100644 --- a/test/integration/fixtures/TestObjectStorageKeys_Limited_Bucket.yaml +++ b/test/integration/fixtures/TestObjectStorageKeys_Limited_Bucket.yaml @@ -42,7 +42,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Jan 2025 06:04:03 GMT + - Wed, 19 Feb 2025 18:29:38 GMT Pragma: - no-cache Strict-Transport-Security: @@ -103,7 +103,7 @@ interactions: Content-Type: - application/json Expires: - - Wed, 08 Jan 2025 06:04:10 GMT + - Wed, 19 Feb 2025 18:29:48 GMT Pragma: - no-cache Strict-Transport-Security: diff --git a/test/integration/TestReservedIPAddresses_GetInstanceIPReservationStatus.yaml b/test/integration/fixtures/TestReservedIPAddresses_GetInstanceIPReservationStatus.yaml similarity index 76% rename from test/integration/TestReservedIPAddresses_GetInstanceIPReservationStatus.yaml rename to test/integration/fixtures/TestReservedIPAddresses_GetInstanceIPReservationStatus.yaml index 1ca7cdb20..25d9cdaba 100644 --- a/test/integration/TestReservedIPAddresses_GetInstanceIPReservationStatus.yaml +++ b/test/integration/fixtures/TestReservedIPAddresses_GetInstanceIPReservationStatus.yaml @@ -14,8 +14,8 @@ interactions: url: https://api.linode.com/v4beta/networking/reserved/ips method: POST response: - body: '{"address": "69.164.211.224", "gateway": "69.164.211.1", "subnet_mask": - "255.255.255.0", "prefix": 24, "type": "ipv4", "public": true, "rdns": "69-164-211-224.ip.linodeusercontent.com", + body: '{"address": "66.175.210.129", "gateway": "66.175.210.1", "subnet_mask": + "255.255.255.0", "prefix": 24, "type": "ipv4", "public": true, "rdns": "66-175-210-129.ip.linodeusercontent.com", "linode_id": null, "region": "us-east", "vpc_nat_1_1": null, "reserved": true}' headers: Access-Control-Allow-Credentials: @@ -41,7 +41,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 30 Sep 2024 21:11:18 GMT + - Thu, 13 Feb 2025 16:24:15 GMT Pragma: - no-cache Strict-Transport-Security: @@ -58,14 +58,14 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "800" + - "1600" X-Xss-Protection: - 1; mode=block status: 200 OK code: 200 duration: "" - request: - body: '{"region":"us-east","type":"g6-nanode-1","label":"go-test-ins-reserved-ip-iciv55fz7379","root_pass":"i.L9In8UuA1\\''+xrW8@HG0[hE91\\?29:40@tkUGG\u003ek:.3c63nRR9!jYIc7j.=Nfm","image":"linode/alpine3.17","interfaces":[{"purpose":"public"}],"booted":false,"ipv4":["69.164.211.224"]}' + body: '{"region":"us-east","type":"g6-nanode-1","label":"go-test-ins-reserved-ip-51wnej2z10p6","root_pass":"3$0-68$:{^;C6L)hSj4Rd;nPw(3(q7TPesW[TF4q:AozB4Mi:gu608ecC4SX)3|9","image":"linode/alpine3.17","interfaces":[{"ipam_address":"","label":"","purpose":"public"}],"booted":false,"ipv4":["66.175.210.129"]}' form: {} headers: Accept: @@ -77,17 +77,17 @@ interactions: url: https://api.linode.com/v4beta/linode/instances method: POST response: - body: '{"id": 64660675, "label": "go-test-ins-reserved-ip-iciv55fz7379", "group": + body: '{"id": 71864085, "label": "go-test-ins-reserved-ip-51wnej2z10p6", "group": "", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", - "type": "g6-nanode-1", "ipv4": ["69.164.211.224"], "ipv6": "2600:3c03::f03c:95ff:feb1:6cca/128", + "type": "g6-nanode-1", "ipv4": ["66.175.210.129"], "ipv6": "1234::5678/128", "image": "linode/alpine3.17", "region": "us-east", "site_type": "core", "specs": - {"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": - {"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": - 10000}, "backups": {"enabled": false, "available": false, "schedule": {"day": - null, "window": null}, "last_successful": null}, "hypervisor": "kvm", "watchdog_enabled": - true, "tags": [], "host_uuid": "b3417256e635b83e03311cd43bf9303dacc5a75d", "has_user_data": - false, "placement_group": null, "disk_encryption": "disabled", "lke_cluster_id": - null, "capabilities": []}' + {"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000, "accelerated_devices": + 0}, "alerts": {"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": + 80, "io": 10000}, "backups": {"enabled": true, "available": false, "schedule": + {"day": null, "window": null}, "last_successful": null}, "hypervisor": "kvm", + "watchdog_enabled": true, "tags": [], "host_uuid": "28f0a07a22e3e83d9b15e2ce39641c3e241140a7", + "has_user_data": false, "placement_group": null, "disk_encryption": "enabled", + "lke_cluster_id": null, "capabilities": ["SMTP Enabled"]}' headers: Access-Control-Allow-Credentials: - "true" @@ -110,7 +110,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 30 Sep 2024 21:11:20 GMT + - Thu, 13 Feb 2025 16:24:16 GMT Pragma: - no-cache Strict-Transport-Security: @@ -128,7 +128,7 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "10" + - "8" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -144,19 +144,19 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/linode/instances/64660675/ips + url: https://api.linode.com/v4beta/linode/instances/71864085/ips method: GET response: - body: '{"ipv4": {"public": [{"address": "69.164.211.224", "gateway": "69.164.211.1", + body: '{"ipv4": {"public": [{"address": "66.175.210.129", "gateway": "66.175.210.1", "subnet_mask": "255.255.255.0", "prefix": 24, "type": "ipv4", "public": true, - "rdns": "69-164-211-224.ip.linodeusercontent.com", "linode_id": 64660675, "region": + "rdns": "66-175-210-129.ip.linodeusercontent.com", "linode_id": 71864085, "region": "us-east", "vpc_nat_1_1": null, "reserved": true}], "private": [], "shared": - [], "reserved": [], "vpc": []}, "ipv6": {"slaac": {"address": "2600:3c03::f03c:95ff:feb1:6cca", - "gateway": "fe80::1", "subnet_mask": "ffff:ffff:ffff:ffff::", "prefix": 64, - "type": "ipv6", "rdns": null, "linode_id": 64660675, "region": "us-east", "public": - true}, "link_local": {"address": "fe80::f03c:95ff:feb1:6cca", "gateway": "fe80::1", - "subnet_mask": "ffff:ffff:ffff:ffff::", "prefix": 64, "type": "ipv6", "rdns": - null, "linode_id": 64660675, "region": "us-east", "public": false}, "global": + [], "reserved": [], "vpc": []}, "ipv6": {"slaac": {"address": "1234::5678", + "gateway": "1234::5678", "subnet_mask": "1234::5678", "prefix": 64, + "type": "ipv6", "rdns": null, "linode_id": 71864085, "region": "us-east", "public": + true}, "link_local": {"address": "1234::5678", "gateway": "1234::5678", + "subnet_mask": "1234::5678", "prefix": 64, "type": "ipv6", "rdns": + null, "linode_id": 71864085, "region": "us-east", "public": false}, "global": []}}' headers: Access-Control-Allow-Credentials: @@ -182,7 +182,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 30 Sep 2024 21:11:20 GMT + - Thu, 13 Feb 2025 16:24:17 GMT Pragma: - no-cache Strict-Transport-Security: @@ -200,14 +200,14 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "800" + - "1600" X-Xss-Protection: - 1; mode=block status: 200 OK code: 200 duration: "" - request: - body: '{"region":"us-east","type":"g6-nanode-1","label":"test-instance-ephemeral-ip","root_pass":"*Y3,P,1;B~2r=8G5}s|Pbe8xI\u003e^02uXO0ur964HOd\u003c2{vHsf-^8Utz\u0026ZB64oMxW\u0026"}' + body: '{"region":"us-east","type":"g6-nanode-1","label":"test-instance-ephemeral-ip","root_pass":"7OX]:+,C0QqY(auonT,Ck\u003enVB@/2x43CeVtf58hM:6M9y60M##Ij)566^I38s*r\u0026"}' form: {} headers: Accept: @@ -219,17 +219,17 @@ interactions: url: https://api.linode.com/v4beta/linode/instances method: POST response: - body: '{"id": 64660677, "label": "test-instance-ephemeral-ip", "group": "", "status": + body: '{"id": 71864091, "label": "test-instance-ephemeral-ip", "group": "", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", - "type": "g6-nanode-1", "ipv4": ["45.56.102.65"], "ipv6": "2600:3c03::f03c:95ff:feb1:6c9d/128", + "type": "g6-nanode-1", "ipv4": ["45.79.152.254"], "ipv6": "1234::5678/128", "image": null, "region": "us-east", "site_type": "core", "specs": {"disk": 25600, - "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu": - 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": 10000}, - "backups": {"enabled": false, "available": false, "schedule": {"day": null, - "window": null}, "last_successful": null}, "hypervisor": "kvm", "watchdog_enabled": - true, "tags": [], "host_uuid": "f3bbdb58fa73e88a3294e17d587a130138658c53", "has_user_data": - false, "placement_group": null, "disk_encryption": "disabled", "lke_cluster_id": - null, "capabilities": []}' + "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000, "accelerated_devices": + 0}, "alerts": {"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": + 80, "io": 10000}, "backups": {"enabled": true, "available": false, "schedule": + {"day": null, "window": null}, "last_successful": null}, "hypervisor": "kvm", + "watchdog_enabled": true, "tags": [], "host_uuid": "4e5e2d7864340c2da993d0ce9063b435129f11bb", + "has_user_data": false, "placement_group": null, "disk_encryption": "enabled", + "lke_cluster_id": null, "capabilities": ["SMTP Enabled"]}' headers: Access-Control-Allow-Credentials: - "true" @@ -247,20 +247,19 @@ interactions: - max-age=0, no-cache, no-store Connection: - keep-alive - Content-Length: - - "851" Content-Security-Policy: - default-src 'none' Content-Type: - application/json Expires: - - Mon, 30 Sep 2024 21:11:20 GMT + - Thu, 13 Feb 2025 16:24:17 GMT Pragma: - no-cache Strict-Transport-Security: - max-age=31536000 Vary: - Authorization, X-Filter + - Accept-Encoding X-Accepted-Oauth-Scopes: - linodes:read_write X-Content-Type-Options: @@ -271,7 +270,7 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "10" + - "8" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -287,19 +286,19 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/linode/instances/64660677/ips + url: https://api.linode.com/v4beta/linode/instances/71864091/ips method: GET response: - body: '{"ipv4": {"public": [{"address": "45.56.102.65", "gateway": "45.56.102.1", + body: '{"ipv4": {"public": [{"address": "45.79.152.254", "gateway": "45.79.152.1", "subnet_mask": "255.255.255.0", "prefix": 24, "type": "ipv4", "public": true, - "rdns": "45-56-102-65.ip.linodeusercontent.com", "linode_id": 64660677, "region": + "rdns": "45-79-152-254.ip.linodeusercontent.com", "linode_id": 71864091, "region": "us-east", "vpc_nat_1_1": null, "reserved": false}], "private": [], "shared": - [], "reserved": [], "vpc": []}, "ipv6": {"slaac": {"address": "2600:3c03::f03c:95ff:feb1:6c9d", - "gateway": "fe80::1", "subnet_mask": "ffff:ffff:ffff:ffff::", "prefix": 64, - "type": "ipv6", "rdns": null, "linode_id": 64660677, "region": "us-east", "public": - true}, "link_local": {"address": "fe80::f03c:95ff:feb1:6c9d", "gateway": "fe80::1", - "subnet_mask": "ffff:ffff:ffff:ffff::", "prefix": 64, "type": "ipv6", "rdns": - null, "linode_id": 64660677, "region": "us-east", "public": false}, "global": + [], "reserved": [], "vpc": []}, "ipv6": {"slaac": {"address": "1234::5678", + "gateway": "1234::5678", "subnet_mask": "1234::5678", "prefix": 64, + "type": "ipv6", "rdns": null, "linode_id": 71864091, "region": "us-east", "public": + true}, "link_local": {"address": "1234::5678", "gateway": "1234::5678", + "subnet_mask": "1234::5678", "prefix": 64, "type": "ipv6", "rdns": + null, "linode_id": 71864091, "region": "us-east", "public": false}, "global": []}}' headers: Access-Control-Allow-Credentials: @@ -319,13 +318,13 @@ interactions: Connection: - keep-alive Content-Length: - - "813" + - "815" Content-Security-Policy: - default-src 'none' Content-Type: - application/json Expires: - - Mon, 30 Sep 2024 21:11:21 GMT + - Thu, 13 Feb 2025 16:24:18 GMT Pragma: - no-cache Strict-Transport-Security: @@ -343,7 +342,7 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "800" + - "1600" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -359,7 +358,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/linode/instances/64660677 + url: https://api.linode.com/v4beta/linode/instances/71864091 method: DELETE response: body: '{}' @@ -387,7 +386,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 30 Sep 2024 21:11:22 GMT + - Thu, 13 Feb 2025 16:24:20 GMT Pragma: - no-cache Strict-Transport-Security: @@ -404,7 +403,7 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "800" + - "1600" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -420,7 +419,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/linode/instances/64660675 + url: https://api.linode.com/v4beta/linode/instances/71864085 method: DELETE response: body: '{}' @@ -448,7 +447,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 30 Sep 2024 21:11:25 GMT + - Thu, 13 Feb 2025 16:24:22 GMT Pragma: - no-cache Strict-Transport-Security: @@ -465,7 +464,7 @@ interactions: X-Oauth-Scopes: - '*' X-Ratelimit-Limit: - - "800" + - "1600" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -481,7 +480,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/networking/reserved/ips/69.164.211.224 + url: https://api.linode.com/v4beta/networking/reserved/ips/66.175.210.129 method: DELETE response: body: '{}' @@ -509,7 +508,7 @@ interactions: Content-Type: - application/json Expires: - - Mon, 30 Sep 2024 21:11:25 GMT + - Thu, 13 Feb 2025 16:24:22 GMT Pragma: - no-cache Strict-Transport-Security: diff --git a/test/integration/images_test.go b/test/integration/images_test.go index 572fdd3d5..da61efa74 100644 --- a/test/integration/images_test.go +++ b/test/integration/images_test.go @@ -75,7 +75,7 @@ func TestImage_Upload(t *testing.T) { image, uploadURL, err := client.CreateImageUpload(context.Background(), ImageCreateUploadOptions{ Region: "us-ord", Label: "linodego-image-test", - Description: "An image that does stuff.", + Description: Pointer("An image that does stuff."), }) if err != nil { t.Errorf("Failed to create image upload: %v", err) @@ -114,8 +114,8 @@ func TestImage_CreateUpload(t *testing.T) { Region: getRegionsWithCaps(t, client, []string{"Metadata"})[0], Label: "linodego-image-create-upload", - Description: "An image that does stuff.", - CloudInit: true, + Description: Pointer("An image that does stuff."), + CloudInit: Pointer(true), Tags: &[]string{"foo", "bar"}, }) if err != nil { @@ -159,7 +159,7 @@ func TestImage_CloudInit(t *testing.T) { image, err := client.CreateImage(context.Background(), ImageCreateOptions{ DiskID: instanceDisks[0].ID, Label: "linodego-test-cloud-init", - CloudInit: true, + CloudInit: Pointer(true), Tags: &[]string{"test1", "test2"}, }) if err != nil { @@ -186,7 +186,7 @@ func TestImage_Replicate(t *testing.T) { image, uploadURL, err := client.CreateImageUpload(context.Background(), ImageCreateUploadOptions{ Region: availableRegions[1], Label: "linodego-image-replication", - Description: "An image that does stuff.", + Description: Pointer("An image that does stuff."), }) if err != nil { t.Errorf("Failed to create image upload: %v", err) diff --git a/test/integration/instance_config_test.go b/test/integration/instance_config_test.go index 90af8b257..ff0cd9366 100644 --- a/test/integration/instance_config_test.go +++ b/test/integration/instance_config_test.go @@ -78,13 +78,12 @@ func setupInstanceWithVPCAndNATOneToOne(t *testing.T, fixturesYaml string) ( } updateConfigOpts := config.GetUpdateOptions() - NAT1To1Any := "any" updateConfigOpts.Interfaces = []InstanceConfigInterfaceCreateOptions{ { - Purpose: InterfacePurposeVPC, + Purpose: Pointer(InterfacePurposeVPC), SubnetID: &vpcSubnet.ID, IPv4: &VPCIPv4{ - NAT1To1: &NAT1To1Any, + NAT1To1: Pointer("any"), }, }, } @@ -121,20 +120,19 @@ func setupInstanceWith3Interfaces(t *testing.T, fixturesYaml string) ( } updateConfigOpts := config.GetUpdateOptions() - NAT1To1Any := "any" updateConfigOpts.Interfaces = []InstanceConfigInterfaceCreateOptions{ { - Purpose: InterfacePurposePublic, + Purpose: Pointer(InterfacePurposePublic), }, { - Purpose: InterfacePurposeVLAN, - Label: "testvlan", + Purpose: Pointer(InterfacePurposeVLAN), + Label: Pointer("testvlan"), }, { - Purpose: InterfacePurposeVPC, + Purpose: Pointer(InterfacePurposeVPC), SubnetID: &vpcSubnet.ID, IPv4: &VPCIPv4{ - NAT1To1: &NAT1To1Any, + NAT1To1: Pointer("any"), }, }, } @@ -162,7 +160,7 @@ func TestInstance_ConfigInterfaces_AppendDelete(t *testing.T) { } appednOpts := InstanceConfigInterfaceCreateOptions{ - Purpose: InterfacePurposeVPC, + Purpose: Pointer(InterfacePurposeVPC), SubnetID: &subnet.ID, } @@ -177,7 +175,7 @@ func TestInstance_ConfigInterfaces_AppendDelete(t *testing.T) { } if intfc.ID == 0 || - appednOpts.Purpose != intfc.Purpose || + *appednOpts.Purpose != intfc.Purpose || *appednOpts.SubnetID != *intfc.SubnetID { t.Errorf( "failed to append an interface to instance %v config %v", @@ -315,17 +313,17 @@ func TestInstance_ConfigInterfaces_Update(t *testing.T) { updateConfigOpts.Interfaces = []InstanceConfigInterfaceCreateOptions{ { - Purpose: InterfacePurposePublic, + Purpose: Pointer(InterfacePurposePublic), }, { - Purpose: InterfacePurposeVLAN, - Label: "testvlan", + Purpose: Pointer(InterfacePurposeVLAN), + Label: Pointer("testvlan"), }, { - Purpose: InterfacePurposeVPC, + Purpose: Pointer(InterfacePurposeVPC), SubnetID: &vpcSubnet.ID, IPv4: &VPCIPv4{ - VPC: "192.168.0.87", + VPC: Pointer("192.168.0.87"), }, }, } @@ -345,11 +343,10 @@ func TestInstance_ConfigInterfaces_Update(t *testing.T) { interfaceOptsList[index] = configInterface.GetCreateOptions() } - if !reflect.DeepEqual( - interfaceOptsList, - updateConfigOpts.Interfaces, - ) { - t.Error("failed to update linode interfaces: configs do not match") + // Compare each interface in the result with the expected values + for i, instanceConfigInterface := range result.Interfaces { + expectedInstanceConfigInterface := updateConfigOpts.Interfaces[i] + checkInstanceConfigInterfaceMismatch(t, i, instanceConfigInterface, expectedInstanceConfigInterface) } // Ensure that a nil value will not update interfaces @@ -362,11 +359,10 @@ func TestInstance_ConfigInterfaces_Update(t *testing.T) { interfaceOptsList[index] = configInterface.GetCreateOptions() } - if !reflect.DeepEqual( - interfaceOptsList, - updateConfigOpts.Interfaces, - ) { - t.Error("failed to update linode interfaces: configs do not match") + // Compare each interface in the result with the expected values + for i, instanceConfigInterface := range result.Interfaces { + expectedInstanceConfigInterface := updateConfigOpts.Interfaces[i] + checkInstanceConfigInterfaceMismatch(t, i, instanceConfigInterface, expectedInstanceConfigInterface) } } @@ -390,7 +386,7 @@ func TestInstance_ConfigInterface_Update(t *testing.T) { instance.ID, config.ID, InstanceConfigInterfaceCreateOptions{ - Purpose: InterfacePurposeVPC, + Purpose: Pointer(InterfacePurposeVPC), SubnetID: &vpcSubnet.ID, IPRanges: []string{"192.168.0.5/32"}, }, @@ -399,7 +395,7 @@ func TestInstance_ConfigInterface_Update(t *testing.T) { t.Errorf("an error occurs when appending an interface to config %v: %v", config.ID, err) } updateOpts := intfc.GetUpdateOptions() - updateOpts.Primary = true + updateOpts.Primary = Pointer(true) updatedIntfc, err := client.UpdateInstanceConfigInterface( context.Background(), @@ -412,7 +408,7 @@ func TestInstance_ConfigInterface_Update(t *testing.T) { t.Errorf("an error occurs when updating an interface in config %v", config.ID) } - if !(updatedIntfc.Primary == updateOpts.Primary) { + if updateOpts.Primary == nil || updatedIntfc.Primary != *updateOpts.Primary { t.Errorf("updating interface %v didn't succeed", intfc.ID) } @@ -420,13 +416,12 @@ func TestInstance_ConfigInterface_Update(t *testing.T) { t.Errorf("unexpected value for IPRanges: %s", updatedIntfc.IPRanges[0]) } - NAT1To1Any := "any" updateOpts.IPv4 = &VPCIPv4{ - VPC: "192.168.0.10", - NAT1To1: &NAT1To1Any, + VPC: Pointer("192.168.0.10"), + NAT1To1: Pointer("any"), } newIPRanges := make([]string, 0) - updateOpts.IPRanges = &newIPRanges + updateOpts.IPRanges = newIPRanges updatedIntfc, err = client.UpdateInstanceConfigInterface( context.Background(), @@ -439,8 +434,8 @@ func TestInstance_ConfigInterface_Update(t *testing.T) { t.Errorf("an error occurs when updating an interface in config %v", config.ID) } - if !(updatedIntfc.Primary == updateOpts.Primary && - updateOpts.IPv4.VPC == updatedIntfc.IPv4.VPC) { + if !(updatedIntfc.Primary == *updateOpts.Primary && + *updateOpts.IPv4.VPC == *updatedIntfc.IPv4.VPC) { t.Errorf("updating interface %v didn't succeed", intfc.ID) } @@ -476,9 +471,9 @@ func TestInstance_Config_Update(t *testing.T) { } updateConfigOpts := InstanceConfigUpdateOptions{ - Label: "go-conf-test-" + randLabel(), + Label: Pointer("go-conf-test-" + randLabel()), Devices: &InstanceConfigDeviceMap{}, - RootDevice: "/dev/root", + RootDevice: Pointer("/dev/root"), } _, err = client.UpdateInstanceConfig(context.Background(), instance.ID, config.ID, updateConfigOpts) @@ -486,3 +481,30 @@ func TestInstance_Config_Update(t *testing.T) { t.Error(err) } } + +func checkInstanceConfigInterfaceMismatch(t *testing.T, i int, icf InstanceConfigInterface, expectedIcf InstanceConfigInterfaceCreateOptions) { + // Compare Purpose + if icf.Purpose != *expectedIcf.Purpose { + t.Errorf("Interface %d: Purpose mismatch: expected %v, got %v", i, *expectedIcf.Purpose, icf.Purpose) + } + + // Compare Label + if expectedIcf.Label != nil && icf.Label != *expectedIcf.Label { + t.Errorf("Interface %d: Label mismatch: expected %v, got %v", i, *expectedIcf.Label, icf.Label) + } + + // Compare SubnetID + if icf.SubnetID != nil && expectedIcf.SubnetID != nil && *icf.SubnetID != *expectedIcf.SubnetID { + t.Errorf("Interface %d: SubnetID mismatch: expected %v, got %v", i, *expectedIcf.SubnetID, *icf.SubnetID) + } + + // Compare IPv4 VPC + if icf.IPv4 != nil && expectedIcf.IPv4 != nil && *icf.IPv4.VPC != *expectedIcf.IPv4.VPC { + t.Errorf("Interface %d: IPv4 VPC mismatch: expected %v, got %v", i, *expectedIcf.IPv4.VPC, *icf.IPv4.VPC) + } + + // Compare IPRanges + if icf.IPRanges != nil && expectedIcf.IPRanges != nil && !reflect.DeepEqual(icf.IPRanges, expectedIcf.IPRanges) { + t.Errorf("Interface %d: IPRanges mismatch: expected %v, got %v", i, expectedIcf.IPRanges, icf.IPRanges) + } +} diff --git a/test/integration/instance_firewalls_test.go b/test/integration/instance_firewalls_test.go index b4ed83ed7..3558bcfd3 100644 --- a/test/integration/instance_firewalls_test.go +++ b/test/integration/instance_firewalls_test.go @@ -10,7 +10,7 @@ import ( func TestInstanceFirewalls_List(t *testing.T) { client, instance, _, teardown, err := setupInstanceFirewall(t, []firewallModifier{ func(createOpts *linodego.FirewallCreateOptions) { - createOpts.Label = "linodego-fw-ins-test" + createOpts.Label = linodego.Pointer("linodego-fw-ins-test") }, }, "fixtures/TestInstanceFirewalls_List") if err != nil { @@ -32,12 +32,12 @@ func setupInstanceFirewall(t *testing.T, firewallModifiers []firewallModifier, f t.Helper() client, instance, instanceTeardown, err := setupInstance(t, fixturesYaml, false, func(client *linodego.Client, opts *linodego.InstanceCreateOptions) { - opts.Label = "linodego-fw-inst-test" + opts.Label = linodego.Pointer("linodego-fw-inst-test") }) device := linodego.DevicesCreationOptions{Linodes: []int{instance.ID}} firewallModifiers = append(firewallModifiers, func(createOpts *linodego.FirewallCreateOptions) { - createOpts.Devices = device + createOpts.Devices = &device }) firewall, firewallTeardown, err := createFirewall(t, client, firewallModifiers...) diff --git a/test/integration/instance_reserved_ips_test.go b/test/integration/instance_reserved_ips_test.go index 423d3463d..16862d9b2 100644 --- a/test/integration/instance_reserved_ips_test.go +++ b/test/integration/instance_reserved_ips_test.go @@ -39,17 +39,17 @@ func createInstanceWithReservedIP( t.Helper() createOpts := linodego.InstanceCreateOptions{ - Label: "go-test-ins-reserved-ip-" + randLabel(), + Label: linodego.Pointer("go-test-ins-reserved-ip-" + randLabel()), Region: "us-east", Type: "g6-nanode-1", Booted: linodego.Pointer(false), - Image: "linode/alpine3.17", - RootPass: randPassword(), + Image: linodego.Pointer("linode/alpine3.17"), + RootPass: linodego.Pointer(randPassword()), Interfaces: []linodego.InstanceConfigInterfaceCreateOptions{ { - Purpose: linodego.InterfacePurposePublic, - Label: "", - IPAMAddress: "", + Purpose: linodego.Pointer(linodego.InterfacePurposePublic), + Label: linodego.Pointer(""), + IPAMAddress: linodego.Pointer(""), }, }, IPv4: []string{reservedIP}, @@ -216,8 +216,8 @@ func TestInstance_AddReservedIPToInstance(t *testing.T) { instance, err := client.CreateInstance(context.Background(), linodego.InstanceCreateOptions{ Region: "us-east", Type: "g6-nanode-1", - Label: "test-instance-for-ip-reservation", - RootPass: randPassword(), + Label: linodego.Pointer("test-instance-for-ip-reservation"), + RootPass: linodego.Pointer(randPassword()), }) if err != nil { t.Fatalf("Error creating test instance: %v", err) @@ -279,8 +279,8 @@ func TestInstance_AddReservedIPToInstanceVariants(t *testing.T) { instance, err := client.CreateInstance(context.Background(), linodego.InstanceCreateOptions{ Region: "us-east", Type: "g6-nanode-1", - Label: "test-instance-for-ip-reservation", - RootPass: randPassword(), + Label: linodego.Pointer("test-instance-for-ip-reservation"), + RootPass: linodego.Pointer(randPassword()), }) if err != nil { t.Fatalf("Error creating test instance: %v", err) @@ -498,8 +498,8 @@ func TestInstance_DeleteInstanceVariants(t *testing.T) { newInstance, err := client.CreateInstance(context.Background(), linodego.InstanceCreateOptions{ Region: "us-east", Type: "g6-nanode-1", - Label: "test-instance-freed-ip", - RootPass: randPassword(), + Label: linodego.Pointer("test-instance-freed-ip"), + RootPass: linodego.Pointer(randPassword()), IPv4: []string{reservedIP.Address}, }) if err != nil { @@ -527,8 +527,8 @@ func TestInstance_DeleteInstanceVariants(t *testing.T) { ephemeralInstance, err := client.CreateInstance(context.Background(), linodego.InstanceCreateOptions{ Region: "us-east", Type: "g6-nanode-1", - Label: "ephemeral-ip-test", - RootPass: randPassword(), + Label: linodego.Pointer("ephemeral-ip-test"), + RootPass: linodego.Pointer(randPassword()), }) if err != nil { t.Fatalf("Failed to create Linode with ephemeral IP: %v", err) diff --git a/test/integration/instance_snapshots_test.go b/test/integration/instance_snapshots_test.go index 3854aa3dc..d09f3cce3 100644 --- a/test/integration/instance_snapshots_test.go +++ b/test/integration/instance_snapshots_test.go @@ -30,7 +30,7 @@ func TestInstanceBackups_List(t *testing.T) { t.Fatalf("failed to get instance: %s", err) } - if !instance.Backups.Available { + if instance.Backups.Available == nil || !*instance.Backups.Available { t.Fatalf("expected Backups.Available to be true, got false") } @@ -96,7 +96,7 @@ func setupInstanceBackup(t *testing.T, fixturesYaml string) (*linodego.Client, * createOpts := linodego.InstanceDiskCreateOptions{ Size: 10, Label: "linodego-disk-test", - Filesystem: "ext4", + Filesystem: linodego.Pointer("ext4"), } disk, err := client.CreateInstanceDisk(context.Background(), instance.ID, createOpts) if err != nil { diff --git a/test/integration/instances_test.go b/test/integration/instances_test.go index e8562d4ed..72d79b4c8 100644 --- a/test/integration/instances_test.go +++ b/test/integration/instances_test.go @@ -117,10 +117,9 @@ func TestInstance_ResetPassword(t *testing.T) { t, "fixtures/TestInstance_ResetPassword", true, func(client *linodego.Client, options *linodego.InstanceCreateOptions) { - boot := false options.Type = "g6-nanode-1" - options.Booted = &boot - options.RootPass = randPassword() + options.Booted = linodego.Pointer(false) + options.RootPass = linodego.Pointer(randPassword()) }, ) @@ -156,9 +155,8 @@ func TestInstance_Resize(t *testing.T) { t, "fixtures/TestInstance_Resize", true, func(client *linodego.Client, options *linodego.InstanceCreateOptions) { - boot := true options.Type = "g6-nanode-1" - options.Booted = &boot + options.Booted = linodego.Pointer(true) }, ) @@ -182,7 +180,7 @@ func TestInstance_Resize(t *testing.T) { instance.ID, linodego.InstanceResizeOptions{ Type: "g6-standard-1", - MigrationType: "warm", + MigrationType: linodego.Pointer(linodego.WarmMigration), }, ) if err != nil { @@ -195,9 +193,8 @@ func TestInstance_Migrate(t *testing.T) { t, "fixtures/TestInstance_Migrate", true, func(client *linodego.Client, options *linodego.InstanceCreateOptions) { - boot := true options.Type = "g6-nanode-1" - options.Booted = &boot + options.Booted = linodego.Pointer(true) }, ) @@ -216,15 +213,13 @@ func TestInstance_Migrate(t *testing.T) { t.Errorf("Error waiting for instance readiness for migration: %s", err.Error()) } - upgrade := false - err = client.MigrateInstance( context.Background(), instance.ID, linodego.InstanceMigrateOptions{ - Type: "cold", - Region: "us-west", - Upgrade: &upgrade, + Type: linodego.Pointer(linodego.ColdMigration), + Region: linodego.Pointer("us-west"), + Upgrade: linodego.Pointer(false), }, ) if err != nil { @@ -254,11 +249,11 @@ func TestInstance_MigrateToPG(t *testing.T) { } instanceCreateOpts := linodego.InstanceCreateOptions{ - Label: "go-test-ins-" + randLabel(), - RootPass: randPassword(), + Label: linodego.Pointer("go-test-ins-" + randLabel()), + RootPass: linodego.Pointer(randPassword()), Region: regions[0], Type: "g6-nanode-1", - Image: "linode/debian10", + Image: linodego.Pointer("linode/debian10"), Booted: linodego.Pointer(true), PlacementGroup: &linodego.InstanceCreatePlacementGroupOptions{ ID: pgOutbound.ID, @@ -292,15 +287,13 @@ func TestInstance_MigrateToPG(t *testing.T) { t.Fatalf("failed to create placement group: %s", err) } - upgrade := false - err = client.MigrateInstance( context.Background(), instance.ID, linodego.InstanceMigrateOptions{ - Type: "cold", - Region: regions[1], - Upgrade: &upgrade, + Type: linodego.Pointer(linodego.ColdMigration), + Region: ®ions[1], + Upgrade: linodego.Pointer(false), PlacementGroup: &linodego.InstanceCreatePlacementGroupOptions{ID: pgInbound.ID}, }, ) @@ -390,7 +383,7 @@ func TestInstance_Disk_Resize(t *testing.T) { disk, err := client.CreateInstanceDisk(context.Background(), instance.ID, linodego.InstanceDiskCreateOptions{ Label: "disk-test-" + randLabel(), - Filesystem: "ext4", + Filesystem: linodego.Pointer("ext4"), Size: 2000, }) if err != nil { @@ -460,8 +453,8 @@ func TestInstance_Disk_ListMultiple(t *testing.T) { _, err = client.CreateInstanceDisk(context.Background(), instance2.ID, linodego.InstanceDiskCreateOptions{ Label: "go-disk-test-" + randLabel(), - Image: image.ID, - RootPass: randPassword(), + Image: &image.ID, + RootPass: linodego.Pointer(randPassword()), Size: 2000, }) if err != nil { @@ -499,9 +492,9 @@ func TestInstance_Disk_Clone(t *testing.T) { disk, err := client.CreateInstanceDisk(context.Background(), instance.ID, linodego.InstanceDiskCreateOptions{ Label: "go-disk-test-" + randLabel(), - Filesystem: "ext4", - Image: "linode/debian10", - RootPass: randPassword(), + Filesystem: linodego.Pointer("ext4"), + Image: linodego.Pointer("linode/debian10"), + RootPass: linodego.Pointer(randPassword()), Size: 2000, }) if err != nil { @@ -539,9 +532,9 @@ func TestInstance_Disk_ResetPassword(t *testing.T) { disk, err := client.CreateInstanceDisk(context.Background(), instance.ID, linodego.InstanceDiskCreateOptions{ Label: "go-disk-test-" + randLabel(), - Filesystem: "ext4", - Image: "linode/debian10", - RootPass: randPassword(), + Filesystem: linodego.Pointer("ext4"), + Image: linodego.Pointer("linode/debian10"), + RootPass: linodego.Pointer(randPassword()), Size: 2000, }) if err != nil { @@ -619,10 +612,10 @@ func TestInstance_Volumes_List(t *testing.T) { } configOpts := linodego.InstanceConfigUpdateOptions{ - Label: "go-vol-test" + getUniqueText(), + Label: linodego.Pointer("go-vol-test" + getUniqueText()), Devices: &linodego.InstanceConfigDeviceMap{ SDA: &linodego.InstanceConfigDevice{ - VolumeID: volume.ID, + VolumeID: &volume.ID, }, }, } @@ -655,7 +648,7 @@ func TestInstance_CreateUnderFirewall(t *testing.T) { t, client, true, func(_ *linodego.Client, options *linodego.InstanceCreateOptions) { - options.FirewallID = firewall.ID + options.FirewallID = &firewall.ID }, ) defer teardownInstance() @@ -685,12 +678,12 @@ func TestInstance_Rebuild(t *testing.T) { } rebuildOpts := linodego.InstanceRebuildOptions{ - Image: "linode/alpine3.19", + Image: linodego.Pointer("linode/alpine3.19"), Metadata: &linodego.InstanceMetadataOptions{ - UserData: base64.StdEncoding.EncodeToString([]byte("cool")), + UserData: linodego.Pointer(base64.StdEncoding.EncodeToString([]byte("cool"))), }, - RootPass: randPassword(), - Type: "g6-standard-2", + RootPass: linodego.Pointer(randPassword()), + Type: linodego.Pointer("g6-standard-2"), } instance, err = client.RebuildInstance(context.Background(), instance.ID, rebuildOpts) if err != nil { @@ -709,7 +702,7 @@ func TestInstance_RebuildWithEncryption(t *testing.T) { true, func(client *linodego.Client, options *linodego.InstanceCreateOptions) { options.Region = getRegionsWithCaps(t, client, []string{"Disk Encryption"})[0] - options.DiskEncryption = linodego.InstanceDiskEncryptionEnabled + options.DiskEncryption = linodego.Pointer(linodego.InstanceDiskEncryptionEnabled) }, ) defer teardown() @@ -724,10 +717,10 @@ func TestInstance_RebuildWithEncryption(t *testing.T) { } rebuildOpts := linodego.InstanceRebuildOptions{ - Image: "linode/alpine3.19", - RootPass: randPassword(), - Type: "g6-standard-2", - DiskEncryption: linodego.InstanceDiskEncryptionDisabled, + Image: linodego.Pointer("linode/alpine3.19"), + RootPass: linodego.Pointer(randPassword()), + Type: linodego.Pointer("g6-standard-2"), + DiskEncryption: linodego.Pointer(linodego.InstanceDiskEncryptionDisabled), } instance, err = client.RebuildInstance(context.Background(), instance.ID, rebuildOpts) if err != nil { @@ -767,11 +760,11 @@ func TestInstance_Clone(t *testing.T) { } cloneOpts := linodego.InstanceCloneOptions{ - Region: targetRegion, - Type: "g6-nanode-1", - PrivateIP: true, + Region: &targetRegion, + Type: linodego.Pointer("g6-nanode-1"), + PrivateIP: linodego.Pointer(true), Metadata: &linodego.InstanceMetadataOptions{ - UserData: base64.StdEncoding.EncodeToString([]byte("reallycooluserdata")), + UserData: linodego.Pointer(base64.StdEncoding.EncodeToString([]byte("reallycooluserdata"))), }, } clonedInstance, err := client.CloneInstance(context.Background(), instance.ID, cloneOpts) @@ -821,7 +814,7 @@ func TestInstance_withMetadata(t *testing.T) { _, inst, _, teardown, err := setupInstanceWithoutDisks(t, "fixtures/TestInstance_withMetadata", true, func(client *linodego.Client, options *linodego.InstanceCreateOptions) { options.Metadata = &linodego.InstanceMetadataOptions{ - UserData: base64.StdEncoding.EncodeToString([]byte("reallycoolmetadata")), + UserData: linodego.Pointer(base64.StdEncoding.EncodeToString([]byte("reallycoolmetadata"))), } options.Region = getRegionsWithCaps(t, client, []string{"Metadata"})[0] }) @@ -838,7 +831,7 @@ func TestInstance_withMetadata(t *testing.T) { func TestInstance_DiskEncryption(t *testing.T) { _, inst, teardown, err := setupInstance(t, "fixtures/TestInstance_DiskEncryption", true, func(c *linodego.Client, ico *linodego.InstanceCreateOptions) { - ico.DiskEncryption = linodego.InstanceDiskEncryptionEnabled + ico.DiskEncryption = linodego.Pointer(linodego.InstanceDiskEncryptionEnabled) ico.Region = "us-east" }) if err != nil { @@ -857,7 +850,7 @@ func TestInstance_withBlockStorageEncryption(t *testing.T) { inst, err := createInstance(t, client, true, func(client *linodego.Client, options *linodego.InstanceCreateOptions) { options.Region = getRegionsWithCaps(t, client, []string{"Linodes", "Block Storage Encryption"})[0] - options.Label = "go-inst-test-create-bde" + options.Label = linodego.Pointer("go-inst-test-create-bde") }) require.NoError(t, err) @@ -876,7 +869,7 @@ func TestInstance_withVPU(t *testing.T) { inst, err := createInstance(t, client, true, func(client *linodego.Client, options *linodego.InstanceCreateOptions) { options.Region = "us-lax" options.Type = "g1-accelerated-netint-vpu-t1u1-s" - options.Label = "go-inst-test-create-vpu" + options.Label = linodego.Pointer("go-inst-test-create-vpu") }) require.NoError(t, err) @@ -922,16 +915,16 @@ func createInstance(t *testing.T, client *linodego.Client, enableCloudFirewall b } createOpts := linodego.InstanceCreateOptions{ - Label: "go-test-ins-" + randLabel(), - RootPass: randPassword(), + Label: linodego.Pointer("go-test-ins-" + randLabel()), + RootPass: linodego.Pointer(randPassword()), Region: getRegionsWithCaps(t, client, []string{"linodes"})[0], Type: "g6-nanode-1", - Image: "linode/debian12", + Image: linodego.Pointer("linode/debian12"), Booted: linodego.Pointer(false), } if enableCloudFirewall { - createOpts.FirewallID = firewallID + createOpts.FirewallID = &firewallID } for _, modifier := range modifiers { @@ -971,14 +964,14 @@ func createInstanceWithoutDisks( t.Helper() createOpts := linodego.InstanceCreateOptions{ - Label: "go-test-ins-wo-disk-" + randLabel(), + Label: linodego.Pointer("go-test-ins-wo-disk-" + randLabel()), Region: getRegionsWithCaps(t, client, []string{"linodes"})[0], Type: "g6-nanode-1", Booted: linodego.Pointer(false), } if enableCloudFirewall { - createOpts.FirewallID = GetFirewallID() + createOpts.FirewallID = linodego.Pointer(GetFirewallID()) } for _, modifier := range modifiers { @@ -991,7 +984,7 @@ func createInstanceWithoutDisks( return nil, nil, func() {}, err } configOpts := linodego.InstanceConfigCreateOptions{ - Label: "go-test-conf-" + randLabel(), + Label: linodego.Pointer("go-test-conf-" + randLabel()), } config, err := client.CreateInstanceConfig(context.Background(), instance.ID, configOpts) if err != nil { diff --git a/test/integration/lke_clusters_acl_test.go b/test/integration/lke_clusters_acl_test.go index f55ab0bb5..ffd1ba3be 100644 --- a/test/integration/lke_clusters_acl_test.go +++ b/test/integration/lke_clusters_acl_test.go @@ -11,18 +11,16 @@ import ( ) func TestLKECluster_withACL(t *testing.T) { - valueTrue := true - client, cluster, teardown, err := setupLKECluster( t, []clusterModifier{ func(options *linodego.LKEClusterCreateOptions) { options.ControlPlane = &linodego.LKEClusterControlPlaneOptions{ ACL: &linodego.LKEClusterControlPlaneACLOptions{ - Enabled: &valueTrue, + Enabled: linodego.Pointer(true), Addresses: &linodego.LKEClusterControlPlaneACLAddressesOptions{ - IPv4: &[]string{"10.0.0.1/32"}, - IPv6: &[]string{"1234::5678"}, + IPv4: []string{"10.0.0.1/32"}, + IPv6: []string{"1234::5678"}, }, }, } @@ -45,10 +43,10 @@ func TestLKECluster_withACL(t *testing.T) { cluster.ID, linodego.LKEClusterControlPlaneACLUpdateOptions{ ACL: linodego.LKEClusterControlPlaneACLOptions{ - Enabled: &valueTrue, + Enabled: linodego.Pointer(true), Addresses: &linodego.LKEClusterControlPlaneACLAddressesOptions{ - IPv4: &[]string{"10.0.0.2/32"}, - IPv6: &[]string{}, + IPv4: []string{"10.0.0.2/32"}, + IPv6: []string{}, }, RevisionID: "test-revision-id", }, diff --git a/test/integration/lke_clusters_test.go b/test/integration/lke_clusters_test.go index d2c0537db..2185c60e5 100644 --- a/test/integration/lke_clusters_test.go +++ b/test/integration/lke_clusters_test.go @@ -66,7 +66,7 @@ func TestLKECluster_GetFound_smoke(t *testing.T) { func TestLKECluster_Enterprise_smoke(t *testing.T) { client, lkeCluster, teardown, err := setupLKECluster(t, []clusterModifier{func(createOpts *linodego.LKEClusterCreateOptions) { - createOpts.Tier = "enterprise" + createOpts.Tier = linodego.Pointer("enterprise") createOpts.Region = "us-lax" createOpts.K8sVersion = "v1.31.1+lke1" }}, "fixtures/TestLKECluster_Enterprise_smoke") @@ -97,9 +97,9 @@ func TestLKECluster_Update(t *testing.T) { updatedK8sVersion := "1.30" updatedCluster, err := client.UpdateLKECluster(context.Background(), cluster.ID, linodego.LKEClusterUpdateOptions{ - Tags: &updatedTags, - Label: updatedLabel, - K8sVersion: updatedK8sVersion, + Tags: updatedTags, + Label: &updatedLabel, + K8sVersion: &updatedK8sVersion, }) if err != nil { t.Fatalf("failed to update LKE Cluster (%d): %s", cluster.ID, err) @@ -308,7 +308,7 @@ func setupLKECluster(t *testing.T, clusterModifiers []clusterModifier, fixturesY client, fixtureTeardown := createTestClient(t, fixturesYaml) createOpts := linodego.LKEClusterCreateOptions{ - Label: label, + Label: "go-test-def", Region: getRegionsWithCaps(t, client, []string{"Kubernetes", "Disk Encryption"})[0], K8sVersion: "1.31", Tags: []string{"testing"}, @@ -338,7 +338,7 @@ func TestLKECluster_APLEnabled_smoke(t *testing.T) { createOpts.Label = "go-lke-test-apl-enabled" }, func(createOpts *linodego.LKEClusterCreateOptions) { - createOpts.APLEnabled = true + createOpts.APLEnabled = linodego.Pointer(true) }, func(createOpts *linodego.LKEClusterCreateOptions) { // NOTE: g6-dedicated-4 is the minimum APL-compatible Linode type diff --git a/test/integration/lke_node_pools_test.go b/test/integration/lke_node_pools_test.go index c82cbd201..c3389148a 100644 --- a/test/integration/lke_node_pools_test.go +++ b/test/integration/lke_node_pools_test.go @@ -72,8 +72,8 @@ func TestLKENodePool_GetFound(t *testing.T) { t.Errorf("unexpected tags:\n%s", diff) } - if i.DiskEncryption != linodego.InstanceDiskEncryptionEnabled { - t.Errorf("DiskEncryption not enabled, got: %s, want: %s", i.DiskEncryption, linodego.InstanceDiskEncryptionEnabled) + if i.DiskEncryption == nil || *i.DiskEncryption != linodego.InstanceDiskEncryptionEnabled { + t.Errorf("DiskEncryption not enabled, got: %s, want: %s", *i.DiskEncryption, linodego.InstanceDiskEncryptionEnabled) } wrapper, teardownClusterClient := transportRecorderWrapper(t, "fixtures/TestLKENodePool_GetFound_k8s") @@ -207,8 +207,8 @@ func TestLKENodePool_Update(t *testing.T) { } updatedTags := []string{} updated, err := client.UpdateLKENodePool(context.TODO(), lkeCluster.ID, nodePool.ID, linodego.LKENodePoolUpdateOptions{ - Count: 2, // downsize - Tags: &updatedTags, // remove all tags + Count: linodego.Pointer(2), // downsize + Tags: updatedTags, // remove all tags Autoscaler: &updatedAutoscaler, }) if err != nil { @@ -232,14 +232,14 @@ func TestLKENodePool_Update(t *testing.T) { updatedLabels := linodego.LKENodePoolLabels{"foo": "bar"} updatedTaints := []linodego.LKENodePoolTaint{{ Key: "foo", - Value: "bar", + Value: linodego.Pointer("bar"), Effect: linodego.LKENodePoolTaintEffectNoSchedule, }} updated, err = client.UpdateLKENodePool(context.TODO(), lkeCluster.ID, nodePool.ID, linodego.LKENodePoolUpdateOptions{ - Count: 3, // upsize - Tags: &updatedTags, // repopulate tags - Labels: &updatedLabels, // set a label - Taints: &updatedTaints, // set a taint + Count: linodego.Pointer(3), // upsize + Tags: updatedTags, // repopulate tags + Labels: &updatedLabels, // set a label + Taints: updatedTaints, // set a taint }) if err != nil { t.Fatal(err) @@ -268,7 +268,7 @@ func TestLKENodePool_CreateWithLabelsAndTaints(t *testing.T) { Labels: linodego.LKENodePoolLabels{"foo": "bar"}, Taints: []linodego.LKENodePoolTaint{{ Key: "foo", - Value: "bar", + Value: linodego.Pointer("bar"), Effect: linodego.LKENodePoolTaintEffectNoSchedule, }}, Count: 1, diff --git a/test/integration/main_test.go b/test/integration/main_test.go index 8596e5dd8..5a0d1b40d 100644 --- a/test/integration/main_test.go +++ b/test/integration/main_test.go @@ -51,7 +51,7 @@ func setupCloudFirewall(t *testing.T) { firewallLabel := fmt.Sprintf("cloudfw-%d", time.Now().UnixNano()) firewall, err := client.CreateFirewall(context.Background(), linodego.FirewallCreateOptions{ - Label: firewallLabel, + Label: &firewallLabel, Rules: firewallRuleSet, }) if err != nil { @@ -78,9 +78,9 @@ func getDefaultFirewallRuleSet(publicIPv4 string) linodego.FirewallRuleSet { cloudFirewallRule := linodego.FirewallRule{ Label: "ssh-inbound-accept-local", Action: "ACCEPT", - Ports: "22", + Ports: linodego.Pointer("22"), Protocol: "TCP", - Addresses: linodego.NetworkAddresses{IPv4: &[]string{publicIPv4}}, + Addresses: linodego.NetworkAddresses{IPv4: []string{publicIPv4}}, } return linodego.FirewallRuleSet{ diff --git a/test/integration/mysql_test.go b/test/integration/mysql_test.go index 773029fd8..0a63f44e9 100644 --- a/test/integration/mysql_test.go +++ b/test/integration/mysql_test.go @@ -51,12 +51,10 @@ func TestDatabase_MySQL_Suite(t *testing.T) { Pending: []linodego.DatabaseMaintenanceWindowPending{}, } - allowList := []string{"128.173.205.21", "123.177.200.20"} - updatedLabel := database.Label + "-updated" opts := linodego.MySQLUpdateOptions{ - AllowList: &allowList, - Label: updatedLabel, + AllowList: []string{"128.173.205.21", "123.177.200.20"}, + Label: &updatedLabel, Updates: &updatedWindow, } db, err = client.UpdateMySQLDatabase(context.Background(), database.ID, opts) @@ -142,7 +140,7 @@ func createMySQLDatabase(t *testing.T, client *linodego.Client, Region: getRegionsWithCaps(t, client, []string{"Managed Databases"})[0], Type: "g6-nanode-1", Engine: "mysql/8", - ClusterSize: 3, + ClusterSize: linodego.Pointer(3), AllowList: []string{"203.0.113.1", "192.0.1.0/24"}, } diff --git a/test/integration/network_ips_test.go b/test/integration/network_ips_test.go index 545b4a492..bf475cd52 100644 --- a/test/integration/network_ips_test.go +++ b/test/integration/network_ips_test.go @@ -167,7 +167,7 @@ func TestIPAddresses_Instance_Get(t *testing.T) { if i.IPv4.Public[0].Address != instance.IPv4[0].String() { t.Errorf("Expected matching public IP ipaddresses with GetInstanceIPAddress Instance IPAddress but got %v", i) } - if *i.IPv4.VPC[0].Address != config.Interfaces[2].IPv4.VPC { + if *i.IPv4.VPC[0].Address != *config.Interfaces[2].IPv4.VPC { t.Errorf("Expected matching VPC IP addresses with GetInstanceIPAddress Instance IPAddress but got %v", i) } } @@ -179,9 +179,6 @@ func TestIPAddress_Update(t *testing.T) { t.Error(err) } - reservedTrue := true - reservedFalse := false - address := instance.IPv4[0].String() i, err := client.GetInstanceIPAddresses(context.Background(), instance.ID) @@ -221,7 +218,7 @@ func TestIPAddress_Update(t *testing.T) { ephemeralIP := instance.IPv4[0].String() updateOpts = IPAddressUpdateOptionsV2{ - Reserved: &reservedTrue, + Reserved: linodego.Pointer(true), } updatedIP, err := client.UpdateIPAddressV2(context.Background(), ephemeralIP, updateOpts) if err != nil { @@ -240,7 +237,7 @@ func TestIPAddress_Update(t *testing.T) { defer client.DeleteReservedIPAddress(context.Background(), reservedIP) updateOpts = IPAddressUpdateOptionsV2{ - Reserved: &reservedTrue, + Reserved: linodego.Pointer(true), } updatedIP, err = client.UpdateIPAddressV2(context.Background(), reservedIP, updateOpts) if err != nil { @@ -254,7 +251,7 @@ func TestIPAddress_Update(t *testing.T) { ephemeralIP = instance.IPv4[0].String() updateOpts = IPAddressUpdateOptionsV2{ - Reserved: &reservedFalse, + Reserved: linodego.Pointer(false), } updatedIP, err = client.UpdateIPAddressV2(context.Background(), ephemeralIP, updateOpts) if err != nil { @@ -287,7 +284,7 @@ func TestIPAddress_Update(t *testing.T) { } updateOpts = IPAddressUpdateOptionsV2{ - Reserved: &reservedFalse, + Reserved: linodego.Pointer(false), } updatedIP, err = client.UpdateIPAddressV2(context.Background(), reservedIP, updateOpts) if err != nil { @@ -305,7 +302,7 @@ func TestIPAddress_Update(t *testing.T) { } updateOpts = IPAddressUpdateOptionsV2{ - Reserved: &reservedTrue, + Reserved: linodego.Pointer(true), RDNS: linodego.Pointer(linodego.Pointer("sample rdns")), } _, err = client.UpdateIPAddressV2(context.Background(), unassignedResIP, updateOpts) @@ -323,7 +320,7 @@ func TestIPAddress_Update(t *testing.T) { } updateOpts = IPAddressUpdateOptionsV2{ - Reserved: &reservedTrue, + Reserved: linodego.Pointer(true), } updatedIP, err = client.UpdateIPAddressV2(context.Background(), reservedIP, updateOpts) if err != nil { @@ -343,7 +340,7 @@ func TestIPAddress_Update(t *testing.T) { } updateOpts = IPAddressUpdateOptionsV2{ - Reserved: &reservedFalse, + Reserved: linodego.Pointer(false), } _, err = client.UpdateIPAddressV2(context.Background(), reservedIP, updateOpts) if err != nil { @@ -361,7 +358,7 @@ func TestIPAddress_Update(t *testing.T) { invalidResIp := "123.72.121.76" updateOpts = IPAddressUpdateOptionsV2{ - Reserved: &reservedFalse, + Reserved: linodego.Pointer(false), } updatedIP, err = client.UpdateIPAddressV2(context.Background(), invalidResIp, updateOpts) @@ -412,7 +409,7 @@ func TestIPAddress_Instance_Assign(t *testing.T) { } newInstance, err := createInstance(t, client, true, func(client *Client, options *InstanceCreateOptions) { - options.Label = "go-ins-test-assign" + options.Label = linodego.Pointer("go-ins-test-assign") options.Region = instance.Region }) @@ -430,7 +427,7 @@ func TestIPAddress_Instance_Assign(t *testing.T) { ipRange, err := client.CreateIPv6Range(context.Background(), IPv6RangeCreateOptions{ PrefixLength: 64, - LinodeID: newInstance.ID, + LinodeID: &newInstance.ID, }) if err != nil { t.Error(err) @@ -472,7 +469,7 @@ func TestIPAddress_Instance_Share(t *testing.T) { } newInstance, err := createInstance(t, client, true, func(client *Client, options *InstanceCreateOptions) { - options.Label = "go-ins-test-share" + options.Label = linodego.Pointer("go-ins-test-share") options.Region = instance.Region }) @@ -530,9 +527,9 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { opts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Reserved: true, - Region: instance.Region, - LinodeID: instance.ID, + Reserved: linodego.Pointer(true), + Region: &instance.Region, + LinodeID: &instance.ID, } validIp, err := client.AllocateReserveIP(context.Background(), opts) // defer cleanUpIPAllocation(t, client, validIp.Address) @@ -547,9 +544,9 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { nonOwnedLinodeOpts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Reserved: true, - Region: instance.Region, - LinodeID: 99999, // Assume this is a non-owned Linode ID + Reserved: linodego.Pointer(true), + Region: &instance.Region, + LinodeID: linodego.Pointer(99999), // Assume this is a non-owned Linode ID } _, nonOwnedLinodeErr := client.AllocateReserveIP(context.Background(), nonOwnedLinodeOpts) if nonOwnedLinodeErr == nil { @@ -561,8 +558,8 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { omitLinodeIDOpts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Reserved: true, - Region: instance.Region, + Reserved: linodego.Pointer(true), + Region: &instance.Region, } omitLinodeIDip, omitLinodeErr := client.AllocateReserveIP(context.Background(), omitLinodeIDOpts) if omitLinodeErr != nil { @@ -577,8 +574,8 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { omitRegionOpts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Reserved: true, - LinodeID: instance.ID, + Reserved: linodego.Pointer(true), + LinodeID: &instance.ID, } omitRegionip, omitRegionErr := client.AllocateReserveIP(context.Background(), omitRegionOpts) // defer cleanUpIPAllocation(t, client, omitRegionip.Address) @@ -596,7 +593,7 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { omitRegionAndLinodeIDopts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Reserved: true, + Reserved: linodego.Pointer(true), } _, omitRegionAndLinodeIDerr := client.AllocateReserveIP(context.Background(), omitRegionAndLinodeIDopts) @@ -609,9 +606,9 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { publicFalseOpts := AllocateReserveIPOptions{ Type: "ipv4", Public: false, - Reserved: true, - Region: instance.Region, - LinodeID: instance.ID, + Reserved: linodego.Pointer(true), + Region: &instance.Region, + LinodeID: &instance.ID, } _, publicFalseErr := client.AllocateReserveIP(context.Background(), publicFalseOpts) if publicFalseErr == nil { @@ -623,9 +620,9 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { reservedFalseOpts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Reserved: false, - Region: instance.Region, - LinodeID: instance.ID, + Reserved: linodego.Pointer(false), + Region: &instance.Region, + LinodeID: &instance.ID, } reservedFalseIp, reservedFalseErr := client.AllocateReserveIP(context.Background(), reservedFalseOpts) if reservedFalseErr != nil { @@ -642,8 +639,8 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { omitReservedOpts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Region: instance.Region, - LinodeID: instance.ID, + Region: &instance.Region, + LinodeID: &instance.ID, } omitReservedip, omitReservedErr := client.AllocateReserveIP(context.Background(), omitReservedOpts) if omitReservedErr != nil { @@ -660,8 +657,8 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { omitOpts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Reserved: false, - Region: instance.Region, + Reserved: linodego.Pointer(false), + Region: &instance.Region, } _, omitOptsErr := client.AllocateReserveIP(context.Background(), omitOpts) if omitOptsErr == nil { @@ -673,7 +670,7 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { omitIDResopts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Region: instance.Region, + Region: &instance.Region, } _, omitIDResErr := client.AllocateReserveIP(context.Background(), omitIDResopts) if omitIDResErr == nil { @@ -685,9 +682,9 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { typeIPv6opts := AllocateReserveIPOptions{ Type: "ipv6", Public: true, - Reserved: true, - Region: instance.Region, - LinodeID: instance.ID, + Reserved: linodego.Pointer(true), + Region: &instance.Region, + LinodeID: &instance.ID, } _, typeIPv6Err := client.AllocateReserveIP(context.Background(), typeIPv6opts) if typeIPv6Err == nil { @@ -699,9 +696,9 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { resFalseIPv6opts := AllocateReserveIPOptions{ Type: "ipv6", Public: true, - Reserved: false, - Region: instance.Region, - LinodeID: instance.ID, + Reserved: linodego.Pointer(false), + Region: &instance.Region, + LinodeID: &instance.ID, } _, resFalseIPv6Err := client.AllocateReserveIP(context.Background(), resFalseIPv6opts) if resFalseIPv6Err == nil { @@ -713,9 +710,9 @@ func TestIPAddress_Instance_Allocate(t *testing.T) { regionMismatchOpts := AllocateReserveIPOptions{ Type: "ipv4", Public: true, - Reserved: true, - Region: "us-west", // Assume this is different from instance.Region - LinodeID: instance.ID, + Reserved: linodego.Pointer(true), + Region: linodego.Pointer("us-west"), // Assume this is different from instance.Region + LinodeID: &instance.ID, } _, regionMismatchErr := client.AllocateReserveIP(context.Background(), regionMismatchOpts) if regionMismatchErr == nil { diff --git a/test/integration/network_ranges_test.go b/test/integration/network_ranges_test.go index 277cd4d3e..34ce916f6 100644 --- a/test/integration/network_ranges_test.go +++ b/test/integration/network_ranges_test.go @@ -65,7 +65,7 @@ func TestIPv6Range_Share(t *testing.T) { } inst, err := createInstance(t, client, true, func(client *Client, inst *InstanceCreateOptions) { - inst.Label = "go-ins-test-share6" + inst.Label = Pointer("go-ins-test-share6") inst.Region = origInst.Region }) if err != nil { @@ -150,7 +150,7 @@ func setupIPv6RangeInstance(t *testing.T, ipv6RangeModifiers []ipv6RangeModifier t.Cleanup(fixtureTeardown) instance, err := createInstance(t, client, true, func(client *Client, inst *InstanceCreateOptions) { - inst.Label = "go-ins-test-range6" + inst.Label = Pointer("go-ins-test-range6") // This should stay hard-coded until IPv6 sharing has a // corresponding capability. @@ -169,7 +169,7 @@ func setupIPv6RangeInstance(t *testing.T, ipv6RangeModifiers []ipv6RangeModifier }) ipv6RangeModifiers = append(ipv6RangeModifiers, func(options *IPv6RangeCreateOptions) { - options.LinodeID = instance.ID + options.LinodeID = &instance.ID }) ipRange, err := createIPv6Range(t, client, ipv6RangeModifiers...) diff --git a/test/integration/network_reserved_ips_test.go b/test/integration/network_reserved_ips_test.go index c261a0ba3..bf61369cf 100644 --- a/test/integration/network_reserved_ips_test.go +++ b/test/integration/network_reserved_ips_test.go @@ -389,7 +389,7 @@ func TestReservedIPAddresses_DeleteIPAddressVariants(t *testing.T) { } func TestReservedIPAddresses_GetIPReservationStatus(t *testing.T) { - client, teardown := createTestClient(t, "TestReservedIPAddresses_GetInstanceIPReservationStatus") + client, teardown := createTestClient(t, "fixtures/TestReservedIPAddresses_GetInstanceIPReservationStatus") defer teardown() // Create a Linode with a reserved IP @@ -435,8 +435,8 @@ func TestReservedIPAddresses_GetIPReservationStatus(t *testing.T) { instanceWithEphemeralIP, err := client.CreateInstance(context.Background(), linodego.InstanceCreateOptions{ Region: "us-east", Type: "g6-nanode-1", - Label: "test-instance-ephemeral-ip", - RootPass: randPassword(), + Label: linodego.Pointer("test-instance-ephemeral-ip"), + RootPass: linodego.Pointer(randPassword()), }) if err != nil { t.Fatalf("Failed to create Linode with ephemeral IP: %v", err) diff --git a/test/integration/nodebalancer_config_nodes_test.go b/test/integration/nodebalancer_config_nodes_test.go index 304490e98..ecf0777d9 100644 --- a/test/integration/nodebalancer_config_nodes_test.go +++ b/test/integration/nodebalancer_config_nodes_test.go @@ -13,8 +13,8 @@ var ( testNodeWeight = 10 testNodeBalancerNodeCreateOpts = linodego.NodeBalancerNodeCreateOptions{ Label: testNodeLabel, - Weight: testNodeWeight, - Mode: linodego.ModeAccept, + Weight: &testNodeWeight, + Mode: linodego.Pointer(linodego.ModeAccept), } ) @@ -29,8 +29,8 @@ func TestNodeBalancerNode_Create_smoke(t *testing.T) { expected := testNodeBalancerNodeCreateOpts if node.Label != expected.Label || - node.Weight != expected.Weight || - node.Mode != expected.Mode { + node.Weight != *expected.Weight || + node.Mode != *expected.Mode { t.Errorf("NodeBalancerNode did not match CreateOptions - %v", node) } } @@ -43,9 +43,9 @@ func TestNodeBalancerNode_Update(t *testing.T) { } updateOpts := linodego.NodeBalancerNodeUpdateOptions{ - Mode: linodego.ModeDrain, - Weight: testNodeWeight + 90, - Label: testNodeLabel + "_r", + Mode: linodego.Pointer(linodego.ModeDrain), + Weight: linodego.Pointer(testNodeWeight + 90), + Label: linodego.Pointer(testNodeLabel + "_r"), } nodeUpdated, err := client.UpdateNodeBalancerNode(context.Background(), nodebalancer.ID, config.ID, node.ID, updateOpts) if err != nil { @@ -53,9 +53,9 @@ func TestNodeBalancerNode_Update(t *testing.T) { } // fixture sanitization breaks predictability for this test, verify the prefix - if string(updateOpts.Mode) != string(nodeUpdated.Mode) || - updateOpts.Label != nodeUpdated.Label || - updateOpts.Weight != nodeUpdated.Weight { + if string(*updateOpts.Mode) != string(nodeUpdated.Mode) || + *updateOpts.Label != nodeUpdated.Label || + *updateOpts.Weight != nodeUpdated.Weight { t.Errorf("NodeBalancerNode did not match UpdateOptions") } } @@ -125,7 +125,7 @@ func TestNodeBalancer_Rebuild(t *testing.T) { nbcRebuildOpts.Nodes, linodego.NodeBalancerConfigRebuildNodeOptions{ NodeBalancerNodeCreateOptions: node.GetCreateOptions(), - ID: node.ID, + ID: &node.ID, }, ) diff --git a/test/integration/nodebalancer_configs_test.go b/test/integration/nodebalancer_configs_test.go index 4d85837e9..ad5c5f442 100644 --- a/test/integration/nodebalancer_configs_test.go +++ b/test/integration/nodebalancer_configs_test.go @@ -9,9 +9,9 @@ import ( var testNodeBalancerConfigCreateOpts = linodego.NodeBalancerConfigCreateOptions{ Port: 80, - Protocol: linodego.ProtocolHTTP, - Algorithm: linodego.AlgorithmRoundRobin, - CheckInterval: 60, + Protocol: linodego.Pointer(linodego.ProtocolHTTP), + Algorithm: linodego.Pointer(linodego.AlgorithmRoundRobin), + CheckInterval: linodego.Pointer(60), } func TestNodeBalancerConfig_Create_smoke(t *testing.T) { @@ -25,7 +25,7 @@ func TestNodeBalancerConfig_Create_smoke(t *testing.T) { expected := testNodeBalancerConfigCreateOpts // cant compare Target, fixture IPs are sanitized - if config.Port != expected.Port || config.Protocol != expected.Protocol { + if config.Port != expected.Port || config.Protocol != *expected.Protocol { t.Errorf("NodeBalancerConfig did not match CreateOptions") } } @@ -39,18 +39,18 @@ func TestNodeBalancerConfig_Update(t *testing.T) { updateOpts := linodego.NodeBalancerConfigUpdateOptions{ Port: 8080, - Protocol: linodego.ProtocolTCP, - ProxyProtocol: linodego.ProxyProtocolV2, - Algorithm: linodego.AlgorithmLeastConn, + Protocol: linodego.Pointer(linodego.ProtocolTCP), + ProxyProtocol: linodego.Pointer(linodego.ProxyProtocolV2), + Algorithm: linodego.Pointer(linodego.AlgorithmLeastConn), } configUpdated, err := client.UpdateNodeBalancerConfig(context.Background(), nodebalancer.ID, config.ID, updateOpts) if err != nil { t.Errorf("Error updating NodeBalancer Config, %s", err) } if configUpdated.Port != updateOpts.Port || - string(updateOpts.Algorithm) != string(configUpdated.Algorithm) || - string(updateOpts.Protocol) != string(configUpdated.Protocol) || - string(updateOpts.ProxyProtocol) != string(configUpdated.ProxyProtocol) { + string(*updateOpts.Algorithm) != string(configUpdated.Algorithm) || + string(*updateOpts.Protocol) != string(configUpdated.Protocol) || + string(*updateOpts.ProxyProtocol) != string(configUpdated.ProxyProtocol) { t.Errorf("NodeBalancerConfig did not match UpdateOptions") } } diff --git a/test/integration/nodebalancers_test.go b/test/integration/nodebalancers_test.go index cf0e1e30a..356f59afa 100644 --- a/test/integration/nodebalancers_test.go +++ b/test/integration/nodebalancers_test.go @@ -8,11 +8,6 @@ import ( "github.com/linode/linodego" ) -var ( - clientConnThrottle = 20 - label = "go-test-def" -) - func TestNodeBalancer_Create_create_smoke(t *testing.T) { _, nodebalancer, teardown, err := setupNodeBalancer(t, "fixtures/TestNodeBalancer_Create") defer teardown() @@ -22,7 +17,7 @@ func TestNodeBalancer_Create_create_smoke(t *testing.T) { } // when comparing fixtures to random value Label will differ, compare the known suffix - if !strings.Contains(*nodebalancer.Label, label) { + if !strings.Contains(*nodebalancer.Label, "go-test-def") { t.Errorf("nodebalancer returned does not match nodebalancer create request") } @@ -85,10 +80,10 @@ func setupNodeBalancer(t *testing.T, fixturesYaml string) (*linodego.Client, *li var fixtureTeardown func() client, fixtureTeardown := createTestClient(t, fixturesYaml) createOpts := linodego.NodeBalancerCreateOptions{ - Label: &label, - Region: getRegionsWithCaps(t, client, []string{"NodeBalancers"})[0], - ClientConnThrottle: &clientConnThrottle, - FirewallID: GetFirewallID(), + Label: linodego.Pointer("go-test-def"), + Region: linodego.Pointer(getRegionsWithCaps(t, client, []string{"NodeBalancers"})[0]), + ClientConnThrottle: linodego.Pointer(20), + FirewallID: linodego.Pointer(GetFirewallID()), } nodebalancer, err := client.CreateNodeBalancer(context.Background(), createOpts) diff --git a/test/integration/object_storage_bucket_certs_test.go b/test/integration/object_storage_bucket_certs_test.go index 20a0ca295..abfc221bd 100644 --- a/test/integration/object_storage_bucket_certs_test.go +++ b/test/integration/object_storage_bucket_certs_test.go @@ -108,8 +108,8 @@ func TestObjectStorageBucketCert_smoke(t *testing.T) { })] bucket, err := client.CreateObjectStorageBucket(context.Background(), linodego.ObjectStorageBucketCreateOptions{ - Region: selectedEndpoint.Region, - EndpointType: selectedEndpoint.EndpointType, + Region: &selectedEndpoint.Region, + EndpointType: &selectedEndpoint.EndpointType, Label: "linode-obj-bucket-cert-test.xyz", }) if err != nil { diff --git a/test/integration/object_storage_buckets_test.go b/test/integration/object_storage_buckets_test.go index 05934ac86..6df9afcd4 100644 --- a/test/integration/object_storage_buckets_test.go +++ b/test/integration/object_storage_buckets_test.go @@ -12,12 +12,12 @@ import ( var objectStorageBucketTestLabel = "go-bucket-test-def" var testObjectStorageBucketCreateOpts = ObjectStorageBucketCreateOptions{ - Cluster: "us-east-1", + Cluster: linodego.Pointer("us-east-1"), Label: objectStorageBucketTestLabel, } var testRegionalObjectStorageBucketCreateOpts = ObjectStorageBucketCreateOptions{ - Region: "us-east", + Region: linodego.Pointer("us-east"), Label: objectStorageBucketTestLabel, } @@ -35,7 +35,7 @@ func TestObjectStorageBucket_Create_smoke(t *testing.T) { // when comparing fixtures to random value Label will differ, compare the known prefix if bucket.Label != expected.Label || - bucket.Cluster != expected.Cluster { + bucket.Cluster != *expected.Cluster { t.Errorf("Object Storage Bucket did not match CreateOptions") } @@ -54,8 +54,8 @@ func TestObjectStorageBucket_Regional(t *testing.T) { client, bucket, teardown, err := setupObjectStorageBucket(t, []objectStorageBucketModifier{ func(opts *ObjectStorageBucketCreateOptions) { - opts.Cluster = "" - opts.Region = region + opts.Cluster = linodego.Pointer("") + opts.Region = ®ion }, }, "fixtures/TestObjectStorageBucket_Regional", @@ -126,7 +126,7 @@ func TestObjectStorageBucket_GetFound(t *testing.T) { // when comparing fixtures to random value Label will differ, compare the known prefix if bucket.Label != expected.Label || - bucket.Cluster != expected.Cluster { + bucket.Cluster != *expected.Cluster { t.Errorf("Object Storage Bucket did not match CreateOptions") } } @@ -180,7 +180,7 @@ func TestObjectStorageBucket_Access_Get(t *testing.T) { corsEnabled := false createOpts := ObjectStorageBucketCreateOptions{ - ACL: ACLAuthenticatedRead, + ACL: linodego.Pointer(ACLAuthenticatedRead), CorsEnabled: &corsEnabled, } endpointType := linodego.ObjectStorageEndpointE1 @@ -218,14 +218,14 @@ func TestObjectStorageBucket_Access_Get(t *testing.T) { t.Errorf("ObjectStorageBucket access CORS does not match update, expected %t, got %t", corsEnabled, *newBucketv2.CorsEnabled) } - if newBucket.ACL != createOpts.ACL { + if createOpts.ACL == nil || newBucket.ACL != *createOpts.ACL { t.Errorf("ObjectStorageBucket access ACL does not match update, expected %s, got %s", - createOpts.ACL, + *createOpts.ACL, newBucket.ACL) } - if newBucketv2.ACL != createOpts.ACL { + if createOpts.ACL == nil || newBucketv2.ACL != *createOpts.ACL { t.Errorf("ObjectStorageBucket access ACL does not match update, expected %s, got %s", - createOpts.ACL, + *createOpts.ACL, newBucketv2.ACL) } } @@ -242,7 +242,7 @@ func TestObjectStorageBucket_Access_Update(t *testing.T) { corsEnabled := false opts := ObjectStorageBucketUpdateAccessOptions{ - ACL: ACLPrivate, + ACL: linodego.Pointer(ACLPrivate), CorsEnabled: &corsEnabled, } @@ -260,8 +260,8 @@ func TestObjectStorageBucket_Access_Update(t *testing.T) { t.Errorf("ObjectStorageBucket access CORS does not match update, expected %t, got %t", corsEnabled, newBucket.CorsEnabled) } - if newBucket.ACL != opts.ACL { - t.Errorf("ObjectStorageBucket access ACL does not match update, expected %s, got %s", opts.ACL, newBucket.ACL) + if opts.ACL == nil || newBucket.ACL != *opts.ACL { + t.Errorf("ObjectStorageBucket access ACL does not match update, expected %s, got %s", *opts.ACL, newBucket.ACL) } } @@ -298,8 +298,8 @@ func setupObjectStorageBucket( selectedEndpoint := endpoints[slices.IndexFunc(endpoints, func(e linodego.ObjectStorageEndpoint) bool { return e.EndpointType == linodego.ObjectStorageEndpointE1 })] - createOpts.Region = selectedEndpoint.Region - createOpts.EndpointType = selectedEndpoint.EndpointType + createOpts.Region = &selectedEndpoint.Region + createOpts.EndpointType = &selectedEndpoint.EndpointType } } diff --git a/test/integration/object_storage_keys_test.go b/test/integration/object_storage_keys_test.go index 5ecb94671..01667b130 100644 --- a/test/integration/object_storage_keys_test.go +++ b/test/integration/object_storage_keys_test.go @@ -13,7 +13,7 @@ import ( ) var testBasicObjectStorageKeyCreateOpts = ObjectStorageKeyCreateOptions{ - Label: label, + Label: "go-test-def", } func TestObjectStorageKey_GetMissing(t *testing.T) { @@ -66,7 +66,7 @@ func TestObjectStorageKey_Update(t *testing.T) { renamedLabel := objectStorageKey.Label + "_r" updateOpts := ObjectStorageKeyUpdateOptions{ - Label: renamedLabel, + Label: &renamedLabel, } objectStorageKey, err = client.UpdateObjectStorageKey(context.Background(), objectStorageKey.ID, updateOpts) if err != nil { @@ -117,14 +117,14 @@ func TestObjectStorageKeys_Limited(t *testing.T) { createOpts := testBasicObjectStorageKeyCreateOpts createOpts.BucketAccess = &[]ObjectStorageKeyBucketAccess{ { - Cluster: "us-east-1", - Region: "us-east", + Cluster: linodego.Pointer("us-east-1"), + Region: linodego.Pointer("us-east"), BucketName: bucket.Label, Permissions: "read_only", }, { - Cluster: "us-east-1", - Region: "us-east", + Cluster: linodego.Pointer("us-east-1"), + Region: linodego.Pointer("us-east"), BucketName: bucket.Label, Permissions: "read_write", }, @@ -136,7 +136,7 @@ func TestObjectStorageKeys_Limited(t *testing.T) { t.Error(err) } if !objectStorageKey.Limited || !cmp.Equal(objectStorageKey.BucketAccess, createOpts.BucketAccess) { - t.Errorf("objectStorageKey returned (%v) does not match objectStorageKey creation request (%v)", *objectStorageKey.BucketAccess, *createOpts.BucketAccess) + t.Errorf("objectStorageKey returned (%v) does not match objectStorageKey creation request (%v)", *objectStorageKey.BucketAccess, createOpts.BucketAccess) } } @@ -168,8 +168,8 @@ func TestObjectStorageKeys_Regional_Limited(t *testing.T) { client, bucket, teardown, err := setupObjectStorageBucket(t, []objectStorageBucketModifier{ func(createOpts *ObjectStorageBucketCreateOptions) { - createOpts.Cluster = "" - createOpts.Region = region + createOpts.Cluster = linodego.Pointer("") + createOpts.Region = ®ion }, }, "fixtures/TestObjectStorageKeys_Regional_Limited", client, teardown, nil) @@ -180,7 +180,7 @@ func TestObjectStorageKeys_Regional_Limited(t *testing.T) { createOpts := testBasicObjectStorageKeyCreateOpts createOpts.BucketAccess = &[]ObjectStorageKeyBucketAccess{ { - Region: region, + Region: ®ion, BucketName: bucket.Label, Permissions: "read_only", }, diff --git a/test/integration/object_storage_object_test.go b/test/integration/object_storage_object_test.go index 14166b734..06f29087c 100644 --- a/test/integration/object_storage_object_test.go +++ b/test/integration/object_storage_object_test.go @@ -17,7 +17,7 @@ func putObjectStorageObject(t *testing.T, client *linodego.Client, bucket *linod url, err := client.CreateObjectStorageObjectURL(context.TODO(), bucket.Cluster, bucket.Label, linodego.ObjectStorageObjectURLCreateOptions{ Name: name, Method: http.MethodPut, - ContentType: "text/plain", + ContentType: linodego.Pointer("text/plain"), ExpiresIn: &objectStorageObjectURLExpirySeconds, }) if err != nil { diff --git a/test/integration/placement_group_test.go b/test/integration/placement_group_test.go index d55559761..93cd37fec 100644 --- a/test/integration/placement_group_test.go +++ b/test/integration/placement_group_test.go @@ -39,7 +39,7 @@ func TestPlacementGroup_basic_smoke(t *testing.T) { context.Background(), pg.ID, linodego.PlacementGroupUpdateOptions{ - Label: updatedLabel, + Label: &updatedLabel, }, ) require.NoError(t, err) diff --git a/test/integration/postgres_test.go b/test/integration/postgres_test.go index 844fe0434..c8abe2245 100644 --- a/test/integration/postgres_test.go +++ b/test/integration/postgres_test.go @@ -51,12 +51,10 @@ func TestDatabase_Postgres_Suite(t *testing.T) { Pending: []linodego.DatabaseMaintenanceWindowPending{}, } - allowList := []string{"128.173.205.21", "123.177.200.20"} - updatedLabel := database.Label + "-updated" opts := linodego.PostgresUpdateOptions{ - AllowList: &allowList, - Label: updatedLabel, + AllowList: []string{"128.173.205.21", "123.177.200.20"}, + Label: &updatedLabel, Updates: &updatedWindow, } db, err = client.UpdatePostgresDatabase(context.Background(), database.ID, opts) @@ -146,7 +144,7 @@ func createPostgresDatabase(t *testing.T, client *linodego.Client, Region: getRegionsWithCaps(t, client, []string{"Managed Databases"})[0], Type: "g6-nanode-1", Engine: "postgresql/14", - ClusterSize: 3, + ClusterSize: linodego.Pointer(3), AllowList: []string{"203.0.113.1", "192.0.1.0/24"}, } for _, modifier := range databaseMofidiers { diff --git a/test/integration/profile_sshkeys_test.go b/test/integration/profile_sshkeys_test.go index 843aea9ef..1f0b411dc 100644 --- a/test/integration/profile_sshkeys_test.go +++ b/test/integration/profile_sshkeys_test.go @@ -9,8 +9,8 @@ import ( ) var testSSHKeyCreateOpts = SSHKeyCreateOptions{ - Label: label, - SSHKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYlv4Ns3tY2NEseuuMXEz1sLzO9sGC0cwaT2ECbWFyrsn1Fg5ISdkaJD8LiuhZ41/1Mh0Sq49wY89yLkmw+Ukrd+thFbhUqTzjL09U89kn3Ds/ajVJgwnJ4pXmBqhq0/3pmO/UkYIBi5ErTnPWL+yHAoQ1HsVetxYUmY2SPaT0pduDIrvNZRvWn3Nvn9qsUVfthWiGc8oHWE5xyd7+3UPLHSMkE4rZd2k6e7bJWCM/VJ7ZrJQ6UVTDXjBCkkT12WsOWxcEuL36RUGgGa4h5M4IY0SkgQSKHer01dJSj3c6OBzj2CRDZFoM8f/YC66s0+ZQ9cE/aADDycMIvqOJBI6X " + label, + Label: "go-test-def", + SSHKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYlv4Ns3tY2NEseuuMXEz1sLzO9sGC0cwaT2ECbWFyrsn1Fg5ISdkaJD8LiuhZ41/1Mh0Sq49wY89yLkmw+Ukrd+thFbhUqTzjL09U89kn3Ds/ajVJgwnJ4pXmBqhq0/3pmO/UkYIBi5ErTnPWL+yHAoQ1HsVetxYUmY2SPaT0pduDIrvNZRvWn3Nvn9qsUVfthWiGc8oHWE5xyd7+3UPLHSMkE4rZd2k6e7bJWCM/VJ7ZrJQ6UVTDXjBCkkT12WsOWxcEuL36RUGgGa4h5M4IY0SkgQSKHer01dJSj3c6OBzj2CRDZFoM8f/YC66s0+ZQ9cE/aADDycMIvqOJBI6X " + "go-test-def", } func TestSSHKey_GetMissing(t *testing.T) { diff --git a/test/integration/profile_test.go b/test/integration/profile_test.go index e2e96d1b9..20cea0bce 100644 --- a/test/integration/profile_test.go +++ b/test/integration/profile_test.go @@ -28,7 +28,7 @@ func TestProfile_Update(t *testing.T) { } updateOpts := profile.GetUpdateOptions() - if updateOpts.Email != profile.Email { + if updateOpts.Email == nil || *updateOpts.Email != profile.Email { t.Errorf("Expected matching Username from GetUpdateOptions, got: %v", updateOpts) } @@ -36,7 +36,7 @@ func TestProfile_Update(t *testing.T) { if err != nil { t.Errorf("Error updating profile: %s", err) } - if i.Email != updateOpts.Email { + if updateOpts.Email == nil || i.Email != *updateOpts.Email { t.Errorf("Expected profile email to be changed, but found %v", i) } } diff --git a/test/integration/tags_test.go b/test/integration/tags_test.go index b2dc748a2..544adb572 100644 --- a/test/integration/tags_test.go +++ b/test/integration/tags_test.go @@ -20,10 +20,10 @@ func TestTag_Create_create_smoke(t *testing.T) { updateOpts := instance.GetUpdateOptions() if updateOpts.Tags == nil { - updateOpts.Tags = new([]string) + updateOpts.Tags = []string{} } - newTags := append(*updateOpts.Tags, "go-tag-test-bar") - updateOpts.Tags = &newTags + newTags := append(updateOpts.Tags, "go-tag-test-bar") + updateOpts.Tags = newTags updateOpts.Backups = nil instance, err = client.UpdateInstance(context.Background(), instance.ID, updateOpts) if err != nil { @@ -94,7 +94,7 @@ func setupTaggedInstance(t *testing.T, fixturesYaml string) (*Client, *Instance, t.Helper() client, fixtureTeardown := createTestClient(t, fixturesYaml) createOpts := InstanceCreateOptions{ - Label: "go-ins-test-tag", + Label: Pointer("go-ins-test-tag"), Region: getRegionsWithCaps(t, client, []string{"Linodes"})[0], Type: "g6-nanode-1", Tags: []string{"go-tag-test"}, diff --git a/test/integration/vlans_test.go b/test/integration/vlans_test.go index 64bcced77..253d92839 100644 --- a/test/integration/vlans_test.go +++ b/test/integration/vlans_test.go @@ -83,19 +83,17 @@ func TestVLANs_GetIPAMAddress(t *testing.T) { func createVLANInstance(t *testing.T, client *linodego.Client, instanceName, vlanName string) (*linodego.Instance, func(), error) { t.Helper() - trueBool := true - instance, err := createInstance(t, client, true, func(client *linodego.Client, opts *linodego.InstanceCreateOptions) { opts.Interfaces = []linodego.InstanceConfigInterfaceCreateOptions{ { - Label: vlanName, - Purpose: linodego.InterfacePurposeVLAN, - IPAMAddress: "10.0.0.1/24", + Label: &vlanName, + Purpose: linodego.Pointer(linodego.InterfacePurposeVLAN), + IPAMAddress: linodego.Pointer("10.0.0.1/24"), }, } - opts.Booted = &trueBool - opts.Label = instanceName + opts.Booted = linodego.Pointer(true) + opts.Label = &instanceName opts.Region = getRegionsWithCaps(t, client, []string{"Vlans"})[0] }) if err != nil { diff --git a/test/integration/volumes_test.go b/test/integration/volumes_test.go index 0060dfe7c..a885ce6e7 100644 --- a/test/integration/volumes_test.go +++ b/test/integration/volumes_test.go @@ -15,8 +15,8 @@ func TestVolume_Create_smoke(t *testing.T) { defer teardown() createOpts := linodego.VolumeCreateOptions{ - Label: "go-vol-test-create", - Region: getRegionsWithCaps(t, client, []string{"Linodes"})[0], + Label: linodego.Pointer("go-vol-test-create"), + Region: linodego.Pointer(getRegionsWithCaps(t, client, []string{"Linodes"})[0]), } volume, err := client.CreateVolume(context.Background(), createOpts) if err != nil { @@ -41,9 +41,9 @@ func TestVolume_Create_withEncryption(t *testing.T) { defer teardown() createOpts := linodego.VolumeCreateOptions{ - Label: "go-vol-test-create-encryption", - Region: getRegionsWithCaps(t, client, []string{"Linodes", "Block Storage Encryption"})[0], - Encryption: "enabled", + Label: linodego.Pointer("go-vol-test-create-encryption"), + Region: linodego.Pointer(getRegionsWithCaps(t, client, []string{"Linodes", "Block Storage Encryption"})[0]), + Encryption: linodego.Pointer("enabled"), } volume, err := client.CreateVolume(context.Background(), createOpts) if err != nil { @@ -120,9 +120,9 @@ func TestVolume_Get_withEncryption(t *testing.T) { defer teardown() createOpts := linodego.VolumeCreateOptions{ - Label: "go-vol-test-get-encryption", - Region: getRegionsWithCaps(t, client, []string{"Linodes", "Block Storage Encryption"})[0], - Encryption: "enabled", + Label: linodego.Pointer("go-vol-test-get-encryption"), + Region: linodego.Pointer(getRegionsWithCaps(t, client, []string{"Linodes", "Block Storage Encryption"})[0]), + Encryption: linodego.Pointer("enabled"), } volume, err := client.CreateVolume(context.Background(), createOpts) if err != nil { @@ -186,7 +186,7 @@ func TestVolume_WaitForLinodeID(t *testing.T) { defer teardownInstance() createConfigOpts := linodego.InstanceConfigCreateOptions{ - Label: "go-config-test-wait", + Label: linodego.Pointer("go-config-test-wait"), Devices: linodego.InstanceConfigDeviceMap{}, } config, errConfig := client.CreateInstanceConfig(context.Background(), instance.ID, createConfigOpts) @@ -200,7 +200,7 @@ func TestVolume_WaitForLinodeID(t *testing.T) { } defer teardownVolume() - attachOptions := linodego.VolumeAttachOptions{LinodeID: instance.ID, ConfigID: config.ID} + attachOptions := linodego.VolumeAttachOptions{LinodeID: instance.ID, ConfigID: &config.ID} if volumeAttached, err := client.AttachVolume(context.Background(), volume.ID, &attachOptions); err != nil { t.Errorf("Error attaching volume, %s", err) } else if volumeAttached.LinodeID == nil { @@ -232,7 +232,7 @@ func TestVolume_Update(t *testing.T) { defer teardown() updatedLabel := volume.Label + "-updated" updateOpts := linodego.VolumeUpdateOptions{ - Label: updatedLabel, + Label: &updatedLabel, } volume, err = client.UpdateVolume(context.Background(), volume.ID, updateOpts) if err != nil { @@ -253,8 +253,8 @@ func setupVolume(t *testing.T, fixturesYaml string) (*linodego.Client, *linodego var fixtureTeardown func() client, fixtureTeardown := createTestClient(t, fixturesYaml) createOpts := linodego.VolumeCreateOptions{ - Label: "go-vol-test-def", - Region: getRegionsWithCaps(t, client, []string{"Linodes"})[0], + Label: linodego.Pointer("go-vol-test-def"), + Region: linodego.Pointer(getRegionsWithCaps(t, client, []string{"Linodes"})[0]), } volume, err := client.CreateVolume(context.Background(), createOpts) if err != nil { @@ -279,8 +279,8 @@ func createVolume( ) (*linodego.Volume, func(), error) { t.Helper() createOpts := linodego.VolumeCreateOptions{ - Label: "go-vol-test" + randLabel(), - Region: getRegionsWithCaps(t, client, []string{"Linodes"})[0], + Label: linodego.Pointer("go-vol-test" + randLabel()), + Region: linodego.Pointer(getRegionsWithCaps(t, client, []string{"Linodes"})[0]), } for _, mod := range vModifier { diff --git a/test/integration/vpc_subnet_test.go b/test/integration/vpc_subnet_test.go index 03be9be3a..f3bdcd53e 100644 --- a/test/integration/vpc_subnet_test.go +++ b/test/integration/vpc_subnet_test.go @@ -326,7 +326,7 @@ func TestVPC_Subnet_WithInstance(t *testing.T) { t.Fatal("IP/VPC id mismatch") } - if nat1To1.Address != config.Interfaces[2].IPv4.VPC { + if nat1To1.Address != *config.Interfaces[2].IPv4.VPC { t.Fatalf("nat_1_1 subnet IP mismatch") } } diff --git a/test/integration/vpc_test.go b/test/integration/vpc_test.go index a5a19c15d..40b12eff3 100644 --- a/test/integration/vpc_test.go +++ b/test/integration/vpc_test.go @@ -97,14 +97,14 @@ func vpcCreateOptionsCheck( vpc *linodego.VPC, t *testing.T, ) { - good := (opts.Description == vpc.Description && + good := (*opts.Description == vpc.Description && opts.Label == vpc.Label && opts.Region == vpc.Region && len(opts.Subnets) == len(vpc.Subnets)) for i := 0; i < minInt(len(opts.Subnets), len(vpc.Subnets)); i++ { - good = good && (opts.Subnets[i].IPv4 == vpc.Subnets[i].IPv4 && - opts.Subnets[i].Label == vpc.Subnets[i].Label) + good = good && ((opts.Subnets)[i].IPv4 == vpc.Subnets[i].IPv4 && + (opts.Subnets)[i].Label == vpc.Subnets[i].Label) } if !good { @@ -119,7 +119,7 @@ func vpcUpdateOptionsCheck( vpc *linodego.VPC, t *testing.T, ) { - if !(opts.Description == vpc.Description && opts.Label == vpc.Label) { + if !(*opts.Description == vpc.Description && *opts.Label == vpc.Label) { t.Error("the VPC instance and VPC Update Options instance are mismatched") } } @@ -150,8 +150,8 @@ func TestVPC_Update(t *testing.T) { updatedDescription := "updated description" updatedLabel := "updated-label" - opts.Description = updatedDescription - opts.Label = updatedLabel + opts.Description = &updatedDescription + opts.Label = &updatedLabel updatedVPC, err := client.UpdateVPC(context.Background(), vpc.ID, opts) if err != nil { t.Error(formatVPCError(err, "updating", &vpc.ID)) @@ -214,8 +214,8 @@ func TestVPC_Update_Invalid_data(t *testing.T) { updatedDescription := "updated description" updatedLabel := "updated_invalid_label" - opts.Description = updatedDescription - opts.Label = updatedLabel + opts.Description = &updatedDescription + opts.Label = &updatedLabel _, err = client.UpdateVPC(context.Background(), vpc.ID, opts) @@ -248,10 +248,10 @@ func TestVPC_ListAllIPAddresses(t *testing.T) { t.Fatal("expecting 1 VPC IP address, but got 0") } - if *vpcIPs[0].Address != config.Interfaces[0].IPv4.VPC { + if *vpcIPs[0].Address != *config.Interfaces[0].IPv4.VPC { t.Fatalf( "expecting VPC IP address on Linode %d to be %q, but got %q", - instance.ID, *vpcIPs[0].Address, config.Interfaces[0].IPv4.VPC, + instance.ID, *vpcIPs[0].Address, *config.Interfaces[0].IPv4.VPC, ) } } @@ -275,10 +275,10 @@ func TestVPC_ListIPAddresses(t *testing.T) { t.Fatal("expecting 1 VPC IP address, but got 0") } - if *vpcIPs[0].Address != config.Interfaces[0].IPv4.VPC { + if *vpcIPs[0].Address != *config.Interfaces[0].IPv4.VPC { t.Fatalf( "expecting VPC IP address on Linode %d to be %q, but got %q", - instance.ID, *vpcIPs[0].Address, config.Interfaces[0].IPv4.VPC, + instance.ID, *vpcIPs[0].Address, *config.Interfaces[0].IPv4.VPC, ) } } diff --git a/test/integration/waitfor_test.go b/test/integration/waitfor_test.go index 244b220f6..fc4e80852 100644 --- a/test/integration/waitfor_test.go +++ b/test/integration/waitfor_test.go @@ -20,9 +20,9 @@ func TestEventPoller_InstancePower(t *testing.T) { instance, err := client.CreateInstance(context.Background(), linodego.InstanceCreateOptions{ Region: getRegionsWithCaps(t, client, []string{"Linodes"})[0], Type: "g6-nanode-1", - Image: "linode/ubuntu22.04", - RootPass: randPassword(), - Label: "go-ins-poll-test", + Image: linodego.Pointer("linode/ubuntu22.04"), + RootPass: linodego.Pointer(randPassword()), + Label: linodego.Pointer("go-ins-poll-test"), Booted: linodego.Pointer(false), }) if err != nil { @@ -104,9 +104,9 @@ func TestWaitForResourceFree(t *testing.T) { instance, err := client.CreateInstance(context.Background(), linodego.InstanceCreateOptions{ Region: getRegionsWithCaps(t, client, []string{"Linodes"})[0], Type: "g6-nanode-1", - Image: "linode/ubuntu22.04", - RootPass: randPassword(), - Label: "linodego-waitforfree", + Image: linodego.Pointer("linode/ubuntu22.04"), + RootPass: linodego.Pointer(randPassword()), + Label: linodego.Pointer("linodego-waitforfree"), }) if err != nil { t.Fatal(err) @@ -147,7 +147,7 @@ func TestEventPoller_Secondary(t *testing.T) { instance, err := client.CreateInstance(context.Background(), linodego.InstanceCreateOptions{ Region: getRegionsWithCaps(t, client, []string{"Linodes"})[0], Type: "g6-nanode-1", - Label: "go-ins-poll-test", + Label: linodego.Pointer("go-ins-poll-test"), Booted: linodego.Pointer(false), }) if err != nil { diff --git a/test/unit/account_agreements_test.go b/test/unit/account_agreements_test.go index 060d686c7..d78c6dd94 100644 --- a/test/unit/account_agreements_test.go +++ b/test/unit/account_agreements_test.go @@ -30,10 +30,14 @@ func TestAccountAgreements_Get(t *testing.T) { func TestAccountAgreements_Acknowledge(t *testing.T) { client := createMockClient(t) + euModel := true + masterServiceAgreement := true + privacyPolicy := true + requestData := linodego.AccountAgreementsUpdateOptions{ - EUModel: true, - MasterServiceAgreement: true, - PrivacyPolicy: true, + EUModel: &euModel, + MasterServiceAgreement: &masterServiceAgreement, + PrivacyPolicy: &privacyPolicy, } httpmock.RegisterRegexpResponder("POST", mockRequestURL(t, "account/agreements"), diff --git a/test/unit/account_payments_test.go b/test/unit/account_payments_test.go index 36553b433..5fbe4a0b6 100644 --- a/test/unit/account_payments_test.go +++ b/test/unit/account_payments_test.go @@ -19,8 +19,10 @@ func TestAccountPayments_Create(t *testing.T) { base.MockPost("account/payments", fixtureData) + cvv := "123" + requestData := linodego.PaymentCreateOptions{ - CVV: "123", + CVV: &cvv, USD: json.Number("120.50"), } diff --git a/test/unit/account_test.go b/test/unit/account_test.go index c6c7d0c35..8cfd2e01b 100644 --- a/test/unit/account_test.go +++ b/test/unit/account_test.go @@ -60,9 +60,12 @@ func TestAccount_Update(t *testing.T) { base.SetUp(t) defer base.TearDown(t) + city := "Cambridge" + state := "MA" + requestData := linodego.AccountUpdateOptions{ - City: "Cambridge", - State: "MA", + City: &city, + State: &state, } base.MockPut("account", fixtureData) diff --git a/test/unit/account_users_test.go b/test/unit/account_users_test.go index e72c3a4bf..52fdc34cb 100644 --- a/test/unit/account_users_test.go +++ b/test/unit/account_users_test.go @@ -95,10 +95,12 @@ func TestAccountUsers_Update(t *testing.T) { defer base.TearDown(t) restricted := true + username := "adevi" + email := "jkowalski@linode.com" requestData := linodego.UserUpdateOptions{ - Username: "adevi", - Email: "jkowalski@linode.com", + Username: &username, + Email: &email, Restricted: &restricted, } diff --git a/test/unit/domain_test.go b/test/unit/domain_test.go index ec35361e9..4827d9c8a 100644 --- a/test/unit/domain_test.go +++ b/test/unit/domain_test.go @@ -76,19 +76,27 @@ func TestDomain_Create(t *testing.T) { base.SetUp(t) defer base.TearDown(t) + description := "" + soaEmail := "admin@example.org" + retrySec := 300 + expireSec := 300 + refreshSec := 300 + ttlSec := 300 + status := linodego.DomainStatus("active") + requestData := linodego.DomainCreateOptions{ Domain: "example.org", Type: linodego.DomainType("master"), - Description: "", - SOAEmail: "admin@example.org", - RetrySec: 300, + Description: &description, + SOAEmail: &soaEmail, + RetrySec: &retrySec, MasterIPs: []string{}, AXfrIPs: []string{}, Tags: []string{"example tag", "another example"}, - ExpireSec: 300, - RefreshSec: 300, - TTLSec: 300, - Status: linodego.DomainStatus("active"), + ExpireSec: &expireSec, + RefreshSec: &refreshSec, + TTLSec: &ttlSec, + Status: &status, } base.MockPost(formatMockAPIPath("domains"), fixtureData) @@ -121,19 +129,29 @@ func TestDomain_Update(t *testing.T) { domainID := 1234 + domainName := "example.org" + domainType := linodego.DomainType("master") + description := "" + soaEmail := "admin@example.org" + retrySec := 300 + expireSec := 300 + refreshSec := 300 + ttlSec := 300 + status := linodego.DomainStatus("active") + requestData := linodego.DomainUpdateOptions{ - Domain: "example.org", - Type: linodego.DomainType("master"), - Description: "", - SOAEmail: "admin@example.org", - RetrySec: 300, + Domain: &domainName, + Type: &domainType, + Description: &description, + SOAEmail: &soaEmail, + RetrySec: &retrySec, MasterIPs: []string{}, AXfrIPs: []string{}, Tags: []string{"example tag", "another example"}, - ExpireSec: 300, - RefreshSec: 300, - TTLSec: 300, - Status: linodego.DomainStatus("active"), + ExpireSec: &expireSec, + RefreshSec: &refreshSec, + TTLSec: &ttlSec, + Status: &status, } base.MockPut(formatMockAPIPath("domains/%d", domainID), fixtureData) diff --git a/test/unit/domainrecord_test.go b/test/unit/domainrecord_test.go index 5739dcbab..dcdeb6a9f 100644 --- a/test/unit/domainrecord_test.go +++ b/test/unit/domainrecord_test.go @@ -91,6 +91,7 @@ func TestDomainRecord_Create(t *testing.T) { service := (*string)(nil) protocol := (*string)(nil) tag := (*string)(nil) + ttlSec := 604800 requestData := linodego.DomainRecordCreateOptions{ Type: linodego.RecordTypeA, @@ -101,7 +102,7 @@ func TestDomainRecord_Create(t *testing.T) { Port: &port, Service: service, Protocol: protocol, - TTLSec: 604800, + TTLSec: &ttlSec, Tag: tag, } @@ -141,17 +142,21 @@ func TestDomainRecord_Update(t *testing.T) { service := (*string)(nil) protocol := (*string)(nil) tag := (*string)(nil) + recordType := linodego.RecordTypeA + name := "test" + target := "192.0.2.0" + ttlSec := 604800 requestData := linodego.DomainRecordUpdateOptions{ - Type: linodego.RecordTypeA, - Name: "test", - Target: "192.0.2.0", + Type: &recordType, + Name: &name, + Target: &target, Priority: &priority, Weight: &weight, Port: &port, Service: service, Protocol: protocol, - TTLSec: 604800, + TTLSec: &ttlSec, Tag: tag, } diff --git a/test/unit/instance_test.go b/test/unit/instance_test.go index c04e19e55..b57884afd 100644 --- a/test/unit/instance_test.go +++ b/test/unit/instance_test.go @@ -47,9 +47,12 @@ func TestInstance_Migrate(t *testing.T) { upgrade := false + migrationType := linodego.InstanceMigrationType("cold") + region := "us-west" + requestData := linodego.InstanceMigrateOptions{ - Type: "cold", - Region: "us-west", + Type: &migrationType, + Region: ®ion, Upgrade: &upgrade, } diff --git a/test/unit/mysql_test.go b/test/unit/mysql_test.go index 844de0544..d9ff5cd55 100644 --- a/test/unit/mysql_test.go +++ b/test/unit/mysql_test.go @@ -62,8 +62,10 @@ func TestDatabaseMySQL_Update(t *testing.T) { base.SetUp(t) defer base.TearDown(t) + label := "example-db-updated" + requestData := linodego.MySQLUpdateOptions{ - Label: "example-db-updated", + Label: &label, } base.MockPut("databases/mysql/instances/123", fixtureData) diff --git a/test/unit/placement_group_test.go b/test/unit/placement_group_test.go index 7283ca1d4..78e1cd54a 100644 --- a/test/unit/placement_group_test.go +++ b/test/unit/placement_group_test.go @@ -80,8 +80,10 @@ func TestPlacementGroups_Update(t *testing.T) { base.SetUp(t) defer base.TearDown(t) + label := "PG_Miami_failover_new" + requestData := linodego.PlacementGroupUpdateOptions{ - Label: "PG_Miami_failover_new", + Label: &label, } base.MockPut("placement/groups/528", fixtureData) diff --git a/test/unit/postgres_test.go b/test/unit/postgres_test.go index 011c45af5..3666add89 100644 --- a/test/unit/postgres_test.go +++ b/test/unit/postgres_test.go @@ -61,8 +61,10 @@ func TestDatabasePostgreSQL_Update(t *testing.T) { base.SetUp(t) defer base.TearDown(t) + label := "example-db-updated" + requestData := linodego.PostgresUpdateOptions{ - Label: "example-db-updated", + Label: &label, } base.MockPut("databases/postgresql/instances/123", fixtureData) diff --git a/test/unit/profile_test.go b/test/unit/profile_test.go index ca82f52a6..6697d67bf 100644 --- a/test/unit/profile_test.go +++ b/test/unit/profile_test.go @@ -21,6 +21,8 @@ func TestProfile_Get(t *testing.T) { profile, err := base.Client.GetProfile(context.Background()) assert.NoError(t, err) + verifiedPhoneNumber := "+5555555555" + assert.Equal(t, "password", profile.AuthenticationType) assert.Equal(t, "example-user@gmail.com", profile.Email) assert.Equal(t, true, profile.EmailNotifications) @@ -36,7 +38,7 @@ func TestProfile_Get(t *testing.T) { assert.Equal(t, true, profile.TwoFactorAuth) assert.Equal(t, 1234, profile.UID) assert.Equal(t, "exampleUser", profile.Username) - assert.Equal(t, "+5555555555", profile.VerifiedPhoneNumber) + assert.Equal(t, &verifiedPhoneNumber, profile.VerifiedPhoneNumber) } func TestProfile_Update(t *testing.T) { @@ -47,8 +49,10 @@ func TestProfile_Update(t *testing.T) { base.SetUp(t) defer base.TearDown(t) + email := "example-user-new@gmail.com" + requestData := linodego.ProfileUpdateOptions{ - Email: "example-user-new@gmail.com", + Email: &email, } base.MockPut("profile", fixtureData) @@ -56,6 +60,8 @@ func TestProfile_Update(t *testing.T) { profile, err := base.Client.UpdateProfile(context.Background(), requestData) assert.NoError(t, err) + verifiedPhoneNumber := "+5555555555" + assert.Equal(t, "password", profile.AuthenticationType) assert.Equal(t, "example-user-new@gmail.com", profile.Email) assert.Equal(t, true, profile.EmailNotifications) @@ -71,5 +77,5 @@ func TestProfile_Update(t *testing.T) { assert.Equal(t, true, profile.TwoFactorAuth) assert.Equal(t, 1234, profile.UID) assert.Equal(t, "exampleUser", profile.Username) - assert.Equal(t, "+5555555555", profile.VerifiedPhoneNumber) + assert.Equal(t, &verifiedPhoneNumber, profile.VerifiedPhoneNumber) } diff --git a/test/unit/volume_test.go b/test/unit/volume_test.go index 74fda3441..7116f4fbe 100644 --- a/test/unit/volume_test.go +++ b/test/unit/volume_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/assert" "github.com/linode/linodego" + "github.com/stretchr/testify/assert" ) func TestListVolumes(t *testing.T) { @@ -70,9 +70,12 @@ func TestCreateVolume(t *testing.T) { base.MockPost("volumes", fixtureData) + label := "new-volume" + size := 20 + opts := linodego.VolumeCreateOptions{ - Label: "new-volume", - Size: 20, + Label: &label, + Size: &size, Tags: []string{"test"}, } @@ -100,9 +103,11 @@ func TestUpdateVolume(t *testing.T) { volumeID := 123 base.MockPut(fmt.Sprintf("volumes/%d", volumeID), fixtureData) + label := "new-volume" + opts := linodego.VolumeUpdateOptions{ - Label: "updated-volume", - Tags: &[]string{"updated"}, + Label: &label, + Tags: []string{"updated"}, } updatedVolume, err := base.Client.UpdateVolume(context.Background(), volumeID, opts) @@ -128,30 +133,30 @@ func TestDeleteVolume(t *testing.T) { } func TestAttachVolume(t *testing.T) { - // Mock the API response for attaching a volume - fixtureData, err := fixtures.GetFixture("volume_attach") - assert.NoError(t, err) - - var base ClientBaseCase - base.SetUp(t) - defer base.TearDown(t) - - volumeID := 123 - base.MockPost(fmt.Sprintf("volumes/%d/attach", volumeID), fixtureData) - - // Use direct pointer assignment for PersistAcrossBoots - persistAcrossBoots := true - opts := &linodego.VolumeAttachOptions{ - LinodeID: 456, - PersistAcrossBoots: &persistAcrossBoots, - } - - attachedVolume, err := base.Client.AttachVolume(context.Background(), volumeID, opts) - assert.NoError(t, err, "Expected no error when attaching volume") - - // Verify the attached volume's LinodeID and filesystem path - assert.Equal(t, 456, *attachedVolume.LinodeID, "Expected LinodeID to match input") - assert.Equal(t, "/dev/disk/by-id/volume-123", attachedVolume.FilesystemPath, "Expected filesystem path to match fixture") + // Mock the API response for attaching a volume + fixtureData, err := fixtures.GetFixture("volume_attach") + assert.NoError(t, err) + + var base ClientBaseCase + base.SetUp(t) + defer base.TearDown(t) + + volumeID := 123 + base.MockPost(fmt.Sprintf("volumes/%d/attach", volumeID), fixtureData) + + // Use direct pointer assignment for PersistAcrossBoots + persistAcrossBoots := true + opts := &linodego.VolumeAttachOptions{ + LinodeID: 456, + PersistAcrossBoots: &persistAcrossBoots, + } + + attachedVolume, err := base.Client.AttachVolume(context.Background(), volumeID, opts) + assert.NoError(t, err, "Expected no error when attaching volume") + + // Verify the attached volume's LinodeID and filesystem path + assert.Equal(t, 456, *attachedVolume.LinodeID, "Expected LinodeID to match input") + assert.Equal(t, "/dev/disk/by-id/volume-123", attachedVolume.FilesystemPath, "Expected filesystem path to match fixture") } func TestDetachVolume(t *testing.T) { diff --git a/volumes.go b/volumes.go index 389f03477..3a6c0efde 100644 --- a/volumes.go +++ b/volumes.go @@ -46,28 +46,28 @@ type Volume struct { // VolumeCreateOptions fields are those accepted by CreateVolume type VolumeCreateOptions struct { - Label string `json:"label,omitempty"` - Region string `json:"region,omitempty"` - LinodeID int `json:"linode_id,omitempty"` - ConfigID int `json:"config_id,omitempty"` + Label *string `json:"label,omitempty"` + Region *string `json:"region,omitempty"` + LinodeID *int `json:"linode_id,omitempty"` + ConfigID *int `json:"config_id,omitempty"` // The Volume's size, in GiB. Minimum size is 10GiB, maximum size is 10240GiB. A "0" value will result in the default size. - Size int `json:"size,omitempty"` + Size *int `json:"size,omitempty"` // An array of tags applied to this object. Tags are for organizational purposes only. Tags []string `json:"tags"` PersistAcrossBoots *bool `json:"persist_across_boots,omitempty"` - Encryption string `json:"encryption,omitempty"` + Encryption *string `json:"encryption,omitempty"` } // VolumeUpdateOptions fields are those accepted by UpdateVolume type VolumeUpdateOptions struct { - Label string `json:"label,omitempty"` - Tags *[]string `json:"tags,omitempty"` + Label *string `json:"label,omitempty"` + Tags []string `json:"tags,omitempty"` } // VolumeAttachOptions fields are those accepted by AttachVolume type VolumeAttachOptions struct { LinodeID int `json:"linode_id"` - ConfigID int `json:"config_id,omitempty"` + ConfigID *int `json:"config_id,omitempty"` PersistAcrossBoots *bool `json:"persist_across_boots,omitempty"` } @@ -95,19 +95,19 @@ func (v *Volume) UnmarshalJSON(b []byte) error { // GetUpdateOptions converts a Volume to VolumeUpdateOptions for use in UpdateVolume func (v Volume) GetUpdateOptions() (updateOpts VolumeUpdateOptions) { - updateOpts.Label = v.Label - updateOpts.Tags = &v.Tags + updateOpts.Label = &v.Label + updateOpts.Tags = v.Tags return } // GetCreateOptions converts a Volume to VolumeCreateOptions for use in CreateVolume func (v Volume) GetCreateOptions() (createOpts VolumeCreateOptions) { - createOpts.Label = v.Label + createOpts.Label = &v.Label createOpts.Tags = v.Tags - createOpts.Region = v.Region - createOpts.Size = v.Size + createOpts.Region = &v.Region + createOpts.Size = &v.Size if v.LinodeID != nil && *v.LinodeID > 0 { - createOpts.LinodeID = *v.LinodeID + createOpts.LinodeID = &*v.LinodeID } return } diff --git a/vpc.go b/vpc.go index 644c4ceb8..4dd17b453 100644 --- a/vpc.go +++ b/vpc.go @@ -20,14 +20,14 @@ type VPC struct { type VPCCreateOptions struct { Label string `json:"label"` - Description string `json:"description,omitempty"` + Description *string `json:"description,omitempty"` Region string `json:"region"` Subnets []VPCSubnetCreateOptions `json:"subnets,omitempty"` } type VPCUpdateOptions struct { - Label string `json:"label,omitempty"` - Description string `json:"description,omitempty"` + Label *string `json:"label,omitempty"` + Description *string `json:"description,omitempty"` } func (v VPC) GetCreateOptions() VPCCreateOptions { @@ -38,7 +38,7 @@ func (v VPC) GetCreateOptions() VPCCreateOptions { return VPCCreateOptions{ Label: v.Label, - Description: v.Description, + Description: &v.Description, Region: v.Region, Subnets: subnetCreations, } @@ -46,8 +46,8 @@ func (v VPC) GetCreateOptions() VPCCreateOptions { func (v VPC) GetUpdateOptions() VPCUpdateOptions { return VPCUpdateOptions{ - Label: v.Label, - Description: v.Description, + Label: &v.Label, + Description: &v.Description, } }