Skip to content

Commit

Permalink
undo refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed Dec 20, 2023
1 parent 52a9b08 commit 178c671
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
8 changes: 4 additions & 4 deletions internal/cmd/firewall/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ var CreateCmd = base.CreateCmd{
}
}

res, _, err := client.Firewall().Create(ctx, opts)
result, _, err := client.Firewall().Create(ctx, opts)
if err != nil {
return nil, nil, err
}

if err := waiter.WaitForActions(ctx, res.Actions); err != nil {
if err := waiter.WaitForActions(ctx, result.Actions); err != nil {
return nil, nil, err
}

cmd.Printf("Firewall %d created\n", res.Firewall.ID)
cmd.Printf("Firewall %d created\n", result.Firewall.ID)

return res.Firewall, util.Wrap("firewall", hcloud.SchemaFromFirewall(res.Firewall)), err
return result.Firewall, util.Wrap("firewall", hcloud.SchemaFromFirewall(result.Firewall)), err
},
}
12 changes: 6 additions & 6 deletions internal/cmd/floatingip/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,24 @@ var CreateCmd = base.CreateCmd{
createOpts.Server = server
}

res, _, err := client.FloatingIP().Create(ctx, createOpts)
result, _, err := client.FloatingIP().Create(ctx, createOpts)
if err != nil {
return nil, nil, err
}

if res.Action != nil {
if err := waiter.ActionProgress(ctx, res.Action); err != nil {
if result.Action != nil {
if err := waiter.ActionProgress(ctx, result.Action); err != nil {
return nil, nil, err
}
}

cmd.Printf("Floating IP %d created\n", res.FloatingIP.ID)
cmd.Printf("Floating IP %d created\n", result.FloatingIP.ID)

if err := changeProtection(ctx, client, waiter, cmd, res.FloatingIP, true, protectionOps); err != nil {
if err := changeProtection(ctx, client, waiter, cmd, result.FloatingIP, true, protectionOps); err != nil {
return nil, nil, err
}

return res.FloatingIP, util.Wrap("floating_ip", hcloud.SchemaFromFloatingIP(res.FloatingIP)), nil
return result.FloatingIP, util.Wrap("floating_ip", hcloud.SchemaFromFloatingIP(result.FloatingIP)), nil
},

PrintResource: func(ctx context.Context, client hcapi2.Client, cmd *cobra.Command, resource any) {
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/loadbalancer/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ var CreateCmd = base.CreateCmd{
if location != "" {
createOpts.Location = &hcloud.Location{Name: location}
}
res, _, err := client.LoadBalancer().Create(ctx, createOpts)
result, _, err := client.LoadBalancer().Create(ctx, createOpts)
if err != nil {
return nil, nil, err
}

if err := waiter.ActionProgress(ctx, res.Action); err != nil {
if err := waiter.ActionProgress(ctx, result.Action); err != nil {
return nil, nil, err
}
loadBalancer, _, err := client.LoadBalancer().GetByID(ctx, res.LoadBalancer.ID)
loadBalancer, _, err := client.LoadBalancer().GetByID(ctx, result.LoadBalancer.ID)
if err != nil {
return nil, nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/placementgroup/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ var CreateCmd = base.CreateCmd{
Type: hcloud.PlacementGroupType(placementGroupType),
}

res, _, err := client.PlacementGroup().Create(ctx, opts)
result, _, err := client.PlacementGroup().Create(ctx, opts)
if err != nil {
return nil, nil, err
}

if res.Action != nil {
if err := waiter.ActionProgress(ctx, res.Action); err != nil {
if result.Action != nil {
if err := waiter.ActionProgress(ctx, result.Action); err != nil {
return nil, nil, err
}
}

cmd.Printf("Placement group %d created\n", res.PlacementGroup.ID)
cmd.Printf("Placement group %d created\n", result.PlacementGroup.ID)

return res.PlacementGroup, util.Wrap("placement_group", hcloud.SchemaFromPlacementGroup(res.PlacementGroup)), nil
return result.PlacementGroup, util.Wrap("placement_group", hcloud.SchemaFromPlacementGroup(result.PlacementGroup)), nil
},
}
12 changes: 6 additions & 6 deletions internal/cmd/primaryip/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,26 @@ var CreateCmd = base.CreateCmd{
createOpts.AssigneeID = &assigneeID
}

res, _, err := client.PrimaryIP().Create(ctx, createOpts)
result, _, err := client.PrimaryIP().Create(ctx, createOpts)
if err != nil {
return nil, nil, err
}

if res.Action != nil {
if err := waiter.ActionProgress(ctx, res.Action); err != nil {
if result.Action != nil {
if err := waiter.ActionProgress(ctx, result.Action); err != nil {
return nil, nil, err
}
}

cmd.Printf("Primary IP %d created\n", res.PrimaryIP.ID)
cmd.Printf("Primary IP %d created\n", result.PrimaryIP.ID)

if len(protection) > 0 {
if err := changeProtection(ctx, client, waiter, cmd, res.PrimaryIP, true, protectionOpts); err != nil {
if err := changeProtection(ctx, client, waiter, cmd, result.PrimaryIP, true, protectionOpts); err != nil {
return nil, nil, err
}
}

return res.PrimaryIP, util.Wrap("primary_ip", hcloud.SchemaFromPrimaryIP(res.PrimaryIP)), nil
return result.PrimaryIP, util.Wrap("primary_ip", hcloud.SchemaFromPrimaryIP(result.PrimaryIP)), nil
},
PrintResource: func(_ context.Context, _ hcapi2.Client, cmd *cobra.Command, resource any) {
primaryIP := resource.(*hcloud.PrimaryIP)
Expand Down
12 changes: 6 additions & 6 deletions internal/cmd/volume/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,23 @@ var CreateCmd = base.CreateCmd{
createOpts.Format = &format
}

res, _, err := client.Volume().Create(ctx, createOpts)
result, _, err := client.Volume().Create(ctx, createOpts)
if err != nil {
return nil, nil, err
}

if err := waiter.ActionProgress(ctx, res.Action); err != nil {
if err := waiter.ActionProgress(ctx, result.Action); err != nil {
return nil, nil, err
}
if err := waiter.WaitForActions(ctx, res.NextActions); err != nil {
if err := waiter.WaitForActions(ctx, result.NextActions); err != nil {
return nil, nil, err
}
cmd.Printf("Volume %d created\n", res.Volume.ID)
cmd.Printf("Volume %d created\n", result.Volume.ID)

if err := changeProtection(ctx, client, waiter, cmd, res.Volume, true, protectionOpts); err != nil {
if err := changeProtection(ctx, client, waiter, cmd, result.Volume, true, protectionOpts); err != nil {
return nil, nil, err
}

return res.Volume, util.Wrap("volume", hcloud.SchemaFromVolume(res.Volume)), nil
return result.Volume, util.Wrap("volume", hcloud.SchemaFromVolume(result.Volume)), nil
},
}

0 comments on commit 178c671

Please sign in to comment.