diff --git a/pkg/apis/registryman/v1alpha1/types.go b/pkg/apis/registryman/v1alpha1/types.go index 099eb53..e522638 100644 --- a/pkg/apis/registryman/v1alpha1/types.go +++ b/pkg/apis/registryman/v1alpha1/types.go @@ -546,7 +546,7 @@ func (rtt *ReplicationTriggerType) UnmarshalText(text []byte) error { *rtt = ManualReplicationTriggerType case "event_based": *rtt = EventBasedReplicationTriggerType - case "cron": + case "scheduled", "cron": *rtt = CronReplicationTriggerType default: *rtt = UndefinedRepliationTriggerType diff --git a/pkg/config/errors.go b/pkg/config/errors.go index 875492e..0a412ef 100644 --- a/pkg/config/errors.go +++ b/pkg/config/errors.go @@ -42,6 +42,10 @@ var ErrValidationRegistryNameNotUnique error = errors.New("validation error: mul // non-existing Scanner. var ErrValidationScannerNameReference error = errors.New("validation error: multiple registries present with the same name") -// ErrValidationScannerNameReference error indicates that a project refers to a -// non-existing Scanner. +// ErrValidationGroupWithoutDN error indicates that a project group member +// doesn't have its DN field set. var ErrValidationGroupWithoutDN error = errors.New("validation error: project group member with missing DN field") + +// ErrValidationReplicationRuleWrongSchedule error indicates that the replication rule's +// schedule field isn't empty while the replication type is not 'cron'. +var ErrValidationReplicationRuleWrongSchedule error = errors.New("validation error: replication rule with incorrect schedule field") diff --git a/pkg/config/local_file_aos.go b/pkg/config/local_file_aos.go index 4606a15..984b625 100644 --- a/pkg/config/local_file_aos.go +++ b/pkg/config/local_file_aos.go @@ -334,6 +334,10 @@ func checkProject(project *api.Project) error { err = ErrValidationGroupWithoutDN } } + if project.Spec.Trigger.Schedule != "" && + project.Spec.Trigger.TriggerType() != api.CronReplicationTriggerType { + return ErrValidationReplicationRuleWrongSchedule + } return err } diff --git a/pkg/harbor/project.go b/pkg/harbor/project.go index c304934..f030b26 100644 --- a/pkg/harbor/project.go +++ b/pkg/harbor/project.go @@ -295,7 +295,9 @@ func (p *project) GetReplicationRules(ctx context.Context, trigger globalregistr ) if replRule.GetProjectName() == p.Name { p.registry.logger.V(1).Info("project name matches, replication rule stored") - if trigger != nil && trigger != replRule.Trigger() { + if trigger != nil && + trigger.TriggerType() != replRule.Trigger().TriggerType() && + trigger.TriggerSchedule() != replRule.Trigger().TriggerSchedule() { continue } if direction != "" && direction != replRule.Direction() {