util

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package util provides utility functions for converting API group and resource names into normalized type names suitable for use in authorization systems.

This package is primarily designed for use with Fine-Grained Authorization (FGA) systems where consistent naming conventions are required for type definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToTypeName

func ConvertToTypeName(group, singular string) string

ConvertToTypeName converts an API group and singular resource name into a normalized type name suitable for use in authorization systems.

Parameters:

  • group: The API group name (e.g., "apps", "networking.k8s.io", "")
  • singular: The singular form of the resource name (e.g., "deployment", "pod", "Service")

Returns:

A normalized type name string suitable for authorization system usage.

Examples:

ConvertToTypeName("apps", "deployment") → "apps_deployment"
ConvertToTypeName("", "pod") → "core_pod"
ConvertToTypeName("networking.k8s.io", "ingress") → "networking_k8s_io_ingress"
ConvertToTypeName("Apps", "Deployment") → "apps_deployment"

The function handles edge cases gracefully:

  • Empty group names default to "core"
  • Very long names are truncated to respect maxRelationLength
  • Special characters like dots are normalized to underscores
  • Mixed case is normalized to lowercase

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL