Skip to content

Use NamespacedName Type for Internal APIs #157

@danehans

Description

@danehans

Internal APIs, e.g. EndpointSliceReconciler, use separate ns and name strings to represent the ns/name of CRs. A few benefits of using NamespacedName are:

  • Encapsulates the namespace and name into a single struct, improving readability by clearly indicating that these two fields together uniquely identify a Kubernetes resource.
  • Provides stronger type safety compared to using two separate strings.
  • Provides built-in methods like String() that automatically format the resource identifier in the conventional namespace/name format, reducing boilerplate code and potential formatting errors.
  • Functions that operate on Kubernetes resources often require both namespace and name. Using a single types.NamespacedName reduces the number of function parameters, simplifying function signatures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions