def get_affinity_rules(cluster, search_criteria):
    """
    Get an affinity rule by its name
    """
    rules = []
    for rule in cluster.configuration.rule:
        if rule.key == search_criteria:
            return [rule]
        if rule.name == search_criteria:
            rules.append(rule)
    return rules if rules else None
