Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ require (
github.com/spf13/viper v1.19.0
github.com/stackitcloud/stackit-sdk-go/core v0.14.0
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.4.0
github.com/stackitcloud/stackit-sdk-go/services/dns v0.11.0
github.com/stackitcloud/stackit-sdk-go/services/dns v0.12.0
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.16.0
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v0.16.0
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.19.0
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v0.16.0
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.11.0
github.com/stackitcloud/stackit-sdk-go/services/runcommand v0.2.0
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.10.0
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.2.0
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.3.0
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.5.0
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v0.3.0
github.com/stackitcloud/stackit-sdk-go/services/ske v0.20.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ github.com/stackitcloud/stackit-sdk-go/core v0.14.0 h1:oBwwzrEHDTlZpRoQwmMQpNA8b
github.com/stackitcloud/stackit-sdk-go/core v0.14.0/go.mod h1:mDX1mSTsB3mP+tNBGcFNx6gH1mGBN4T+dVt+lcw7nlw=
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.4.0 h1:WXSIE4KfdHzaiiD0MF8CsoIv8I+Two/Bf/r28tYhRCU=
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.4.0/go.mod h1:8spVqlPqZrvQQ63Qodbydk3qsZx7lr963ECft+sqFhY=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.11.0 h1:+OZ82DwFy4JIJThadVjvll5kUWjHPSLbUIF65njsNBk=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.11.0/go.mod h1:mv8U7kuclXo+0VpDHtBCkve/3i9h1yT+RAId/MUi+C8=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.12.0 h1:NypnmRbvjCX7ANJej1epwmopBEjkMzklJT3SY5iVwWg=
github.com/stackitcloud/stackit-sdk-go/services/dns v0.12.0/go.mod h1:mv8U7kuclXo+0VpDHtBCkve/3i9h1yT+RAId/MUi+C8=
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.16.0 h1:geyW780gqNxzSsPvmlxy3kUUJaRA4eiF9V3b2Ibcdjs=
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.16.0/go.mod h1:YfuN+eXuqr846xeRyW2Vf1JM2jU0ikeQa76dDI66RsM=
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v0.17.0 h1:06CGP64CEk3Zg6i9kZCMRdmCzLLiyMWQqGK1teBr9Oc=
Expand Down Expand Up @@ -159,8 +159,8 @@ github.com/stackitcloud/stackit-sdk-go/services/runcommand v0.2.0 h1:tb0w+0imdJh
github.com/stackitcloud/stackit-sdk-go/services/runcommand v0.2.0/go.mod h1:LgCIIj7jA2lWX4DI3bxUYD+m0TbWCr1VgAyBYNJeghc=
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.10.0 h1:HrnEgRPt3eD/tEHyzDWyCRxNFzb9g/FLYfwIEEQZ+Rg=
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.10.0/go.mod h1:268uoY2gKCa5xcDL169TGVjLUNTcZ2En77YdfYOcR1w=
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.2.0 h1:6IUrNIBEIpmrlfEK3QENQZB35KHEmeyc7w1owFOfGpc=
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.2.0/go.mod h1:+807U5ZLXns+CEbyIg483wNEwV10vaN6GjMnSZhw/64=
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.3.0 h1:Tlps8vBQmQ1mx2YFbzOzMIyWtXGJy7X3N9Qk3qk88Cc=
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.3.0/go.mod h1:+807U5ZLXns+CEbyIg483wNEwV10vaN6GjMnSZhw/64=
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.5.0 h1:yf9BxAZEG2hdaekWxaNt2BOX/4qmGkl0d268ggR+tCU=
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.5.0/go.mod h1:Wpqj80yGruCNYGr2yxqhRaLLj4gPSkhJqZyWRXUh/QU=
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v0.3.0 h1:6IZBX9fyza9Eln3FHGHquvLNXQslk+dtkQp41G9+7+Y=
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/services/serverbackup/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

type ServerBackupClient interface {
ListBackupSchedulesExecute(ctx context.Context, projectId, serverId string) (*serverbackup.ListBackupSchedules200Response, error)
ListBackupsExecute(ctx context.Context, projectId, serverId string) (*serverbackup.ListBackups200Response, error)
ListBackupSchedulesExecute(ctx context.Context, projectId, serverId string) (*serverbackup.GetBackupSchedulesResponse, error)
ListBackupsExecute(ctx context.Context, projectId, serverId string) (*serverbackup.GetBackupsListResponse, error)
}

func CanDisableBackupService(ctx context.Context, client ServerBackupClient, projectId, serverId string) (bool, error) {
Expand Down
32 changes: 16 additions & 16 deletions internal/pkg/services/serverbackup/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ var (

type serverbackupClientMocked struct {
listBackupSchedulesFails bool
listBackupSchedulesResp *serverbackup.ListBackupSchedules200Response
listBackupSchedulesResp *serverbackup.GetBackupSchedulesResponse
listBackupsFails bool
listBackupsResp *serverbackup.ListBackups200Response
listBackupsResp *serverbackup.GetBackupsListResponse
}

func (m *serverbackupClientMocked) ListBackupSchedulesExecute(_ context.Context, _, _ string) (*serverbackup.ListBackupSchedules200Response, error) {
func (m *serverbackupClientMocked) ListBackupSchedulesExecute(_ context.Context, _, _ string) (*serverbackup.GetBackupSchedulesResponse, error) {
if m.listBackupSchedulesFails {
return nil, fmt.Errorf("could not list backup schedules")
}
return m.listBackupSchedulesResp, nil
}

func (m *serverbackupClientMocked) ListBackupsExecute(_ context.Context, _, _ string) (*serverbackup.ListBackups200Response, error) {
func (m *serverbackupClientMocked) ListBackupsExecute(_ context.Context, _, _ string) (*serverbackup.GetBackupsListResponse, error) {
if m.listBackupsFails {
return nil, fmt.Errorf("could not list backups")
}
Expand All @@ -42,43 +42,43 @@ func TestCanDisableBackupService(t *testing.T) {
description string
listBackupsFails bool
listBackupSchedulesFails bool
listBackups *serverbackup.ListBackups200Response
listBackupSchedules *serverbackup.ListBackupSchedules200Response
listBackups *serverbackup.GetBackupsListResponse
listBackupSchedules *serverbackup.GetBackupSchedulesResponse
isValid bool // isValid ==> err == nil
expectedOutput bool // expectedCanDisable
}{
{
description: "base-ok-can-disable-backups-service-no-backups-no-backup-schedules",
listBackupsFails: false,
listBackupSchedulesFails: false,
listBackups: &serverbackup.ListBackups200Response{Items: &[]serverbackup.Backup{}},
listBackupSchedules: &serverbackup.ListBackupSchedules200Response{Items: &[]serverbackup.BackupSchedule{}},
listBackups: &serverbackup.GetBackupsListResponse{Items: &[]serverbackup.Backup{}},
listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{Items: &[]serverbackup.BackupSchedule{}},
isValid: true,
expectedOutput: true,
},
{
description: "not-ok-api-error-list-backups",
listBackupsFails: true,
listBackupSchedulesFails: false,
listBackups: &serverbackup.ListBackups200Response{Items: &[]serverbackup.Backup{}},
listBackupSchedules: &serverbackup.ListBackupSchedules200Response{Items: &[]serverbackup.BackupSchedule{}},
listBackups: &serverbackup.GetBackupsListResponse{Items: &[]serverbackup.Backup{}},
listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{Items: &[]serverbackup.BackupSchedule{}},
isValid: false,
expectedOutput: false,
},
{
description: "not-ok-api-error-list-backup-schedules",
listBackupsFails: true,
listBackupSchedulesFails: false,
listBackups: &serverbackup.ListBackups200Response{Items: &[]serverbackup.Backup{}},
listBackupSchedules: &serverbackup.ListBackupSchedules200Response{Items: &[]serverbackup.BackupSchedule{}},
listBackups: &serverbackup.GetBackupsListResponse{Items: &[]serverbackup.Backup{}},
listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{Items: &[]serverbackup.BackupSchedule{}},
isValid: false,
expectedOutput: false,
},
{
description: "not-ok-has-backups-cannot-disable",
listBackupsFails: false,
listBackupSchedulesFails: false,
listBackups: &serverbackup.ListBackups200Response{
listBackups: &serverbackup.GetBackupsListResponse{
Items: &[]serverbackup.Backup{
{
CreatedAt: utils.Ptr("test timestamp"),
Expand All @@ -92,16 +92,16 @@ func TestCanDisableBackupService(t *testing.T) {
},
},
},
listBackupSchedules: &serverbackup.ListBackupSchedules200Response{Items: &[]serverbackup.BackupSchedule{}},
listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{Items: &[]serverbackup.BackupSchedule{}},
isValid: true,
expectedOutput: false,
},
{
description: "not-ok-has-backups-schedules-cannot-disable",
listBackupsFails: false,
listBackupSchedulesFails: false,
listBackups: &serverbackup.ListBackups200Response{Items: &[]serverbackup.Backup{}},
listBackupSchedules: &serverbackup.ListBackupSchedules200Response{
listBackups: &serverbackup.GetBackupsListResponse{Items: &[]serverbackup.Backup{}},
listBackupSchedules: &serverbackup.GetBackupSchedulesResponse{
Items: &[]serverbackup.BackupSchedule{
{
BackupProperties: nil,
Expand Down