From f636b5e56fc5f30736cb0a9054a1fcb8ab840859 Mon Sep 17 00:00:00 2001 From: pauhull Date: Tue, 2 Jan 2024 14:54:13 +0100 Subject: [PATCH] refactor: pass *cobra.Command into ActionWaiter (#655) --- internal/cmd/base/set_rdns.go | 2 +- internal/cmd/certificate/create.go | 2 +- internal/cmd/certificate/create_test.go | 4 ++-- internal/cmd/firewall/add_rule.go | 2 +- internal/cmd/firewall/add_rule_test.go | 2 +- internal/cmd/firewall/apply_to_resource.go | 2 +- internal/cmd/firewall/apply_to_resource_test.go | 4 ++-- internal/cmd/firewall/create.go | 2 +- internal/cmd/firewall/create_test.go | 4 ++-- internal/cmd/firewall/delete_rule.go | 2 +- internal/cmd/firewall/delete_rule_test.go | 2 +- internal/cmd/firewall/remove_from_resource.go | 2 +- .../cmd/firewall/remove_from_resource_test.go | 4 ++-- internal/cmd/firewall/replace_rules.go | 2 +- internal/cmd/firewall/replace_rules_test.go | 2 +- internal/cmd/floatingip/assign.go | 2 +- internal/cmd/floatingip/assign_test.go | 2 +- internal/cmd/floatingip/create.go | 2 +- internal/cmd/floatingip/create_test.go | 4 ++-- .../cmd/floatingip/disable_protection_test.go | 2 +- internal/cmd/floatingip/enable_protection.go | 2 +- .../cmd/floatingip/enable_protection_test.go | 2 +- internal/cmd/floatingip/set_rdns_test.go | 2 +- internal/cmd/floatingip/unassign.go | 2 +- internal/cmd/floatingip/unassign_test.go | 2 +- internal/cmd/image/disable_protection_test.go | 2 +- internal/cmd/image/enable_protection.go | 2 +- internal/cmd/image/enable_protection_test.go | 2 +- internal/cmd/loadbalancer/add_service.go | 2 +- internal/cmd/loadbalancer/add_service_test.go | 2 +- internal/cmd/loadbalancer/add_target.go | 2 +- internal/cmd/loadbalancer/add_target_test.go | 6 +++--- internal/cmd/loadbalancer/attach_to_network.go | 2 +- .../cmd/loadbalancer/attach_to_network_test.go | 2 +- internal/cmd/loadbalancer/change_algorithm.go | 2 +- .../cmd/loadbalancer/change_algorithm_test.go | 2 +- internal/cmd/loadbalancer/change_type.go | 2 +- internal/cmd/loadbalancer/change_type_test.go | 2 +- internal/cmd/loadbalancer/create.go | 2 +- internal/cmd/loadbalancer/create_test.go | 8 ++++---- internal/cmd/loadbalancer/detach_from_network.go | 2 +- .../cmd/loadbalancer/detach_from_network_test.go | 2 +- .../cmd/loadbalancer/disable_protection_test.go | 2 +- .../cmd/loadbalancer/disable_public_interface.go | 2 +- .../disable_public_interface_test.go | 2 +- internal/cmd/loadbalancer/enable_protection.go | 2 +- .../cmd/loadbalancer/enable_protection_test.go | 2 +- .../cmd/loadbalancer/enable_public_interface.go | 2 +- .../loadbalancer/enable_public_interface_test.go | 2 +- internal/cmd/loadbalancer/remove_target.go | 2 +- internal/cmd/loadbalancer/remove_target_test.go | 6 +++--- internal/cmd/loadbalancer/set_rdns_test.go | 2 +- internal/cmd/loadbalancer/update_service.go | 2 +- internal/cmd/loadbalancer/update_service_test.go | 2 +- internal/cmd/network/add_route.go | 2 +- internal/cmd/network/add_subnet.go | 2 +- internal/cmd/network/change_ip_range.go | 2 +- internal/cmd/network/create_test.go | 2 +- internal/cmd/network/enable_protection.go | 2 +- internal/cmd/network/remove_route.go | 2 +- internal/cmd/network/remove_subnet.go | 2 +- internal/cmd/placementgroup/create.go | 2 +- internal/cmd/placementgroup/create_test.go | 4 ++-- internal/cmd/primaryip/assign.go | 2 +- internal/cmd/primaryip/assign_test.go | 2 +- internal/cmd/primaryip/changedns.go | 2 +- internal/cmd/primaryip/changedns_test.go | 2 +- internal/cmd/primaryip/create.go | 2 +- internal/cmd/primaryip/create_test.go | 4 ++-- .../cmd/primaryip/disable_protection_test.go | 2 +- internal/cmd/primaryip/enable_protection.go | 2 +- internal/cmd/primaryip/enable_protection_test.go | 2 +- internal/cmd/primaryip/unassign.go | 2 +- internal/cmd/primaryip/unassign_test.go | 2 +- internal/cmd/server/add_to_placement_group.go | 2 +- .../cmd/server/add_to_placement_group_test.go | 2 +- internal/cmd/server/attach_iso.go | 2 +- internal/cmd/server/attach_to_network.go | 2 +- internal/cmd/server/change_alias_ips.go | 2 +- internal/cmd/server/change_type.go | 2 +- internal/cmd/server/create.go | 6 +++--- internal/cmd/server/create_image.go | 2 +- internal/cmd/server/create_test.go | 16 ++++++++-------- internal/cmd/server/delete.go | 2 +- internal/cmd/server/delete_test.go | 2 +- internal/cmd/server/detach_from_network.go | 2 +- internal/cmd/server/detach_iso.go | 2 +- internal/cmd/server/disable_backup.go | 2 +- internal/cmd/server/disable_rescue.go | 2 +- internal/cmd/server/enable_backup.go | 2 +- internal/cmd/server/enable_protection.go | 2 +- internal/cmd/server/enable_rescue.go | 2 +- internal/cmd/server/poweroff.go | 2 +- internal/cmd/server/poweron.go | 2 +- internal/cmd/server/reboot.go | 2 +- internal/cmd/server/rebuild.go | 2 +- .../cmd/server/remove_from_placement_group.go | 2 +- .../server/remove_from_placement_group_test.go | 2 +- internal/cmd/server/request_console.go | 2 +- internal/cmd/server/reset.go | 2 +- internal/cmd/server/reset_password.go | 2 +- internal/cmd/server/shutdown.go | 4 ++-- internal/cmd/server/shutdown_test.go | 4 ++-- internal/cmd/volume/attach.go | 2 +- internal/cmd/volume/create.go | 4 ++-- internal/cmd/volume/create_test.go | 14 +++++++------- internal/cmd/volume/detach.go | 2 +- internal/cmd/volume/enable_protection.go | 2 +- internal/cmd/volume/resize.go | 2 +- internal/state/command_helper_mocks.go | 16 ++++++++-------- internal/state/command_helpers.go | 4 ++-- internal/state/helpers.go | 12 ++++++------ 112 files changed, 157 insertions(+), 157 deletions(-) diff --git a/internal/cmd/base/set_rdns.go b/internal/cmd/base/set_rdns.go index 7648dbda..676d3fdb 100644 --- a/internal/cmd/base/set_rdns.go +++ b/internal/cmd/base/set_rdns.go @@ -77,7 +77,7 @@ func (rc *SetRdnsCmd) Run(ctx context.Context, client hcapi2.Client, cmd *cobra. return err } - if err := actionWaiter.ActionProgress(ctx, action); err != nil { + if err := actionWaiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/certificate/create.go b/internal/cmd/certificate/create.go index d2531f39..5e61f60f 100644 --- a/internal/cmd/certificate/create.go +++ b/internal/cmd/certificate/create.go @@ -131,7 +131,7 @@ func createManaged(ctx context.Context, client hcapi2.Client, waiter state.Actio if err != nil { return nil, err } - if err := waiter.ActionProgress(ctx, res.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, res.Action); err != nil { return nil, err } cmd.Printf("Certificate %d created\n", res.Certificate.ID) diff --git a/internal/cmd/certificate/create_test.go b/internal/cmd/certificate/create_test.go index d46435fe..1fc70903 100644 --- a/internal/cmd/certificate/create_test.go +++ b/internal/cmd/certificate/create_test.go @@ -46,7 +46,7 @@ func TestCreateManaged(t *testing.T) { Action: &hcloud.Action{ID: 321}, }, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) out, _, err := fx.Run(cmd, []string{"--name", "test", "--type", "managed", "--domain", "example.com"}) @@ -97,7 +97,7 @@ func TestCreateManagedJSON(t *testing.T) { Action: &hcloud.Action{ID: 321}, }, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) jsonOut, out, err := fx.Run(cmd, []string{"-o=json", "--name", "test", "--type", "managed", "--domain", "example.com"}) diff --git a/internal/cmd/firewall/add_rule.go b/internal/cmd/firewall/add_rule.go index 74e5a3fb..480f423a 100644 --- a/internal/cmd/firewall/add_rule.go +++ b/internal/cmd/firewall/add_rule.go @@ -113,7 +113,7 @@ var AddRuleCmd = base.Cmd{ if err != nil { return err } - if err := waiter.WaitForActions(ctx, actions); err != nil { + if err := waiter.WaitForActions(cmd, ctx, actions); err != nil { return err } diff --git a/internal/cmd/firewall/add_rule_test.go b/internal/cmd/firewall/add_rule_test.go index c7052daf..e22ed9b8 100644 --- a/internal/cmd/firewall/add_rule_test.go +++ b/internal/cmd/firewall/add_rule_test.go @@ -44,7 +44,7 @@ func TestAddRule(t *testing.T) { }). Return([]*hcloud.Action{{ID: 123}, {ID: 321}}, nil, nil) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). Return(nil) out, _, err := fx.Run(cmd, []string{"--direction", "in", "--protocol", "tcp", "--source-ips", "0.0.0.0/0", "--port", "80", "--description", "http", "test"}) diff --git a/internal/cmd/firewall/apply_to_resource.go b/internal/cmd/firewall/apply_to_resource.go index be76a82c..45c86da0 100644 --- a/internal/cmd/firewall/apply_to_resource.go +++ b/internal/cmd/firewall/apply_to_resource.go @@ -83,7 +83,7 @@ var ApplyToResourceCmd = base.Cmd{ if err != nil { return err } - if err := waiter.WaitForActions(ctx, actions); err != nil { + if err := waiter.WaitForActions(cmd, ctx, actions); err != nil { return err } cmd.Printf("Firewall %d applied\n", firewall.ID) diff --git a/internal/cmd/firewall/apply_to_resource_test.go b/internal/cmd/firewall/apply_to_resource_test.go index 7c805ba7..3302bf42 100644 --- a/internal/cmd/firewall/apply_to_resource_test.go +++ b/internal/cmd/firewall/apply_to_resource_test.go @@ -42,7 +42,7 @@ func TestApplyToServer(t *testing.T) { }}). Return([]*hcloud.Action{{ID: 123}, {ID: 321}}, nil, nil) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). Return(nil) out, _, err := fx.Run(cmd, []string{"--type", "server", "--server", "my-server", "test"}) @@ -81,7 +81,7 @@ func TestApplyToLabelSelector(t *testing.T) { }}). Return([]*hcloud.Action{{ID: 123}, {ID: 321}}, nil, nil) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). Return(nil) out, _, err := fx.Run(cmd, []string{"--type", "label_selector", "--label-selector", "my-label", "test"}) diff --git a/internal/cmd/firewall/create.go b/internal/cmd/firewall/create.go index d2a688ca..70c12965 100644 --- a/internal/cmd/firewall/create.go +++ b/internal/cmd/firewall/create.go @@ -84,7 +84,7 @@ var CreateCmd = base.CreateCmd{ return nil, nil, err } - if err := waiter.WaitForActions(ctx, result.Actions); err != nil { + if err := waiter.WaitForActions(cmd, ctx, result.Actions); err != nil { return nil, nil, err } diff --git a/internal/cmd/firewall/create_test.go b/internal/cmd/firewall/create_test.go index 1f4b847c..a5cf239a 100644 --- a/internal/cmd/firewall/create_test.go +++ b/internal/cmd/firewall/create_test.go @@ -41,7 +41,7 @@ func TestCreate(t *testing.T) { Actions: []*hcloud.Action{{ID: 321}}, }, nil, nil) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 321}}) + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 321}}) out, _, err := fx.Run(cmd, []string{"--name", "test"}) @@ -90,7 +90,7 @@ func TestCreateJSON(t *testing.T) { Actions: []*hcloud.Action{{ID: 321}}, }, nil, nil) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 321}}) + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 321}}) jsonOut, out, err := fx.Run(cmd, []string{"-o=json", "--name", "test"}) diff --git a/internal/cmd/firewall/delete_rule.go b/internal/cmd/firewall/delete_rule.go index 69afc079..78c2a369 100644 --- a/internal/cmd/firewall/delete_rule.go +++ b/internal/cmd/firewall/delete_rule.go @@ -121,7 +121,7 @@ var DeleteRuleCmd = base.Cmd{ if err != nil { return err } - if err := waiter.WaitForActions(ctx, actions); err != nil { + if err := waiter.WaitForActions(cmd, ctx, actions); err != nil { return err } cmd.Printf("Firewall Rules for Firewall %d updated\n", firewall.ID) diff --git a/internal/cmd/firewall/delete_rule_test.go b/internal/cmd/firewall/delete_rule_test.go index 40d646e4..9b818c7e 100644 --- a/internal/cmd/firewall/delete_rule_test.go +++ b/internal/cmd/firewall/delete_rule_test.go @@ -43,7 +43,7 @@ func TestDeleteRule(t *testing.T) { SetRules(gomock.Any(), firewall, hcloud.FirewallSetRulesOpts{Rules: nil}). Return([]*hcloud.Action{{ID: 123}, {ID: 321}}, nil, nil) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). Return(nil) out, _, err := fx.Run(cmd, []string{"--direction", "in", "--protocol", "tcp", "--source-ips", "0.0.0.0/0", "--port", "80", "--description", "http", "test"}) diff --git a/internal/cmd/firewall/remove_from_resource.go b/internal/cmd/firewall/remove_from_resource.go index c3c871e7..e3b0b2cd 100644 --- a/internal/cmd/firewall/remove_from_resource.go +++ b/internal/cmd/firewall/remove_from_resource.go @@ -82,7 +82,7 @@ var RemoveFromResourceCmd = base.Cmd{ if err != nil { return err } - if err := waiter.WaitForActions(ctx, actions); err != nil { + if err := waiter.WaitForActions(cmd, ctx, actions); err != nil { return err } cmd.Printf("Firewall %d applied\n", firewall.ID) diff --git a/internal/cmd/firewall/remove_from_resource_test.go b/internal/cmd/firewall/remove_from_resource_test.go index 31522bb9..d0932374 100644 --- a/internal/cmd/firewall/remove_from_resource_test.go +++ b/internal/cmd/firewall/remove_from_resource_test.go @@ -42,7 +42,7 @@ func TestRemoveFromServer(t *testing.T) { }}). Return([]*hcloud.Action{{ID: 123}, {ID: 321}}, nil, nil) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). Return(nil) out, _, err := fx.Run(cmd, []string{"--type", "server", "--server", "my-server", "test"}) @@ -81,7 +81,7 @@ func TestRemoveFromLabelSelector(t *testing.T) { }}). Return([]*hcloud.Action{{ID: 123}, {ID: 321}}, nil, nil) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). Return(nil) out, _, err := fx.Run(cmd, []string{"--type", "label_selector", "--label-selector", "my-label", "test"}) diff --git a/internal/cmd/firewall/replace_rules.go b/internal/cmd/firewall/replace_rules.go index bac157f0..3b23dbd7 100644 --- a/internal/cmd/firewall/replace_rules.go +++ b/internal/cmd/firewall/replace_rules.go @@ -95,7 +95,7 @@ var ReplaceRulesCmd = base.Cmd{ if err != nil { return err } - if err := waiter.WaitForActions(ctx, actions); err != nil { + if err := waiter.WaitForActions(cmd, ctx, actions); err != nil { return err } cmd.Printf("Firewall Rules for Firewall %d updated\n", firewall.ID) diff --git a/internal/cmd/firewall/replace_rules_test.go b/internal/cmd/firewall/replace_rules_test.go index 24105519..9637493f 100644 --- a/internal/cmd/firewall/replace_rules_test.go +++ b/internal/cmd/firewall/replace_rules_test.go @@ -67,7 +67,7 @@ func TestReplaceRules(t *testing.T) { }). Return([]*hcloud.Action{{ID: 123}, {ID: 321}}, nil, nil) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). Return(nil) out, _, err := fx.Run(cmd, []string{"--rules-file", "testdata/rules.json", "test"}) diff --git a/internal/cmd/floatingip/assign.go b/internal/cmd/floatingip/assign.go index 0830aea8..5b3fef37 100644 --- a/internal/cmd/floatingip/assign.go +++ b/internal/cmd/floatingip/assign.go @@ -50,7 +50,7 @@ var AssignCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/floatingip/assign_test.go b/internal/cmd/floatingip/assign_test.go index abfb8c9d..fda45555 100644 --- a/internal/cmd/floatingip/assign_test.go +++ b/internal/cmd/floatingip/assign_test.go @@ -32,7 +32,7 @@ func TestAssign(t *testing.T) { Assign(gomock.Any(), &hcloud.FloatingIP{ID: 123}, &hcloud.Server{ID: 456}). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"my-ip", "my-server"}) diff --git a/internal/cmd/floatingip/create.go b/internal/cmd/floatingip/create.go index 11da8302..b977479c 100644 --- a/internal/cmd/floatingip/create.go +++ b/internal/cmd/floatingip/create.go @@ -96,7 +96,7 @@ var CreateCmd = base.CreateCmd{ } if result.Action != nil { - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return nil, nil, err } } diff --git a/internal/cmd/floatingip/create_test.go b/internal/cmd/floatingip/create_test.go index 12670aa4..f17acd0f 100644 --- a/internal/cmd/floatingip/create_test.go +++ b/internal/cmd/floatingip/create_test.go @@ -127,14 +127,14 @@ func TestCreateProtection(t *testing.T) { ID: 321, }, }, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}).Return(nil) fx.Client.FloatingIPClient.EXPECT(). ChangeProtection(gomock.Any(), floatingIp, hcloud.FloatingIPChangeProtectionOpts{ Delete: hcloud.Ptr(true), }). Return(&hcloud.Action{ID: 333}, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 333}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 333}).Return(nil) out, _, err := fx.Run(cmd, []string{"--name", "myFloatingIP", "--type", "ipv4", "--home-location", "fsn1", "--enable-protection", "delete"}) diff --git a/internal/cmd/floatingip/disable_protection_test.go b/internal/cmd/floatingip/disable_protection_test.go index bff1037b..42579853 100644 --- a/internal/cmd/floatingip/disable_protection_test.go +++ b/internal/cmd/floatingip/disable_protection_test.go @@ -31,7 +31,7 @@ func TestDisableProtection(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"test", "delete"}) diff --git a/internal/cmd/floatingip/enable_protection.go b/internal/cmd/floatingip/enable_protection.go index 090b2e51..db259e1b 100644 --- a/internal/cmd/floatingip/enable_protection.go +++ b/internal/cmd/floatingip/enable_protection.go @@ -46,7 +46,7 @@ func changeProtection(ctx context.Context, client hcapi2.Client, waiter state.Ac return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/floatingip/enable_protection_test.go b/internal/cmd/floatingip/enable_protection_test.go index 80e6effb..6feef007 100644 --- a/internal/cmd/floatingip/enable_protection_test.go +++ b/internal/cmd/floatingip/enable_protection_test.go @@ -31,7 +31,7 @@ func TestEnableProtection(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"test", "delete"}) diff --git a/internal/cmd/floatingip/set_rdns_test.go b/internal/cmd/floatingip/set_rdns_test.go index d5b45ee7..10e76632 100644 --- a/internal/cmd/floatingip/set_rdns_test.go +++ b/internal/cmd/floatingip/set_rdns_test.go @@ -35,7 +35,7 @@ func TestSetRDNS(t *testing.T) { ChangeDNSPtr(gomock.Any(), floatingIP, floatingIP.IP, hcloud.Ptr("example.com")). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"--hostname", "example.com", "test"}) diff --git a/internal/cmd/floatingip/unassign.go b/internal/cmd/floatingip/unassign.go index 481fe3a3..cffc0816 100644 --- a/internal/cmd/floatingip/unassign.go +++ b/internal/cmd/floatingip/unassign.go @@ -38,7 +38,7 @@ var UnassignCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/floatingip/unassign_test.go b/internal/cmd/floatingip/unassign_test.go index de655f8e..feef4e78 100644 --- a/internal/cmd/floatingip/unassign_test.go +++ b/internal/cmd/floatingip/unassign_test.go @@ -29,7 +29,7 @@ func TestUnassign(t *testing.T) { Unassign(gomock.Any(), &hcloud.FloatingIP{ID: 123}). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"my-ip"}) diff --git a/internal/cmd/image/disable_protection_test.go b/internal/cmd/image/disable_protection_test.go index 8d2d905e..79a5e080 100644 --- a/internal/cmd/image/disable_protection_test.go +++ b/internal/cmd/image/disable_protection_test.go @@ -28,7 +28,7 @@ func TestDisableProtection(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "delete"}) diff --git a/internal/cmd/image/enable_protection.go b/internal/cmd/image/enable_protection.go index e1f5feaf..e0b77175 100644 --- a/internal/cmd/image/enable_protection.go +++ b/internal/cmd/image/enable_protection.go @@ -48,7 +48,7 @@ func changeProtection(ctx context.Context, client hcapi2.Client, waiter state.Ac return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/image/enable_protection_test.go b/internal/cmd/image/enable_protection_test.go index 7b0663f5..aae2e0cc 100644 --- a/internal/cmd/image/enable_protection_test.go +++ b/internal/cmd/image/enable_protection_test.go @@ -28,7 +28,7 @@ func TestEnableProtection(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "delete"}) diff --git a/internal/cmd/loadbalancer/add_service.go b/internal/cmd/loadbalancer/add_service.go index d0393d72..c73a2798 100644 --- a/internal/cmd/loadbalancer/add_service.go +++ b/internal/cmd/loadbalancer/add_service.go @@ -122,7 +122,7 @@ var AddServiceCmd = base.Cmd{ if err != nil { return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("Service was added to Load Balancer %d\n", loadBalancer.ID) diff --git a/internal/cmd/loadbalancer/add_service_test.go b/internal/cmd/loadbalancer/add_service_test.go index 799479da..8e1d4462 100644 --- a/internal/cmd/loadbalancer/add_service_test.go +++ b/internal/cmd/loadbalancer/add_service_test.go @@ -38,7 +38,7 @@ func TestAddService(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--protocol", "http", "--listen-port", "80", "--destination-port", "8080"}) diff --git a/internal/cmd/loadbalancer/add_target.go b/internal/cmd/loadbalancer/add_target.go index c49c1fb7..9f34a1a1 100644 --- a/internal/cmd/loadbalancer/add_target.go +++ b/internal/cmd/loadbalancer/add_target.go @@ -97,7 +97,7 @@ var AddTargetCmd = base.Cmd{ return fmt.Errorf("specify one of --server, --label-selector, or --ip") } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("Target added to Load Balancer %d\n", loadBalancer.ID) diff --git a/internal/cmd/loadbalancer/add_target_test.go b/internal/cmd/loadbalancer/add_target_test.go index 36a6a9f7..bdf4cd38 100644 --- a/internal/cmd/loadbalancer/add_target_test.go +++ b/internal/cmd/loadbalancer/add_target_test.go @@ -36,7 +36,7 @@ func TestAddTargetServer(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--server", "my-server"}) @@ -68,7 +68,7 @@ func TestAddTargetLabelSelector(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--label-selector", "my-label"}) @@ -99,7 +99,7 @@ func TestAddTargetIP(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--ip", "192.168.2.1"}) diff --git a/internal/cmd/loadbalancer/attach_to_network.go b/internal/cmd/loadbalancer/attach_to_network.go index 8f20364e..1471892b 100644 --- a/internal/cmd/loadbalancer/attach_to_network.go +++ b/internal/cmd/loadbalancer/attach_to_network.go @@ -63,7 +63,7 @@ var AttachToNetworkCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/loadbalancer/attach_to_network_test.go b/internal/cmd/loadbalancer/attach_to_network_test.go index bcd8506a..d776da3d 100644 --- a/internal/cmd/loadbalancer/attach_to_network_test.go +++ b/internal/cmd/loadbalancer/attach_to_network_test.go @@ -34,7 +34,7 @@ func TestAttachToNetwork(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--network", "my-network"}) diff --git a/internal/cmd/loadbalancer/change_algorithm.go b/internal/cmd/loadbalancer/change_algorithm.go index ecad1700..e1ef85df 100644 --- a/internal/cmd/loadbalancer/change_algorithm.go +++ b/internal/cmd/loadbalancer/change_algorithm.go @@ -48,7 +48,7 @@ var ChangeAlgorithmCmd = base.Cmd{ if err != nil { return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("Algorithm for Load Balancer %d was changed\n", loadBalancer.ID) diff --git a/internal/cmd/loadbalancer/change_algorithm_test.go b/internal/cmd/loadbalancer/change_algorithm_test.go index 2d8eb9fa..88813f7d 100644 --- a/internal/cmd/loadbalancer/change_algorithm_test.go +++ b/internal/cmd/loadbalancer/change_algorithm_test.go @@ -31,7 +31,7 @@ func TestChangeAlgorithm(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--algorithm-type", "least_connections"}) diff --git a/internal/cmd/loadbalancer/change_type.go b/internal/cmd/loadbalancer/change_type.go index b5cefb1d..3cc17bf8 100644 --- a/internal/cmd/loadbalancer/change_type.go +++ b/internal/cmd/loadbalancer/change_type.go @@ -54,7 +54,7 @@ var ChangeTypeCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/loadbalancer/change_type_test.go b/internal/cmd/loadbalancer/change_type_test.go index 426af526..65b94bde 100644 --- a/internal/cmd/loadbalancer/change_type_test.go +++ b/internal/cmd/loadbalancer/change_type_test.go @@ -36,7 +36,7 @@ func TestChangeType(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "lb21"}) diff --git a/internal/cmd/loadbalancer/create.go b/internal/cmd/loadbalancer/create.go index 7088fe69..086a08e4 100644 --- a/internal/cmd/loadbalancer/create.go +++ b/internal/cmd/loadbalancer/create.go @@ -83,7 +83,7 @@ var CreateCmd = base.CreateCmd{ return nil, nil, err } - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return nil, nil, err } loadBalancer, _, err := client.LoadBalancer().GetByID(ctx, result.LoadBalancer.ID) diff --git a/internal/cmd/loadbalancer/create_test.go b/internal/cmd/loadbalancer/create_test.go index de7ec009..4494088d 100644 --- a/internal/cmd/loadbalancer/create_test.go +++ b/internal/cmd/loadbalancer/create_test.go @@ -39,7 +39,7 @@ func TestCreate(t *testing.T) { LoadBalancer: &hcloud.LoadBalancer{ID: 123}, Action: &hcloud.Action{ID: 321}, }, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}).Return(nil) fx.Client.LoadBalancerClient.EXPECT(). GetByID(gomock.Any(), int64(123)). Return(&hcloud.LoadBalancer{ @@ -105,7 +105,7 @@ func TestCreateJSON(t *testing.T) { LoadBalancer: lb, Action: &hcloud.Action{ID: 321}, }, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}).Return(nil) fx.Client.LoadBalancerClient.EXPECT(). GetByID(gomock.Any(), int64(123)). Return(lb, nil, nil) @@ -153,7 +153,7 @@ func TestCreateProtection(t *testing.T) { LoadBalancer: &hcloud.LoadBalancer{ID: 123}, Action: &hcloud.Action{ID: 321}, }, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}).Return(nil) fx.Client.LoadBalancerClient.EXPECT(). GetByID(gomock.Any(), int64(123)). Return(loadBalancer, nil, nil) @@ -162,7 +162,7 @@ func TestCreateProtection(t *testing.T) { Delete: hcloud.Ptr(true), }). Return(&hcloud.Action{ID: 333}, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 333}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 333}).Return(nil) out, _, err := fx.Run(cmd, []string{"--name", "myLoadBalancer", "--type", "lb11", "--location", "fsn1", "--enable-protection", "delete"}) diff --git a/internal/cmd/loadbalancer/detach_from_network.go b/internal/cmd/loadbalancer/detach_from_network.go index 196a5ec4..2588dc25 100644 --- a/internal/cmd/loadbalancer/detach_from_network.go +++ b/internal/cmd/loadbalancer/detach_from_network.go @@ -54,7 +54,7 @@ var DetachFromNetworkCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/loadbalancer/detach_from_network_test.go b/internal/cmd/loadbalancer/detach_from_network_test.go index a482f47d..07f5f173 100644 --- a/internal/cmd/loadbalancer/detach_from_network_test.go +++ b/internal/cmd/loadbalancer/detach_from_network_test.go @@ -34,7 +34,7 @@ func TestDetachFromNetwork(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--network", "my-network"}) diff --git a/internal/cmd/loadbalancer/disable_protection_test.go b/internal/cmd/loadbalancer/disable_protection_test.go index a24769cc..4a7598f9 100644 --- a/internal/cmd/loadbalancer/disable_protection_test.go +++ b/internal/cmd/loadbalancer/disable_protection_test.go @@ -31,7 +31,7 @@ func TestDisableProtection(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "delete"}) diff --git a/internal/cmd/loadbalancer/disable_public_interface.go b/internal/cmd/loadbalancer/disable_public_interface.go index 399969fd..bbdb2402 100644 --- a/internal/cmd/loadbalancer/disable_public_interface.go +++ b/internal/cmd/loadbalancer/disable_public_interface.go @@ -38,7 +38,7 @@ var DisablePublicInterfaceCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/loadbalancer/disable_public_interface_test.go b/internal/cmd/loadbalancer/disable_public_interface_test.go index c6b590b2..4d854a47 100644 --- a/internal/cmd/loadbalancer/disable_public_interface_test.go +++ b/internal/cmd/loadbalancer/disable_public_interface_test.go @@ -29,7 +29,7 @@ func TestDisablePublicInterface(t *testing.T) { DisablePublicInterface(gomock.Any(), &hcloud.LoadBalancer{ID: 123}). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123"}) diff --git a/internal/cmd/loadbalancer/enable_protection.go b/internal/cmd/loadbalancer/enable_protection.go index 361dee0d..1fcb1c79 100644 --- a/internal/cmd/loadbalancer/enable_protection.go +++ b/internal/cmd/loadbalancer/enable_protection.go @@ -46,7 +46,7 @@ func changeProtection(ctx context.Context, client hcapi2.Client, waiter state.Ac return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/loadbalancer/enable_protection_test.go b/internal/cmd/loadbalancer/enable_protection_test.go index f894cb98..9ad85f85 100644 --- a/internal/cmd/loadbalancer/enable_protection_test.go +++ b/internal/cmd/loadbalancer/enable_protection_test.go @@ -31,7 +31,7 @@ func TestEnableProtection(t *testing.T) { }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "delete"}) diff --git a/internal/cmd/loadbalancer/enable_public_interface.go b/internal/cmd/loadbalancer/enable_public_interface.go index 7f70529e..714eb049 100644 --- a/internal/cmd/loadbalancer/enable_public_interface.go +++ b/internal/cmd/loadbalancer/enable_public_interface.go @@ -38,7 +38,7 @@ var EnablePublicInterfaceCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/loadbalancer/enable_public_interface_test.go b/internal/cmd/loadbalancer/enable_public_interface_test.go index 65bff975..071cc4b7 100644 --- a/internal/cmd/loadbalancer/enable_public_interface_test.go +++ b/internal/cmd/loadbalancer/enable_public_interface_test.go @@ -29,7 +29,7 @@ func TestEnablePublicInterface(t *testing.T) { EnablePublicInterface(gomock.Any(), &hcloud.LoadBalancer{ID: 123}). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123"}) diff --git a/internal/cmd/loadbalancer/remove_target.go b/internal/cmd/loadbalancer/remove_target.go index ce4580a2..8bf29182 100644 --- a/internal/cmd/loadbalancer/remove_target.go +++ b/internal/cmd/loadbalancer/remove_target.go @@ -89,7 +89,7 @@ var RemoveTargetCmd = base.Cmd{ return fmt.Errorf("specify one of --server, --label-selector, or --ip") } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("Target removed from Load Balancer %d\n", loadBalancer.ID) diff --git a/internal/cmd/loadbalancer/remove_target_test.go b/internal/cmd/loadbalancer/remove_target_test.go index 3d7f2a3e..932655e4 100644 --- a/internal/cmd/loadbalancer/remove_target_test.go +++ b/internal/cmd/loadbalancer/remove_target_test.go @@ -33,7 +33,7 @@ func TestRemoveTargetServer(t *testing.T) { RemoveServerTarget(gomock.Any(), &hcloud.LoadBalancer{ID: 123}, &hcloud.Server{ID: 321}). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--server", "my-server"}) @@ -62,7 +62,7 @@ func TestRemoveTargetLabelSelector(t *testing.T) { RemoveLabelSelectorTarget(gomock.Any(), &hcloud.LoadBalancer{ID: 123}, "my-label"). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--label-selector", "my-label"}) @@ -91,7 +91,7 @@ func TestRemoveTargetIP(t *testing.T) { RemoveIPTarget(gomock.Any(), &hcloud.LoadBalancer{ID: 123}, net.ParseIP("192.168.2.1")). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"123", "--ip", "192.168.2.1"}) diff --git a/internal/cmd/loadbalancer/set_rdns_test.go b/internal/cmd/loadbalancer/set_rdns_test.go index 625d47d2..ffece31a 100644 --- a/internal/cmd/loadbalancer/set_rdns_test.go +++ b/internal/cmd/loadbalancer/set_rdns_test.go @@ -39,7 +39,7 @@ func TestSetRDNS(t *testing.T) { ChangeDNSPtr(gomock.Any(), loadBalancer, loadBalancer.PublicNet.IPv4.IP, hcloud.Ptr("example.com")). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}). Return(nil) out, _, err := fx.Run(cmd, []string{"--hostname", "example.com", "test"}) diff --git a/internal/cmd/loadbalancer/update_service.go b/internal/cmd/loadbalancer/update_service.go index 699d1c07..63b94615 100644 --- a/internal/cmd/loadbalancer/update_service.go +++ b/internal/cmd/loadbalancer/update_service.go @@ -164,7 +164,7 @@ var UpdateServiceCmd = base.Cmd{ if err != nil { return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("Service %d on Load Balancer %d was updated\n", listenPort, loadBalancer.ID) diff --git a/internal/cmd/loadbalancer/update_service_test.go b/internal/cmd/loadbalancer/update_service_test.go index 83786dab..2f90cb8e 100644 --- a/internal/cmd/loadbalancer/update_service_test.go +++ b/internal/cmd/loadbalancer/update_service_test.go @@ -55,7 +55,7 @@ func TestUpdateService(t *testing.T) { }). Return(&hcloud.Action{ID: 321}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}). + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}). Return(nil) out, _, err := fx.Run(cmd, []string{ diff --git a/internal/cmd/network/add_route.go b/internal/cmd/network/add_route.go index 66bd49d1..5a02e056 100644 --- a/internal/cmd/network/add_route.go +++ b/internal/cmd/network/add_route.go @@ -56,7 +56,7 @@ var AddRouteCmd = base.Cmd{ if err != nil { return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("Route added to network %d\n", network.ID) diff --git a/internal/cmd/network/add_subnet.go b/internal/cmd/network/add_subnet.go index 8a7f91d2..35c475fa 100644 --- a/internal/cmd/network/add_subnet.go +++ b/internal/cmd/network/add_subnet.go @@ -71,7 +71,7 @@ var AddSubnetCmd = base.Cmd{ if err != nil { return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("Subnet added to network %d\n", network.ID) diff --git a/internal/cmd/network/change_ip_range.go b/internal/cmd/network/change_ip_range.go index 9c212b2e..ab5c9309 100644 --- a/internal/cmd/network/change_ip_range.go +++ b/internal/cmd/network/change_ip_range.go @@ -50,7 +50,7 @@ var ChangeIPRangeCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("IP range of network %d changed\n", network.ID) diff --git a/internal/cmd/network/create_test.go b/internal/cmd/network/create_test.go index d3593ee0..014a8268 100644 --- a/internal/cmd/network/create_test.go +++ b/internal/cmd/network/create_test.go @@ -119,7 +119,7 @@ func TestCreateProtection(t *testing.T) { Delete: hcloud.Ptr(true), }). Return(&hcloud.Action{ID: 123}, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}).Return(nil) out, _, err := fx.Run(cmd, []string{"--name", "myNetwork", "--ip-range", "10.0.0.0/24", "--enable-protection", "delete"}) diff --git a/internal/cmd/network/enable_protection.go b/internal/cmd/network/enable_protection.go index 02aee347..4bb35af2 100644 --- a/internal/cmd/network/enable_protection.go +++ b/internal/cmd/network/enable_protection.go @@ -46,7 +46,7 @@ func changeProtection(ctx context.Context, client hcapi2.Client, waiter state.Ac return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/network/remove_route.go b/internal/cmd/network/remove_route.go index d7186513..0fc2b61a 100644 --- a/internal/cmd/network/remove_route.go +++ b/internal/cmd/network/remove_route.go @@ -55,7 +55,7 @@ var RemoveRouteCmd = base.Cmd{ if err != nil { return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("Route removed from network %d\n", network.ID) diff --git a/internal/cmd/network/remove_subnet.go b/internal/cmd/network/remove_subnet.go index 323243f9..4548b3f2 100644 --- a/internal/cmd/network/remove_subnet.go +++ b/internal/cmd/network/remove_subnet.go @@ -48,7 +48,7 @@ var RemoveSubnetCmd = base.Cmd{ if err != nil { return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } cmd.Printf("Subnet %s removed from network %d\n", ipRange.String(), network.ID) diff --git a/internal/cmd/placementgroup/create.go b/internal/cmd/placementgroup/create.go index 1561613a..2acf753f 100644 --- a/internal/cmd/placementgroup/create.go +++ b/internal/cmd/placementgroup/create.go @@ -44,7 +44,7 @@ var CreateCmd = base.CreateCmd{ } if result.Action != nil { - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return nil, nil, err } } diff --git a/internal/cmd/placementgroup/create_test.go b/internal/cmd/placementgroup/create_test.go index bad49154..df210415 100644 --- a/internal/cmd/placementgroup/create_test.go +++ b/internal/cmd/placementgroup/create_test.go @@ -47,7 +47,7 @@ func TestCreate(t *testing.T) { Return(hcloud.PlacementGroupCreateResult{PlacementGroup: &placementGroup, Action: &hcloud.Action{ID: 321}}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) out, _, err := fx.Run(cmd, []string{"--name", placementGroup.Name, "--type", string(placementGroup.Type)}) @@ -92,7 +92,7 @@ func TestCreateJSON(t *testing.T) { }, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) jsonOut, out, err := fx.Run(cmd, []string{"-o=json", "--name", "myPlacementGroup", "--type", "spread"}) diff --git a/internal/cmd/primaryip/assign.go b/internal/cmd/primaryip/assign.go index 46476147..e9816732 100644 --- a/internal/cmd/primaryip/assign.go +++ b/internal/cmd/primaryip/assign.go @@ -60,7 +60,7 @@ var AssignCmd = base.Cmd{ return err } - if err := actionWaiter.ActionProgress(ctx, action); err != nil { + if err := actionWaiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/primaryip/assign_test.go b/internal/cmd/primaryip/assign_test.go index be1f2977..acc8b649 100644 --- a/internal/cmd/primaryip/assign_test.go +++ b/internal/cmd/primaryip/assign_test.go @@ -54,7 +54,7 @@ func TestAssign(t *testing.T) { nil, ) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), action).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), action).Return(nil) out, _, err := fx.Run(cmd, []string{"13", "--server", "15"}) diff --git a/internal/cmd/primaryip/changedns.go b/internal/cmd/primaryip/changedns.go index b38de8d0..5b744ad8 100644 --- a/internal/cmd/primaryip/changedns.go +++ b/internal/cmd/primaryip/changedns.go @@ -54,7 +54,7 @@ var ChangeDNSCmd = base.Cmd{ return err } - if err := actionWaiter.ActionProgress(ctx, action); err != nil { + if err := actionWaiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/primaryip/changedns_test.go b/internal/cmd/primaryip/changedns_test.go index 2c673309..a2099d27 100644 --- a/internal/cmd/primaryip/changedns_test.go +++ b/internal/cmd/primaryip/changedns_test.go @@ -43,7 +43,7 @@ func TestChangeDNS(t *testing.T) { nil, ) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), action).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), action).Return(nil) out, _, err := fx.Run(cmd, []string{"--hostname=server.your-host.de", "--ip=192.168.0.1", "13"}) diff --git a/internal/cmd/primaryip/create.go b/internal/cmd/primaryip/create.go index a482c663..61a789ce 100644 --- a/internal/cmd/primaryip/create.go +++ b/internal/cmd/primaryip/create.go @@ -69,7 +69,7 @@ var CreateCmd = base.CreateCmd{ } if result.Action != nil { - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return nil, nil, err } } diff --git a/internal/cmd/primaryip/create_test.go b/internal/cmd/primaryip/create_test.go index 231adf4c..505cd6b8 100644 --- a/internal/cmd/primaryip/create_test.go +++ b/internal/cmd/primaryip/create_test.go @@ -47,7 +47,7 @@ func TestCreate(t *testing.T) { ) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) out, _, err := fx.Run(cmd, []string{"--name=my-ip", "--type=ipv4", "--datacenter=fsn1-dc14"}) @@ -105,7 +105,7 @@ func TestCreateJSON(t *testing.T) { }, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) jsonOut, out, err := fx.Run(cmd, []string{"-o=json", "--name=my-ip", "--type=ipv4", "--datacenter=fsn1-dc14"}) diff --git a/internal/cmd/primaryip/disable_protection_test.go b/internal/cmd/primaryip/disable_protection_test.go index 8d65e08c..adc03f30 100644 --- a/internal/cmd/primaryip/disable_protection_test.go +++ b/internal/cmd/primaryip/disable_protection_test.go @@ -43,7 +43,7 @@ func TestEnable(t *testing.T) { nil, ) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), action).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), action).Return(nil) out, _, err := fx.Run(cmd, []string{"13"}) expOut := "Resource protection disabled for primary IP 13\n" diff --git a/internal/cmd/primaryip/enable_protection.go b/internal/cmd/primaryip/enable_protection.go index d376ce6d..0c108de6 100644 --- a/internal/cmd/primaryip/enable_protection.go +++ b/internal/cmd/primaryip/enable_protection.go @@ -44,7 +44,7 @@ func changeProtection(ctx context.Context, client hcapi2.Client, waiter state.Ac return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/primaryip/enable_protection_test.go b/internal/cmd/primaryip/enable_protection_test.go index 3138d4d2..bd6df783 100644 --- a/internal/cmd/primaryip/enable_protection_test.go +++ b/internal/cmd/primaryip/enable_protection_test.go @@ -43,7 +43,7 @@ func TestEnableProtection(t *testing.T) { nil, ) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), action).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), action).Return(nil) out, _, err := fx.Run(cmd, []string{"13"}) expOut := "Resource protection enabled for primary IP 13\n" diff --git a/internal/cmd/primaryip/unassign.go b/internal/cmd/primaryip/unassign.go index be8e3fc7..6c1260f9 100644 --- a/internal/cmd/primaryip/unassign.go +++ b/internal/cmd/primaryip/unassign.go @@ -41,7 +41,7 @@ var UnAssignCmd = base.Cmd{ return err } - if err := actionWaiter.ActionProgress(ctx, action); err != nil { + if err := actionWaiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/primaryip/unassign_test.go b/internal/cmd/primaryip/unassign_test.go index 945524fb..776ae500 100644 --- a/internal/cmd/primaryip/unassign_test.go +++ b/internal/cmd/primaryip/unassign_test.go @@ -39,7 +39,7 @@ func TestUnAssign(t *testing.T) { nil, ) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), action).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), action).Return(nil) out, _, err := fx.Run(cmd, []string{"13"}) diff --git a/internal/cmd/server/add_to_placement_group.go b/internal/cmd/server/add_to_placement_group.go index 18dbd9f2..4701e486 100644 --- a/internal/cmd/server/add_to_placement_group.go +++ b/internal/cmd/server/add_to_placement_group.go @@ -51,7 +51,7 @@ var AddToPlacementGroupCmd = base.Cmd{ return err } - if err := actionWaiter.ActionProgress(ctx, action); err != nil { + if err := actionWaiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/add_to_placement_group_test.go b/internal/cmd/server/add_to_placement_group_test.go index a1e2a443..62073307 100644 --- a/internal/cmd/server/add_to_placement_group_test.go +++ b/internal/cmd/server/add_to_placement_group_test.go @@ -42,7 +42,7 @@ func TestAddToPlacementGroup(t *testing.T) { Return(&placementGroup, nil, nil) fx.Client.ServerClient.EXPECT(). AddToPlacementGroup(gomock.Any(), &server, &placementGroup) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), nil) out, _, err := fx.Run(cmd, []string{"-g", placementGroup.Name, server.Name}) diff --git a/internal/cmd/server/attach_iso.go b/internal/cmd/server/attach_iso.go index a26ea338..2d757b97 100644 --- a/internal/cmd/server/attach_iso.go +++ b/internal/cmd/server/attach_iso.go @@ -57,7 +57,7 @@ var AttachISOCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/attach_to_network.go b/internal/cmd/server/attach_to_network.go index 5619d7eb..4135f651 100644 --- a/internal/cmd/server/attach_to_network.go +++ b/internal/cmd/server/attach_to_network.go @@ -69,7 +69,7 @@ var AttachToNetworkCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/change_alias_ips.go b/internal/cmd/server/change_alias_ips.go index 6562368d..19bc6646 100644 --- a/internal/cmd/server/change_alias_ips.go +++ b/internal/cmd/server/change_alias_ips.go @@ -72,7 +72,7 @@ var ChangeAliasIPsCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/change_type.go b/internal/cmd/server/change_type.go index 66a6b33a..d36ccdf9 100644 --- a/internal/cmd/server/change_type.go +++ b/internal/cmd/server/change_type.go @@ -63,7 +63,7 @@ var ChangeTypeCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/create.go b/internal/cmd/server/create.go index bbb90937..46ddc0fe 100644 --- a/internal/cmd/server/create.go +++ b/internal/cmd/server/create.go @@ -108,10 +108,10 @@ var CreateCmd = base.CreateCmd{ return nil, nil, err } - if err := actionWaiter.ActionProgress(ctx, result.Action); err != nil { + if err := actionWaiter.ActionProgress(cmd, ctx, result.Action); err != nil { return nil, nil, err } - if err := actionWaiter.WaitForActions(ctx, result.NextActions); err != nil { + if err := actionWaiter.WaitForActions(cmd, ctx, result.NextActions); err != nil { return nil, nil, err } @@ -133,7 +133,7 @@ var CreateCmd = base.CreateCmd{ return nil, nil, err } - if err := actionWaiter.ActionProgress(ctx, action); err != nil { + if err := actionWaiter.ActionProgress(cmd, ctx, action); err != nil { return nil, nil, err } diff --git a/internal/cmd/server/create_image.go b/internal/cmd/server/create_image.go index be966555..75348384 100644 --- a/internal/cmd/server/create_image.go +++ b/internal/cmd/server/create_image.go @@ -61,7 +61,7 @@ var CreateImageCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return err } diff --git a/internal/cmd/server/create_test.go b/internal/cmd/server/create_test.go index cc350104..90d4eb9e 100644 --- a/internal/cmd/server/create_test.go +++ b/internal/cmd/server/create_test.go @@ -64,8 +64,8 @@ func TestCreate(t *testing.T) { }, }, }, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}).Return(nil) - fx.ActionWaiter.EXPECT().WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 234}}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}).Return(nil) + fx.ActionWaiter.EXPECT().WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 234}}).Return(nil) args := []string{"--name", "cli-test", "--type", "cx11", "--image", "ubuntu-20.04"} out, _, err := fx.Run(cmd, args) @@ -164,8 +164,8 @@ func TestCreateJSON(t *testing.T) { fx.Client.ServerClient.EXPECT(). GetByID(gomock.Any(), int64(1234)). Return(srv, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}).Return(nil) - fx.ActionWaiter.EXPECT().WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 234}}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}).Return(nil) + fx.ActionWaiter.EXPECT().WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 234}}).Return(nil) args := []string{"-o=json", "--name", "cli-test", "--type", "cx11", "--image", "ubuntu-20.04"} jsonOut, out, err := fx.Run(cmd, args) @@ -231,8 +231,8 @@ func TestCreateProtectionBackup(t *testing.T) { fx.Client.ServerClient.EXPECT(). GetByID(gomock.Any(), int64(1234)). Return(srv, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}).Return(nil) - fx.ActionWaiter.EXPECT().WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 234}}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}).Return(nil) + fx.ActionWaiter.EXPECT().WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 234}}).Return(nil) fx.Client.ServerClient.EXPECT(). ChangeProtection(gomock.Any(), srv, hcloud.ServerChangeProtectionOpts{ @@ -241,14 +241,14 @@ func TestCreateProtectionBackup(t *testing.T) { Return(&hcloud.Action{ ID: 1337, }, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 1337}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 1337}).Return(nil) fx.Client.ServerClient.EXPECT(). EnableBackup(gomock.Any(), srv, ""). Return(&hcloud.Action{ ID: 42, }, nil, nil) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), &hcloud.Action{ID: 42}).Return(nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 42}).Return(nil) args := []string{"--name", "cli-test", "--type", "cx11", "--image", "ubuntu-20.04", "--enable-protection", "rebuild,delete", "--enable-backup"} out, _, err := fx.Run(cmd, args) diff --git a/internal/cmd/server/delete.go b/internal/cmd/server/delete.go index dbd241b8..a1009d47 100644 --- a/internal/cmd/server/delete.go +++ b/internal/cmd/server/delete.go @@ -25,7 +25,7 @@ var DeleteCmd = base.DeleteCmd{ return err } - if err := actionWaiter.ActionProgress(ctx, result.Action); err != nil { + if err := actionWaiter.ActionProgress(cmd, ctx, result.Action); err != nil { return err } diff --git a/internal/cmd/server/delete_test.go b/internal/cmd/server/delete_test.go index 45bbefe5..0ad138a1 100644 --- a/internal/cmd/server/delete_test.go +++ b/internal/cmd/server/delete_test.go @@ -36,7 +36,7 @@ func TestDelete(t *testing.T) { Action: &hcloud.Action{ID: 321}, }, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) out, _, err := fx.Run(cmd, []string{"test"}) diff --git a/internal/cmd/server/detach_from_network.go b/internal/cmd/server/detach_from_network.go index 22515e8c..b2cb4a58 100644 --- a/internal/cmd/server/detach_from_network.go +++ b/internal/cmd/server/detach_from_network.go @@ -55,7 +55,7 @@ var DetachFromNetworkCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/detach_iso.go b/internal/cmd/server/detach_iso.go index 31dbe62e..c16d07b3 100644 --- a/internal/cmd/server/detach_iso.go +++ b/internal/cmd/server/detach_iso.go @@ -38,7 +38,7 @@ var DetachISOCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/disable_backup.go b/internal/cmd/server/disable_backup.go index 4ebd1f84..20e6c435 100644 --- a/internal/cmd/server/disable_backup.go +++ b/internal/cmd/server/disable_backup.go @@ -38,7 +38,7 @@ var DisableBackupCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/disable_rescue.go b/internal/cmd/server/disable_rescue.go index 4d6d26b5..a3c7284a 100644 --- a/internal/cmd/server/disable_rescue.go +++ b/internal/cmd/server/disable_rescue.go @@ -38,7 +38,7 @@ var DisableRescueCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/enable_backup.go b/internal/cmd/server/enable_backup.go index 2fc7d625..591a12f6 100644 --- a/internal/cmd/server/enable_backup.go +++ b/internal/cmd/server/enable_backup.go @@ -47,7 +47,7 @@ var EnableBackupCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/enable_protection.go b/internal/cmd/server/enable_protection.go index 6fae9092..167ec95b 100644 --- a/internal/cmd/server/enable_protection.go +++ b/internal/cmd/server/enable_protection.go @@ -48,7 +48,7 @@ func changeProtection(ctx context.Context, client hcapi2.Client, waiter state.Ac return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/enable_rescue.go b/internal/cmd/server/enable_rescue.go index 97763715..d9eed635 100644 --- a/internal/cmd/server/enable_rescue.go +++ b/internal/cmd/server/enable_rescue.go @@ -63,7 +63,7 @@ var EnableRescueCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return err } diff --git a/internal/cmd/server/poweroff.go b/internal/cmd/server/poweroff.go index 3c2d0c90..b8f40966 100644 --- a/internal/cmd/server/poweroff.go +++ b/internal/cmd/server/poweroff.go @@ -38,7 +38,7 @@ var PoweroffCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/poweron.go b/internal/cmd/server/poweron.go index 5aa1f14b..9f37a8a7 100644 --- a/internal/cmd/server/poweron.go +++ b/internal/cmd/server/poweron.go @@ -38,7 +38,7 @@ var PoweronCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/reboot.go b/internal/cmd/server/reboot.go index 2b878d8e..9ffe7165 100644 --- a/internal/cmd/server/reboot.go +++ b/internal/cmd/server/reboot.go @@ -38,7 +38,7 @@ var RebootCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/rebuild.go b/internal/cmd/server/rebuild.go index 2cd25245..c32ebd96 100644 --- a/internal/cmd/server/rebuild.go +++ b/internal/cmd/server/rebuild.go @@ -70,7 +70,7 @@ var RebuildCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return err } diff --git a/internal/cmd/server/remove_from_placement_group.go b/internal/cmd/server/remove_from_placement_group.go index 38078407..c269c779 100644 --- a/internal/cmd/server/remove_from_placement_group.go +++ b/internal/cmd/server/remove_from_placement_group.go @@ -39,7 +39,7 @@ var RemoveFromPlacementGroupCmd = base.Cmd{ return err } - if err := actionWaiter.ActionProgress(ctx, action); err != nil { + if err := actionWaiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/remove_from_placement_group_test.go b/internal/cmd/server/remove_from_placement_group_test.go index 3f38694b..6ed86162 100644 --- a/internal/cmd/server/remove_from_placement_group_test.go +++ b/internal/cmd/server/remove_from_placement_group_test.go @@ -33,7 +33,7 @@ func TestRemoveFromPlacementGroup(t *testing.T) { Return(&server, nil, nil) fx.Client.ServerClient.EXPECT(). RemoveFromPlacementGroup(gomock.Any(), &server) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), nil) out, _, err := fx.Run(cmd, []string{server.Name}) diff --git a/internal/cmd/server/request_console.go b/internal/cmd/server/request_console.go index feff1ee8..09972928 100644 --- a/internal/cmd/server/request_console.go +++ b/internal/cmd/server/request_console.go @@ -43,7 +43,7 @@ var RequestConsoleCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return err } diff --git a/internal/cmd/server/reset.go b/internal/cmd/server/reset.go index aea5d010..4d7291b2 100644 --- a/internal/cmd/server/reset.go +++ b/internal/cmd/server/reset.go @@ -38,7 +38,7 @@ var ResetCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/server/reset_password.go b/internal/cmd/server/reset_password.go index 51aab721..2bf5077e 100644 --- a/internal/cmd/server/reset_password.go +++ b/internal/cmd/server/reset_password.go @@ -38,7 +38,7 @@ var ResetPasswordCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return err } diff --git a/internal/cmd/server/shutdown.go b/internal/cmd/server/shutdown.go index eb478002..d43e5304 100644 --- a/internal/cmd/server/shutdown.go +++ b/internal/cmd/server/shutdown.go @@ -57,7 +57,7 @@ var ShutdownCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } @@ -93,7 +93,7 @@ var ShutdownCmd = base.Cmd{ errCh <- nil }() - if err := state.DisplayProgressCircle(errCh, "Waiting for server to shut down"); err != nil { + if err := state.DisplayProgressCircle(cmd, errCh, "Waiting for server to shut down"); err != nil { return err } diff --git a/internal/cmd/server/shutdown_test.go b/internal/cmd/server/shutdown_test.go index 54db2fd4..6004f1f8 100644 --- a/internal/cmd/server/shutdown_test.go +++ b/internal/cmd/server/shutdown_test.go @@ -37,7 +37,7 @@ func TestShutdown(t *testing.T) { fx.Client.ServerClient.EXPECT(). Shutdown(gomock.Any(), &server) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), nil) out, _, err := fx.Run(cmd, []string{server.Name}) @@ -73,7 +73,7 @@ func TestShutdownWait(t *testing.T) { fx.Client.ServerClient.EXPECT(). Shutdown(gomock.Any(), &server) - fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), nil) + fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), nil) fx.Client.ServerClient.EXPECT(). GetByID(gomock.Any(), server.ID). diff --git a/internal/cmd/volume/attach.go b/internal/cmd/volume/attach.go index 9b1dbb88..3c3aac85 100644 --- a/internal/cmd/volume/attach.go +++ b/internal/cmd/volume/attach.go @@ -57,7 +57,7 @@ var AttachCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/volume/create.go b/internal/cmd/volume/create.go index e81d75ba..c3ce85d5 100644 --- a/internal/cmd/volume/create.go +++ b/internal/cmd/volume/create.go @@ -99,10 +99,10 @@ var CreateCmd = base.CreateCmd{ return nil, nil, err } - if err := waiter.ActionProgress(ctx, result.Action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, result.Action); err != nil { return nil, nil, err } - if err := waiter.WaitForActions(ctx, result.NextActions); err != nil { + if err := waiter.WaitForActions(cmd, ctx, result.NextActions); err != nil { return nil, nil, err } cmd.Printf("Volume %d created\n", result.Volume.ID) diff --git a/internal/cmd/volume/create_test.go b/internal/cmd/volume/create_test.go index dad6368e..66edbca7 100644 --- a/internal/cmd/volume/create_test.go +++ b/internal/cmd/volume/create_test.go @@ -45,9 +45,9 @@ func TestCreate(t *testing.T) { NextActions: []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}, }, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}) + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}) out, _, err := fx.Run(cmd, []string{"--name", "test", "--size", "20", "--location", "fsn1"}) @@ -95,9 +95,9 @@ func TestCreateJSON(t *testing.T) { NextActions: []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}, }, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}) + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}) jsonOut, out, err := fx.Run(cmd, []string{"-o=json", "--name", "test", "--size", "20", "--location", "fsn1"}) @@ -139,16 +139,16 @@ func TestCreateProtection(t *testing.T) { NextActions: []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}, }, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 321}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 321}) fx.ActionWaiter.EXPECT(). - WaitForActions(gomock.Any(), []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}) + WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}) fx.Client.VolumeClient.EXPECT(). ChangeProtection(gomock.Any(), volume, hcloud.VolumeChangeProtectionOpts{ Delete: hcloud.Ptr(true), }). Return(&hcloud.Action{ID: 123}, nil, nil) fx.ActionWaiter.EXPECT(). - ActionProgress(gomock.Any(), &hcloud.Action{ID: 123}) + ActionProgress(gomock.Any(), gomock.Any(), &hcloud.Action{ID: 123}) out, _, err := fx.Run(cmd, []string{"--name", "test", "--size", "20", "--location", "fsn1", "--enable-protection", "delete"}) diff --git a/internal/cmd/volume/detach.go b/internal/cmd/volume/detach.go index acd2a6b9..38e4c591 100644 --- a/internal/cmd/volume/detach.go +++ b/internal/cmd/volume/detach.go @@ -37,7 +37,7 @@ var DetachCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/volume/enable_protection.go b/internal/cmd/volume/enable_protection.go index 5a525456..efc5ffe3 100644 --- a/internal/cmd/volume/enable_protection.go +++ b/internal/cmd/volume/enable_protection.go @@ -46,7 +46,7 @@ func changeProtection(ctx context.Context, client hcapi2.Client, waiter state.Ac return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/cmd/volume/resize.go b/internal/cmd/volume/resize.go index db54d2ee..d5df7c9d 100644 --- a/internal/cmd/volume/resize.go +++ b/internal/cmd/volume/resize.go @@ -41,7 +41,7 @@ var ResizeCmd = base.Cmd{ return err } - if err := waiter.ActionProgress(ctx, action); err != nil { + if err := waiter.ActionProgress(cmd, ctx, action); err != nil { return err } diff --git a/internal/state/command_helper_mocks.go b/internal/state/command_helper_mocks.go index 551c147c..f9244280 100644 --- a/internal/state/command_helper_mocks.go +++ b/internal/state/command_helper_mocks.go @@ -37,31 +37,31 @@ func (m *MockActionWaiter) EXPECT() *MockActionWaiterMockRecorder { } // ActionProgress mocks base method. -func (m *MockActionWaiter) ActionProgress(arg0 context.Context, arg1 *hcloud.Action) error { +func (m *MockActionWaiter) ActionProgress(arg0 *cobra.Command, arg1 context.Context, arg2 *hcloud.Action) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ActionProgress", arg0, arg1) + ret := m.ctrl.Call(m, "ActionProgress", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } // ActionProgress indicates an expected call of ActionProgress. -func (mr *MockActionWaiterMockRecorder) ActionProgress(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockActionWaiterMockRecorder) ActionProgress(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ActionProgress", reflect.TypeOf((*MockActionWaiter)(nil).ActionProgress), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ActionProgress", reflect.TypeOf((*MockActionWaiter)(nil).ActionProgress), arg0, arg1, arg2) } // WaitForActions mocks base method. -func (m *MockActionWaiter) WaitForActions(arg0 context.Context, arg1 []*hcloud.Action) error { +func (m *MockActionWaiter) WaitForActions(arg0 *cobra.Command, arg1 context.Context, arg2 []*hcloud.Action) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WaitForActions", arg0, arg1) + ret := m.ctrl.Call(m, "WaitForActions", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } // WaitForActions indicates an expected call of WaitForActions. -func (mr *MockActionWaiterMockRecorder) WaitForActions(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockActionWaiterMockRecorder) WaitForActions(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForActions", reflect.TypeOf((*MockActionWaiter)(nil).WaitForActions), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForActions", reflect.TypeOf((*MockActionWaiter)(nil).WaitForActions), arg0, arg1, arg2) } // MockTokenEnsurer is a mock of TokenEnsurer interface. diff --git a/internal/state/command_helpers.go b/internal/state/command_helpers.go index baf246d7..6cd9f751 100644 --- a/internal/state/command_helpers.go +++ b/internal/state/command_helpers.go @@ -11,8 +11,8 @@ import ( //go:generate mockgen -package state -destination command_helper_mocks.go . ActionWaiter,TokenEnsurer type ActionWaiter interface { - ActionProgress(context.Context, *hcloud.Action) error - WaitForActions(context.Context, []*hcloud.Action) error + ActionProgress(*cobra.Command, context.Context, *hcloud.Action) error + WaitForActions(*cobra.Command, context.Context, []*hcloud.Action) error } type TokenEnsurer interface { diff --git a/internal/state/helpers.go b/internal/state/helpers.go index 6c90c4a3..a08eedfb 100644 --- a/internal/state/helpers.go +++ b/internal/state/helpers.go @@ -59,11 +59,11 @@ func StdoutIsTerminal() bool { return terminal.IsTerminal(int(os.Stdout.Fd())) } -func (c *State) ActionProgress(ctx context.Context, action *hcloud.Action) error { - return c.ActionsProgresses(ctx, []*hcloud.Action{action}) +func (c *State) ActionProgress(cmd *cobra.Command, ctx context.Context, action *hcloud.Action) error { + return c.ActionsProgresses(cmd, ctx, []*hcloud.Action{action}) } -func (c *State) ActionsProgresses(ctx context.Context, actions []*hcloud.Action) error { +func (c *State) ActionsProgresses(cmd *cobra.Command, ctx context.Context, actions []*hcloud.Action) error { progressCh, errCh := c.Client().Action.WatchOverallProgress(ctx, actions) if StdoutIsTerminal() { @@ -96,7 +96,7 @@ func (c *State) EnsureToken(_ *cobra.Command, _ []string) error { return nil } -func (c *State) WaitForActions(ctx context.Context, actions []*hcloud.Action) error { +func (c *State) WaitForActions(cmd *cobra.Command, ctx context.Context, actions []*hcloud.Action) error { for _, action := range actions { resources := make(map[string]int64) for _, resource := range action.Resources { @@ -115,7 +115,7 @@ func (c *State) WaitForActions(ctx context.Context, actions []*hcloud.Action) er _, errCh := c.Client().Action.WatchProgress(ctx, action) - err := DisplayProgressCircle(errCh, waitingFor) + err := DisplayProgressCircle(cmd, errCh, waitingFor) if err != nil { return err } @@ -124,7 +124,7 @@ func (c *State) WaitForActions(ctx context.Context, actions []*hcloud.Action) er return nil } -func DisplayProgressCircle(errCh <-chan error, waitingFor string) error { +func DisplayProgressCircle(cmd *cobra.Command, errCh <-chan error, waitingFor string) error { const ( done = "done" failed = "failed"