Skip to main content

repo_key

Function repo_key 

Source
pub fn repo_key(repo: &RepositoryRef, owner_namespace: &str) -> String
Expand description

A normalized, comparable repository key for a consumer’s RepositoryRef resolved from owner_namespace (the consuming CR’s namespace). Two references are “the same repository” only when their keys match. Pure + exhaustive over RepositoryKind. Hoisted from the webhook’s identity-collision module so the validator, the webhook, and child-naming all normalize identically (the webhook re-exports this).

  • Repository"Repository/<effective-ns>/<name>" (effective-ns is ref.namespace or the owner’s namespace).
  • ClusterRepository"ClusterRepository/<name>" (namespace-free).
use kopiur_api::common::{RepositoryKind, RepositoryRef, repo_key};

let r = RepositoryRef { kind: RepositoryKind::Repository, name: "nas".into(), namespace: None };
assert_eq!(repo_key(&r, "backups"), "Repository/backups/nas");
let c = RepositoryRef { kind: RepositoryKind::ClusterRepository, name: "shared".into(), namespace: None };
assert_eq!(repo_key(&c, "backups"), "ClusterRepository/shared");