{"id":31837733,"url":"https://github.com/cloudoperators/common-cloud-resource-names","last_synced_at":"2025-10-12T02:29:47.499Z","repository":{"id":318714177,"uuid":"1028347756","full_name":"cloudoperators/common-cloud-resource-names","owner":"cloudoperators","description":"The Common Cloud Resource Names (CCRN) framework provides a standardized, machine-readable convention for naming and validating resources across heterogeneous technology stacks (Kubernetes, OpenStack, Vault, VMware, etc.). CCRN enables organizations to uniquely identify resources, enforce naming policies, and facilitate cross-system integration.","archived":false,"fork":false,"pushed_at":"2025-10-08T13:52:33.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-11T02:54:13.794Z","etag":null,"topics":["ccrn","cloud","iam","resource-naming"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudoperators.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-29T11:53:26.000Z","updated_at":"2025-10-08T13:51:23.000Z","dependencies_parsed_at":"2025-10-11T02:54:27.420Z","dependency_job_id":"e8bec56c-630b-47b1-87fa-51dd0434627a","html_url":"https://github.com/cloudoperators/common-cloud-resource-names","commit_stats":null,"previous_names":["cloudoperators/common-cloud-resource-names"],"tags_count":2,"template":false,"template_full_name":"cloudoperators/repository-template","purl":"pkg:github/cloudoperators/common-cloud-resource-names","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudoperators%2Fcommon-cloud-resource-names","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudoperators%2Fcommon-cloud-resource-names/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudoperators%2Fcommon-cloud-resource-names/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudoperators%2Fcommon-cloud-resource-names/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudoperators","download_url":"https://codeload.github.com/cloudoperators/common-cloud-resource-names/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudoperators%2Fcommon-cloud-resource-names/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009958,"owners_count":26084670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ccrn","cloud","iam","resource-naming"],"created_at":"2025-10-12T02:29:46.437Z","updated_at":"2025-10-12T02:29:47.490Z","avatar_url":"https://github.com/cloudoperators.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Common Cloud Resource Names (CCRN)\n\n## About this project\n\nThe Common Cloud Resource Names (CCRN) framework provides a standardized, machine-readable convention for naming and validating resources across heterogeneous technology stacks (Kubernetes, OpenStack, Vault, VMware, etc.). CCRN enables organizations to uniquely identify resources, enforce naming policies, and facilitate cross-system integration.\n\n### Key Attributes of the Framework\n\n- **Unified Resource Naming**: Ability to create consistent string-based resource identifiers.\n- **K8s Native**: Resource names are defined and validated with Kubernetes Custom Resource Definitions (CRDs).\n- **Flexibility**: Use wildcards for broad resource selection/description.\n- **Versioning**: Resource type strings include versioning for historical correctness.\n\n### Use Cases\n\n- **IAM Policies and access descriptions**: Consistent resource references for access control use cases\n- **Logging \u0026 Monitoring**: Unique resource identifiers in logs and metrics.\n- **Vulnerability Management**: Precise resource targeting for vulnerability scans and reports.\n- **BOM**: Bill of Material Documentations\n- **Documentation**: Unambiguous resource references in technical documentation.\n\n### CCRN Formats\n\nCCRNs are submitted as a single string value in either the CCRN format or the URN format and they are defined using k8s\ncustom resource definitions.\n\n#### Field-Based CCRN Format\n\nA CCRN string consists of a resource type and a set of required and optional fields:\n\n```\nccrn=\u003ckind\u003e.\u003cgroup\u003e/\u003cversion\u003e, \u003cfieldKey\u003e=\u003cfield_val\u003e, ...\n```\n\nThis example assumes you have a CCRN CRD defined that describes a container. The resulting CCRN might look like:\n\n```\nccrn=container.k8s.ccrn.example.com/v1, cluster=st-eu-de-1, namespace=kube-monitoring, pod=log-collect, name=collector\n```\n\nThe field based format **DOES NOT** enforce **hierarchical fields** but **MUST start with** `ccrn=\u003cresourceIdentifier\u003e` where the `\u003cresourceIdentifier\u003e == \u003ckind\u003e.\u003cgroup\u003e/\u003cversion\u003e`\n\nSo the following CCRN are identical to the above:\n\n```\nccrn=container.k8s.ccrn.example.com/v1, cluster=st-eu-de-1, pod=log-collect, name=collector, namespace=kube-monitoring\n\nccrn=container.k8s.ccrn.example.com/v1, name=collector, cluster=st-eu-de-1, namespace=kube-monitoring, pod=log-collect\n```\n\nBut for better human readability it is recommended to use the hierarchical order of fields as defined in the CRDs URN\nand URL templates.\n\n#### URN Format\n\nA more compact string representation for referencing resources are URN formats.\n\nIn the example above the URN format may look like:\n\n```\nurn:ccrn:container.k8s.ccrn.example.com/v1/st-eu-de-1/kube-monitoringlog-collect/collector\n```\n\nThe URN  formats are derived from the field-based CCRN format and the respective CRD Annotations and have a\nstrict order of fields as defined in the CRD Annotations.\n\n#### The Resource Definition\n\nThe above example CCRN is based on the following example CRD definition that describes a k8s container resource:\n\n```yaml\napiVersion: apiextensions.k8s.io/v1\nkind: CustomResourceDefinition\nmetadata:\n    name: containers.k8s-registry.ccrn.example.com\n    annotations:\n        ccrn/v1.urn-template: \"urn:ccrn:\u003cccrn\u003e/\u003ccluster\u003e/\u003cnamespace\u003e/\u003cpod\u003e/\u003cname\u003e\"\nspec:\n    group: k8s-registry.ccrn.example.com\n    names:\n        kind: container\n        listKind: containerList\n        plural: containers\n        singular: container\n    scope: Namespaced\n    versions:\n        -   name: v1\n            served: true\n            storage: true\n            schema:\n                openAPIV3Schema:\n                    type: object\n                    required: [ \"ccrn\", \"cluster\", \"namespace\", \"pod\", \"name\" ]\n                    properties:\n                        # Required\n                        ccrn:\n                            type: string\n                            enum: [ \"container.k8s-registry.ccrn.example.com/v1\" ]\n                        cluster:\n                            type: string\n                            description: \"The cluster the container is running in\"\n                            enum: [ \"st-eu-de-1\", \"*\" ]\n                        namespace:\n                            type: string\n                            description: \"The Namespace the container is running in\"\n                            pattern: \"^([a-z0-9]([a-z0-9-]*[a-z0-9])?|\\\\*)$\"\n                            maxLength: 63\n                        pod:\n                            type: string\n                            description: \"The name of the Pod the Container is running in\"\n                            pattern: \"^([a-z0-9]([-a-z0-9]*[a-z0-9])?|\\\\*)$\"\n                            maxLength: 253\n                        name:\n                            type: string\n                            description: \"The name of the Container\"\n                            pattern: \"^([a-z0-9]([-a-z0-9]*[a-z0-9])?|\\\\*)$\"\n                            maxLength: 253\n                        # Optional\n                        id:\n                            type: string\n                            description: \"This is the containerID of the container describing the concrete ephemeral container\"\n                            pattern: \"^([a-zA-Z0-9:.-_]+|\\\\*)$\"\n                        labels:\n                            type: object\n                            additionalProperties:\n                                type: string\n                            description: \"Labels for selecting groups of containers\"\n```\n\n### Required vs Optional Fields\n\nEach resource type defines required fields for unique identification and optional fields for grouping/filtering.  \nGenerally required fields are fields used in the URN and URL templates, while optional fields are used for additional\nmetadata or grouping are only present in the field-based CCRN format.\n\n\n### Validation\n\nValidation is performed via Kubernetes Custom Resource Definitions (CRDs) and an admission webhook or directly via\nconsumption of the CRD Files using the Kubernetes Library.\n\n#### Validation via Admission Webhook\n\n1. Create a CCRN custom resource with either `ccrn` or `urn` field.\n2. The webhook parses and validates the CCRN against the corresponding CRD schema.\n3. Resource creation succeeds only if validation passes; otherwise, an error is returned.\n\nExample CCRN resource:\n\n```yaml\napiVersion: validate.ccrn.example.com/v1\nkind: CCRN\nmetadata:\n    name: test-container-ccrn\nspec:\n    ccrn: \"ccrn=k8s-registry.ccrn.example.com/v1, cluster=eu-de-1, namespace=ccrn-test, pod=somepod-xyz, name=actual-name\"\n```\n\n#### Validation via Kubernetes Library\n\nYou can also validate CCRNs directly using the Kubernetes library in your application code. This allows you to check if\na CCRN conforms to the defined CRD schema before processing it.\n\n```golang \npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"os\"\n\n    \"github.com/cloudoperators/common-cloud-resource-names/pkg/validation\"\n    \"github.com/cloudoperators/common-cloud-resource-names/pkg/webhook\"\n)\n\nfunc main() {\n    // Create logger\n    logger := logrus.New()\n    logger.SetLevel(logrus.DebugLevel)\n\n    // Create offline backend\n    backend := validation.NewOfflineBackend(logger, \"ccrn.example.com\")\n\n    // Load CRDs from directory\n    crdDir := \"./ccrn_out\" // Adjust path as needed\n    if len(os.Args) \u003e 1 {\n        crdDir = os.Args[1]\n    }\n\n    fmt.Printf(\"Loading CRDs from directory: %s\\n\", crdDir)\n\n    // Load all YAML files from the directory\n    err := backend.LoadCRDsFromDirectory(crdDir)\n    if err != nil {\n        log.Fatalf(\"Failed to load CRDs: %v\", err)\n    }\n\n    // Show loaded CRDs\n    loadedCRDs := backend.GetLoadedCRDs()\n    fmt.Printf(\"\\nLoaded %d CRDs:\\n\", len(loadedCRDs))\n    for _, crd := range loadedCRDs {\n        fmt.Printf(\"  - %s\\n\", crd)\n    }\n\n    // Create validator\n    validator := validation.NewCCRNValidator(backend)\n\n    res, err := validator.ValidateCCRN(\"ccrn=k8s-registry.ccrn.example.com/v1, cluster=eu-de-1, namespace=ccrn-test, pod=somepod-xyz, name=actual-name\")\n    if err != nil {\n        log.Fatalf(\"Failed to validate CCRN: %v\", err)\n    }\n\n    if res.Valid {\n        fmt.Println(\"CCRN is valid\")\n    } else {\n        fmt.Println(\"CCRN is invalid:\")\n        for _, err := range res.Errors {\n            fmt.Printf(\"  - %s\\n\", err)\n        }\n    }\n}\n```\n\n## Requirements and Setup\n\n*Insert a short description what is required to get your project running...*\n\n## Support, Feedback, Contributing\n\nThis project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cloudoperators/common-cloud-resource-names-ccrn-/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).\n\n## Security / Disclosure\nIf you find any bug that may be a security problem, please follow our instructions at [in our security policy](https://github.com/cloudoperators/common-cloud-resource-names-ccrn-/security/policy) on how to report it. Please do not create GitHub issues for security-related doubts or problems.\n\n## Code of Conduct\n\nWe as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](https://github.com/SAP/.github/blob/main/CODE_OF_CONDUCT.md) at all times.\n\n## Licensing\n\nCopyright 2025 SAP SE or an SAP affiliate company and common-cloud-resource-names-ccrn- contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/cloudoperators/common-cloud-resource-names-ccrn-).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudoperators%2Fcommon-cloud-resource-names","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudoperators%2Fcommon-cloud-resource-names","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudoperators%2Fcommon-cloud-resource-names/lists"}