Skip to content

Commit

Permalink
Merge pull request #59 from uselagoon/check-prune-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon authored Jul 11, 2022
2 parents 203cbc2 + 70df671 commit 94d83e6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/generator/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func generateBackupValues(
if flagCheckSchedule == "enabled" {
buildValues.Backup.CheckSchedule = "@weekly-random"
} else {
buildValues.Backup.CheckSchedule, err = helpers.ConvertCrontab(buildValues.Namespace, flagCheckSchedule)
buildValues.Backup.CheckSchedule, err = helpers.ConvertCrontab(buildValues.Namespace, defaultCheckSchedule)
if err != nil {
return fmt.Errorf("Unable to convert crontab for default check schedule: %v", err)
}
Expand All @@ -78,7 +78,7 @@ func generateBackupValues(
if flagPruneSchedule == "enabled" {
buildValues.Backup.PruneSchedule = "@weekly-random"
} else {
buildValues.Backup.PruneSchedule, err = helpers.ConvertCrontab(buildValues.Namespace, flagPruneSchedule)
buildValues.Backup.PruneSchedule, err = helpers.ConvertCrontab(buildValues.Namespace, defaultPruneSchedule)
if err != nil {
return fmt.Errorf("Unable to convert crontab for default prune schedule: %v", err)
}
Expand Down
64 changes: 63 additions & 1 deletion internal/generator/backups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func Test_generateBackupValues(t *testing.T) {
},
},
{
name: "test11 - custom restore and backup configuration with endpoint and bucket",
name: "test12 - custom restore and backup configuration with endpoint and bucket",
args: args{
buildValues: &BuildValues{
BuildType: "branch",
Expand Down Expand Up @@ -430,6 +430,68 @@ func Test_generateBackupValues(t *testing.T) {
},
},
},
{
name: "test13 - K8UP_WEEKLY_RANDOM_FEATURE_FLAG enabled",
args: args{
buildValues: &BuildValues{
BuildType: "branch",
EnvironmentType: "development",
Namespace: "example-com-main",
},
lYAML: &lagoon.YAML{},
mergedVariables: []lagoon.EnvironmentVariable{},
},
vars: []helpers.EnvironmentVariable{
{Name: "K8UP_WEEKLY_RANDOM_FEATURE_FLAG", Value: "enabled"},
},
want: &BuildValues{
BuildType: "branch",
EnvironmentType: "development",
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "31 1 * * *",
CheckSchedule: "@weekly-random",
PruneSchedule: "@weekly-random",
PruneRetention: PruneRetention{
Hourly: 0,
Daily: 7,
Weekly: 6,
Monthly: 1,
},
},
},
},
{
name: "test14 - K8UP_WEEKLY_RANDOM_FEATURE_FLAG set but not enabled/valid",
args: args{
buildValues: &BuildValues{
BuildType: "branch",
EnvironmentType: "development",
Namespace: "example-com-main",
},
lYAML: &lagoon.YAML{},
mergedVariables: []lagoon.EnvironmentVariable{},
},
vars: []helpers.EnvironmentVariable{
{Name: "K8UP_WEEKLY_RANDOM_FEATURE_FLAG", Value: "jkhk"},
},
want: &BuildValues{
BuildType: "branch",
EnvironmentType: "development",
Namespace: "example-com-main",
Backup: BackupConfiguration{
BackupSchedule: "31 1 * * *",
CheckSchedule: "31 4 * * 0",
PruneSchedule: "31 4 * * 0",
PruneRetention: PruneRetention{
Hourly: 0,
Daily: 7,
Weekly: 6,
Monthly: 1,
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 94d83e6

Please sign in to comment.