Documentation
¶
Overview ¶
SPDX-FileCopyrightText: SAP SE or an SAP affiliate company SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- type CCRNValidator
- type CRDLoadingResult
- type FilesystemBackend
- func (fb *FilesystemBackend) GetCRD(ccrnVersion string) (*apis.CRDInfo, error)
- func (fb *FilesystemBackend) GetLoadedCRDs() []string
- func (fb *FilesystemBackend) GetLoadingStatistics() map[string]interface{}
- func (fb *FilesystemBackend) GetURNTemplate(crdName, version string) (string, error)
- func (fb *FilesystemBackend) IsResourceTypeSupported(ccrnVersion string) bool
- func (fb *FilesystemBackend) LoadCRDs(pattern string) error
- func (fb *FilesystemBackend) LoadCRDsFromDirectory(dir string) error
- func (fb *FilesystemBackend) Refresh() error
- func (fb *FilesystemBackend) ValidateResource(namespace string, parsedCCRN *apis.ParsedResource) error
- type KubernetesBackend
- func (kb *KubernetesBackend) GetCRD(crdVersion string) (*apis.CRDInfo, error)
- func (kb *KubernetesBackend) GetURNTemplate(crdName, version string) (string, error)
- func (kb *KubernetesBackend) IsResourceTypeSupported(ccrnVersion string) bool
- func (kb *KubernetesBackend) Refresh() error
- func (kb *KubernetesBackend) StartRefreshLoop(interval time.Duration)
- func (kb *KubernetesBackend) ValidateResource(namespace string, parsedCCRN *apis.ParsedResource) error
Constants ¶
const ( // YAMLDocumentSeparator represents the standard YAML document separator used by Helm YAMLDocumentSeparator = "---" // CRDKind represents the Kubernetes kind for Custom Resource Definitions CRDKind = "CustomResourceDefinition" // URNTemplateAnnotationFormat defines the format for URN template annotations URNTemplateAnnotationFormat = "ccrn/%s.urn-template" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CCRNValidator ¶
type CCRNValidator struct {
// contains filtered or unexported fields
}
CCRNValidator provides CCRN validation using a pluggable backend
func NewCCRNValidator ¶
func NewCCRNValidator(backend apis.ValidationBackend) *CCRNValidator
NewCCRNValidator creates a new CCRN validator with the specified backend
func (*CCRNValidator) ValidateCCRN ¶
func (v *CCRNValidator) ValidateCCRN(ccrnStr string) (*apis.ValidationResult, error)
ValidateCCRN validates a CCRN string
type CRDLoadingResult ¶
type CRDLoadingResult struct {
ProcessedFiles int // Number of files processed
ProcessedCRDs int // Number of CRDs successfully loaded
SkippedCRDs int // Number of CRDs skipped (e.g., non-CCRN)
ErrorCount int // Number of errors encountered
Errors []error // Detailed error information
LoadedCRDKeys []string // Keys of successfully loaded CRDs
}
CRDLoadingResult contains detailed information about CRD loading operation
type FilesystemBackend ¶
type FilesystemBackend struct {
// contains filtered or unexported fields
}
FilesystemBackend implements ValidationBackend using local CRD files This backend supports loading CRDs from individual files or directories, including multi-document YAML files with Helm-style "---" separators.
func NewOfflineBackend ¶
func NewOfflineBackend(log *logrus.Logger, ccrnGroup string) *FilesystemBackend
NewOfflineBackend creates a new filesystem-based validation backend
Parameters:
- log: Logger instance (will create default if nil)
- ccrnGroup: CCRN group name used for filtering relevant CRDs
Returns:
- *FilesystemBackend: Configured filesystem backend instance
func (*FilesystemBackend) GetCRD ¶
func (fb *FilesystemBackend) GetCRD(ccrnVersion string) (*apis.CRDInfo, error)
GetCRD retrieves CRD information for a given ccrnVersion
func (*FilesystemBackend) GetLoadedCRDs ¶
func (fb *FilesystemBackend) GetLoadedCRDs() []string
GetLoadedCRDs returns a list of loaded CRD keys (useful for debugging and monitoring)
Returns:
- []string: List of all loaded CRD keys
func (*FilesystemBackend) GetLoadingStatistics ¶
func (fb *FilesystemBackend) GetLoadingStatistics() map[string]interface{}
GetLoadingStatistics returns detailed statistics about loaded CRDs
Returns:
- map[string]interface{}: Statistics including counts and file information
func (*FilesystemBackend) GetURNTemplate ¶
func (fb *FilesystemBackend) GetURNTemplate(crdName, version string) (string, error)
GetURNTemplate retrieves the URN template from CRD annotations
func (*FilesystemBackend) IsResourceTypeSupported ¶
func (fb *FilesystemBackend) IsResourceTypeSupported(ccrnVersion string) bool
IsResourceTypeSupported checks if a resource type is supported
func (*FilesystemBackend) LoadCRDs ¶
func (fb *FilesystemBackend) LoadCRDs(pattern string) error
LoadCRDs loads CRD definitions from a glob pattern (files or directories) Supports multi-document YAML files separated by "---" (Helm-style)
Parameters:
- pattern: File glob pattern (e.g., "/path/to/crds/*.yaml", "/path/to/file.yaml")
Returns:
- error: Error if critical failure occurs, nil if at least some CRDs loaded successfully
func (*FilesystemBackend) LoadCRDsFromDirectory ¶
func (fb *FilesystemBackend) LoadCRDsFromDirectory(dir string) error
LoadCRDsFromDirectory loads all CRD YAML files from a directory recursively This method searches both the root directory and subdirectories for YAML files
Parameters:
- dir: Directory path to search for CRD files
Returns:
- error: Error if no CRDs could be loaded from the directory
func (*FilesystemBackend) Refresh ¶
func (fb *FilesystemBackend) Refresh() error
Refresh reloads CRD information from previously loaded paths
func (*FilesystemBackend) ValidateResource ¶
func (fb *FilesystemBackend) ValidateResource(namespace string, parsedCCRN *apis.ParsedResource) error
ValidateResource validates a resource against its OpenAPI schema
type KubernetesBackend ¶
type KubernetesBackend struct {
// contains filtered or unexported fields
}
KubernetesBackend implements ValidationBackend using a live Kubernetes cluster
func NewKubernetesBackend ¶
func NewKubernetesBackend(config *rest.Config, log *logrus.Logger, ccrnGroup string) (*KubernetesBackend, error)
NewKubernetesBackend creates a new Kubernetes validation backend
func (*KubernetesBackend) GetCRD ¶
func (kb *KubernetesBackend) GetCRD(crdVersion string) (*apis.CRDInfo, error)
GetCRD retrieves CRD information for a given apiVersion and kind
func (*KubernetesBackend) GetURNTemplate ¶
func (kb *KubernetesBackend) GetURNTemplate(crdName, version string) (string, error)
GetURNTemplate retrieves the URN template from CRD annotations
func (*KubernetesBackend) IsResourceTypeSupported ¶
func (kb *KubernetesBackend) IsResourceTypeSupported(ccrnVersion string) bool
IsResourceTypeSupported checks if a resource type is supported
func (*KubernetesBackend) Refresh ¶
func (kb *KubernetesBackend) Refresh() error
Refresh reloads CRD information from the cluster
func (*KubernetesBackend) StartRefreshLoop ¶
func (kb *KubernetesBackend) StartRefreshLoop(interval time.Duration)
StartRefreshLoop starts a background goroutine to refresh CRDs periodically
func (*KubernetesBackend) ValidateResource ¶
func (kb *KubernetesBackend) ValidateResource(namespace string, parsedCCRN *apis.ParsedResource) error
ValidateResource validates a resource by creating it in the Kubernetes cluster