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: handler.go
    path of file: ./repos/harbor/src/controller/event/handler/replication/event
    
    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");
// you may not use this file except in compliance with the License.
// You may obtain a copy 
    
func getRelatedPolicies(ctx context.Context, resource *model.Resource) ([]*repctlmodel.Policy, error) {
	policies, err := replication.Ctl.ListPolicies(ctx, nil)
	if err != nil {
		return nil, err
	}
	result := []*repctlmodel.Policy{}
	for _, policy := range policies {
		// disabled
		if !policy.Enabled {
			continue
		}
		// currently, the events are produced only by local Harbor,
		// so they should only apply to the policies whose source registry is local Harbor
		if !(policy.SrcRegistry == nil || policy.SrcRegistry.ID == 0) {
			continue
		}
		// has no trigger
		if policy.Trigger == nil {
			continue
		}
		// trigger type isn't event based
		if policy.Trigger.Type != model.TriggerTypeEventBased {
			continue
		}
		// doesn't replicate deletion
		if resource.Deleted && !policy.ReplicateDeletion {
			continue
		}

		resources, err := filter.DoFilterResources([]*model.Resource{resource}, policy.Filters)
		if err != nil {
			return nil, err
		}
		// doesn't match the filters
		if len(resources) == 0 {
			continue
		}

		result = append(result, policy)
	}
	return result, nil
}