Provisioning: Allow configurable min interval (#111920)
This commit is contained in:
@@ -75,11 +75,6 @@ func ValidateRepository(repo Repository) field.ErrorList {
|
||||
"The target type is required when sync is enabled"))
|
||||
}
|
||||
|
||||
if cfg.Spec.Sync.Enabled && cfg.Spec.Sync.IntervalSeconds < 10 {
|
||||
list = append(list, field.Invalid(field.NewPath("spec", "sync", "intervalSeconds"),
|
||||
cfg.Spec.Sync.IntervalSeconds, fmt.Sprintf("Interval must be at least %d seconds", 10)))
|
||||
}
|
||||
|
||||
// Reserved names (for now)
|
||||
reserved := []string{"classic", "sql", "SQL", "plugins", "legacy", "new", "job", "github", "s3", "gcs", "file", "new", "create", "update", "delete"}
|
||||
if slices.Contains(reserved, cfg.Name) {
|
||||
|
||||
@@ -74,28 +74,6 @@ func TestValidateRepository(t *testing.T) {
|
||||
require.Contains(t, errors.ToAggregate().Error(), "spec.sync.target: Required value")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sync interval too low",
|
||||
repository: func() *MockRepository {
|
||||
m := NewMockRepository(t)
|
||||
m.On("Config").Return(&provisioning.Repository{
|
||||
Spec: provisioning.RepositorySpec{
|
||||
Title: "Test Repo",
|
||||
Sync: provisioning.SyncOptions{
|
||||
Enabled: true,
|
||||
Target: "test",
|
||||
IntervalSeconds: 5,
|
||||
},
|
||||
},
|
||||
})
|
||||
m.On("Validate").Return(field.ErrorList{})
|
||||
return m
|
||||
}(),
|
||||
expectedErrs: 1,
|
||||
validateError: func(t *testing.T, errors field.ErrorList) {
|
||||
require.Contains(t, errors.ToAggregate().Error(), "spec.sync.intervalSeconds: Invalid value")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reserved name",
|
||||
repository: func() *MockRepository {
|
||||
@@ -191,11 +169,10 @@ func TestValidateRepository(t *testing.T) {
|
||||
m.On("Validate").Return(field.ErrorList{})
|
||||
return m
|
||||
}(),
|
||||
expectedErrs: 4, // Updated from 3 to 4 to match actual errors:
|
||||
expectedErrs: 3,
|
||||
// 1. missing title
|
||||
// 2. sync target missing
|
||||
// 3. sync interval too low
|
||||
// 4. reserved name
|
||||
// 3. reserved name
|
||||
},
|
||||
{
|
||||
name: "branch workflow for non-github repository",
|
||||
@@ -447,18 +424,6 @@ func TestFromFieldError(t *testing.T) {
|
||||
expectedType: metav1.CauseTypeFieldValueRequired,
|
||||
expectedDetail: "a repository title must be given",
|
||||
},
|
||||
{
|
||||
name: "invalid field error",
|
||||
fieldError: &field.Error{
|
||||
Type: field.ErrorTypeInvalid,
|
||||
Field: "spec.sync.intervalSeconds",
|
||||
Detail: "Interval must be at least 10 seconds",
|
||||
},
|
||||
expectedCode: http.StatusBadRequest,
|
||||
expectedField: "spec.sync.intervalSeconds",
|
||||
expectedType: metav1.CauseTypeFieldValueInvalid,
|
||||
expectedDetail: "Interval must be at least 10 seconds",
|
||||
},
|
||||
{
|
||||
name: "not supported field error",
|
||||
fieldError: &field.Error{
|
||||
|
||||
Reference in New Issue
Block a user