You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: controller.go
    path of file: ./repos/harbor/src/controller/retention
    
    the code of the file until where you have to start completion: // Copyright Project Harbor Authors
//
// Licensed under the Apache License, Version 2.0 (the "License
    
func (r *defaultController) CreateRetention(ctx context.Context, p *policy.Metadata) (int64, error) {
	err := p.ValidateRetentionPolicy()
	if err != nil {
		return 0, err
	}
	id, err := r.manager.CreatePolicy(ctx, p)
	if err != nil {
		return 0, err
	}

	if p.Trigger.Kind == policy.TriggerKindSchedule {
		cron, ok := p.Trigger.Settings[policy.TriggerSettingsCron]
		if ok && len(cron.(string)) > 0 {
			extras := make(map[string]interface{})
			if _, err = r.scheduler.Schedule(ctx, schedulerVendorType, id, "", cron.(string), SchedulerCallback, TriggerParam{
				PolicyID: id,
				Trigger:  retention.ExecutionTriggerSchedule,
				// the operator of schedule job is harbor-jobservice
				Operator: secret.JobserviceUser,
			}, extras); err != nil {
				return 0, err
			}
		}
	}

	return id, nil
}