Documentation ¶
Index ¶
- func ErrApiVersion(apiVersion APIVersion, kind Kind) error
- func ErrKind(kind Kind) error
- func ErrReference(reference string, kind Kind) error
- func RegexAPIVersion() string
- func RegexAPIVersionAndKind() string
- func RegexKind() string
- func RegexKindLowered() string
- func RegexResourceName() string
- func ToPointer[T any](t T) *T
- func ValidateAPIVersionPtr(ptr *APIVersion) error
- func ValidateResourceName(s string) error
- func ValidateResourceNamePtr(ptr *string) error
- func WriteEncodedFile(path string, v *ResourceDefinition) error
- type APIKind
- type APIServer
- type APIVersion
- type Encoder
- type Encoding
- type FilesystemOperator
- type GitOperator
- type JSONStrategy
- type Kind
- type Metadata
- type Operator
- type OperatorStrategy
- type ResourceDefinition
- type YAMLStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrApiVersion ¶
func ErrApiVersion(apiVersion APIVersion, kind Kind) error
func ErrReference ¶
func RegexAPIVersion ¶
func RegexAPIVersion() string
func RegexAPIVersionAndKind ¶
func RegexAPIVersionAndKind() string
func RegexKindLowered ¶
func RegexKindLowered() string
func RegexResourceName ¶
func RegexResourceName() string
func ValidateAPIVersionPtr ¶
func ValidateAPIVersionPtr(ptr *APIVersion) error
func ValidateResourceName ¶
func ValidateResourceNamePtr ¶
func WriteEncodedFile ¶
func WriteEncodedFile(path string, v *ResourceDefinition) error
Types ¶
type APIKind ¶
type APIKind interface { APIVersion() APIVersion Kind() Kind Operator() Operator }
func NewAPIKind ¶
func NewAPIKind(apiVersion APIVersion, kind Kind, operator Operator) APIKind
type APIServer ¶
type APIServer interface { // Register a new APIKind to the APIServer Register(apiKind APIKind) error // Unregister an APIKind from the APIServer Unregister(apiVersion APIVersion, kind Kind) error // Get existing resources by Kind and optionally by APIVersion and/or name // Please set APIVersion & name to nil if you don't need to filter Get(apiVersion *APIVersion, kind Kind, name *string) ([]ResourceDefinition, error) // Create a new resource definition Create(resource *ResourceDefinition) error // Update an existing resource definition or creates it Update(apiVersion *APIVersion, kind Kind, name string, resource *ResourceDefinition) error // Delete by kind & name. Optional apiVersion. Delete(apiVersion *APIVersion, kind Kind, name string) error }
func NewAPIServer ¶
func NewAPIServer() APIServer
type APIVersion ¶
type APIVersion string
func (APIVersion) ToLower ¶
func (v APIVersion) ToLower() APIVersion
func (APIVersion) Validate ¶
func (v APIVersion) Validate() (APIVersion, error)
type Encoder ¶
type Encoder interface { Marshal(v *ResourceDefinition) ([]byte, error) Unmarshal([]byte) (*ResourceDefinition, error) Encoding() Encoding }
func NewEncoder ¶
func NewEncoderFromFilepath ¶
type FilesystemOperator ¶
type FilesystemOperator struct {
// contains filtered or unexported fields
}
FilesystemOperator operates T through the filesystem. Resources are stored on the filesystem using the following convention: - Filename: {{ T.APIVersion() }}.{{ T.Kind() }}.{{ T.IMetadata().Name }}. {{ s.encoder.Encoding() }}
func NewFilesystemOperator ¶
func NewFilesystemOperator(apiVersion APIVersion, kind Kind, resourceDir string, encoding Encoding) (*FilesystemOperator, error)
NewFilesystemOperator instantiate a new strategy
func (*FilesystemOperator) Create ¶
func (s *FilesystemOperator) Create(t *ResourceDefinition) error
Create should create only if file does not already exist.
func (*FilesystemOperator) Delete ¶
func (s *FilesystemOperator) Delete(name string) error
func (*FilesystemOperator) Get ¶
func (s *FilesystemOperator) Get(name *string) ([]ResourceDefinition, error)
func (*FilesystemOperator) Update ¶
func (s *FilesystemOperator) Update(name *string, v *ResourceDefinition) error
type GitOperator ¶
type GitOperator struct {
// contains filtered or unexported fields
}
GitOperator uses FilesystemStrategy as a backend, and leverages Git for version control.
type JSONStrategy ¶
type JSONStrategy struct{}
func (*JSONStrategy) Encoding ¶
func (s *JSONStrategy) Encoding() Encoding
func (*JSONStrategy) Marshal ¶
func (s *JSONStrategy) Marshal(v *ResourceDefinition) ([]byte, error)
func (*JSONStrategy) Unmarshal ¶
func (s *JSONStrategy) Unmarshal(data []byte) (*ResourceDefinition, error)
type Metadata ¶
type Metadata struct { Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"` Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` Name string `json:"name" yaml:"name"` }
func NewMetadata ¶
type Operator ¶
type Operator interface { Get(name *string) ([]ResourceDefinition, error) Create(*ResourceDefinition) error Update(name *string, v *ResourceDefinition) error Delete(name string) error }
func NewOperator ¶
func NewOperator(strategy OperatorStrategy, options ...any) (Operator, error)
type OperatorStrategy ¶
type OperatorStrategy string
const ( FileSystemOperatorStrategy OperatorStrategy = "filesystem" GitOperatorStrategy OperatorStrategy = "git" )
type ResourceDefinition ¶
type ResourceDefinition struct { APIVersion APIVersion `json:"apiVersion" yaml:"apiVersion"` Kind Kind `json:"kind" yaml:"kind"` Metadata Metadata `json:"metadata" yaml:"metadata"` Spec interface{} `json:"spec" yaml:"spec"` }
func NewResourceDefinition ¶
func NewResourceDefinition(apiVersion APIVersion, kind Kind, name string, spec interface{}) *ResourceDefinition
func ReadEncodedFile ¶
func ReadEncodedFile(path string) (*ResourceDefinition, error)
type YAMLStrategy ¶
type YAMLStrategy struct{}
func (*YAMLStrategy) Encoding ¶
func (s *YAMLStrategy) Encoding() Encoding
func (*YAMLStrategy) Marshal ¶
func (s *YAMLStrategy) Marshal(v *ResourceDefinition) ([]byte, error)
func (*YAMLStrategy) Unmarshal ¶
func (s *YAMLStrategy) Unmarshal(data []byte) (*ResourceDefinition, error)
Click to show internal directories.
Click to hide internal directories.