Skip to content

Commit

Permalink
Fix instance create opts (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-akamai authored Sep 1, 2023
1 parent 9e2ab66 commit 4d3bb35
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
34 changes: 17 additions & 17 deletions instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,23 @@ type InstanceMetadataOptions struct {

// InstanceCreateOptions require only Region and Type
type InstanceCreateOptions struct {
Region string `json:"region"`
Type string `json:"type"`
Label string `json:"label,omitempty"`
Group string `json:"group,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"`
StackScriptData map[string]string `json:"stackscript_data,omitempty"`
BackupID int `json:"backup_id,omitempty"`
Image string `json:"image,omitempty"`
Interfaces []InstanceConfigInterface `json:"interfaces,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"`
Region string `json:"region"`
Type string `json:"type"`
Label string `json:"label,omitempty"`
Group string `json:"group,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"`
StackScriptData map[string]string `json:"stackscript_data,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"`
Tags []string `json:"tags,omitempty"`
Metadata *InstanceMetadataOptions `json:"metadata,omitempty"`
FirewallID int `json:"firewall_id,omitempty"`

// Creation fields that need to be set explicitly false, "", or 0 use pointers
SwapSize *int `json:"swap_size,omitempty"`
Expand Down
2 changes: 0 additions & 2 deletions test/integration/instance_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ func setupVPCWithSubnetWithInstance(
vpc, vpcSubnet, vpcWithSubnetTeardown, err := createVPCWithSubnet(t, client)
if err != nil {
t.Error(err)
instanceTeardown()
vpcWithSubnetTeardown()
}

teardownAll := func() {
Expand Down
7 changes: 2 additions & 5 deletions test/integration/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,15 @@ func createInstanceWithoutDisks(
instance, err := client.CreateInstance(context.Background(), createOpts)
if err != nil {
t.Errorf("Error creating test Instance: %s", err)
return nil, nil, func(){}, err
return nil, nil, func() {}, err
}
configOpts := linodego.InstanceConfigCreateOptions{
Label: "go-test-conf-" + randLabel(),
}
config, err := client.CreateInstanceConfig(context.Background(), instance.ID, configOpts)
if err != nil {
t.Errorf("Error creating config: %s", err)
return nil, nil, func(){}, err
return nil, nil, func() {}, err
}

teardown := func() {
Expand All @@ -533,9 +533,6 @@ func setupInstanceWithoutDisks(t *testing.T, fixturesYaml string, modifiers ...i
instance, config, instanceTeardown, err := createInstanceWithoutDisks(t, client)

teardown := func() {
if terr := client.DeleteInstance(context.Background(), instance.ID); terr != nil {
t.Errorf("Error deleting test Instance: %s", terr)
}
instanceTeardown()
fixtureTeardown()
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/vlans_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func createVLANInstance(t *testing.T, client *linodego.Client, instanceName, vla
trueBool := true

instance, err := createInstance(t, client, func(client *linodego.Client, opts *linodego.InstanceCreateOptions) {
opts.Interfaces = []linodego.InstanceConfigInterface{
opts.Interfaces = []linodego.InstanceConfigInterfaceCreateOptions{
{
Label: vlanName,
Purpose: linodego.InterfacePurposeVLAN,
Expand Down
2 changes: 1 addition & 1 deletion test/integration/vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestVPC_List(t *testing.T) {
found = true
}
}

if !found {
t.Errorf("vpc %v not found in list", vpc.ID)
}
Expand Down

0 comments on commit 4d3bb35

Please sign in to comment.