api

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLabelKeyLen   = 255
	MaxLabelValueLen = 255
)
View Source
const (
	ResourceTypeCluster  = "Cluster"
	ResourceTypeNodePool = "NodePool"
)

Resource type constants

View Source
const (
	AdapterConditionTypeAvailable  = "Available"
	AdapterConditionTypeApplied    = "Applied"
	AdapterConditionTypeHealth     = "Health"
	AdapterConditionTypeReconciled = "Reconciled"
	AdapterConditionTypeFinalized  = "Finalized"
)

Adapter condition type constants (used in adapter.conditions reported by adapters)

View Source
const (
	ResourceConditionTypeAvailable           = "Available"
	ResourceConditionTypeHealth              = "Health"
	ResourceConditionTypeReconciled          = "Reconciled"
	ResourceConditionTypeFinalized           = "Finalized"
	ResourceConditionTypeLastKnownReconciled = "LastKnownReconciled"
)

Resource condition type constants (used in resource.status.conditions aggregated from adapters)

Variables

View Source
var BuildTime = "unknown"

BuildTime is the time when the binary was built, set at compile time via ldflags

View Source
var Commit = "unknown"

Commit is the git commit SHA set at compile time via ldflags

View Source
var Version = "0.0.0-dev"

Version is the application version set at compile time via ldflags

Functions

func NewID

func NewID() (string, error)

NewID generates a new RFC4122 UUID v7 identifier in lowercase format. UUID v7 embeds a Unix timestamp (millisecond precision) in the first 48 bits, providing time-ordering and improved database index performance. The resulting 36-character string (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) is suitable for use in REST APIs, database storage, and Kubernetes resource names.

The lowercase UUID format is DNS-1123 compliant (contains only a-f, 0-9, and hyphens; starts and ends with alphanumeric; 36 chars < 253 char subdomain limit).

Returns an error if UUID generation fails (extremely unlikely in practice).

func SendNotFound

func SendNotFound(w http.ResponseWriter, r *http.Request)

SendNotFound sends a 404 response in RFC 9457 Problem Details format.

func SendPanic

func SendPanic(w http.ResponseWriter, r *http.Request)

SendPanic sends a panic error response in RFC 9457 Problem Details format. It attempts to include trace_id and timestamp dynamically, falling back to a pre-computed body if marshaling fails.

func ValidateLabel added in v0.3.1

func ValidateLabel(key, value string) error

Types

type AdapterCondition

type AdapterCondition struct {
	LastTransitionTime time.Time              `json:"last_transition_time"`
	Reason             *string                `json:"reason,omitempty"`
	Message            *string                `json:"message,omitempty"`
	Type               string                 `json:"type"`
	Status             AdapterConditionStatus `json:"status"`
}

AdapterCondition represents a condition of an adapter Domain equivalent of openapi.AdapterCondition JSON tags match database JSONB structure

type AdapterConditionStatus

type AdapterConditionStatus string

AdapterConditionStatus represents the status of an adapter condition (includes Unknown) Domain equivalent of openapi.AdapterConditionStatus

const (
	AdapterConditionTrue    AdapterConditionStatus = "True"
	AdapterConditionFalse   AdapterConditionStatus = "False"
	AdapterConditionUnknown AdapterConditionStatus = "Unknown"
)

func (AdapterConditionStatus) IsValid added in v0.3.0

func (s AdapterConditionStatus) IsValid() bool

IsValid returns true if the status is one of the accepted enum values (True, False, Unknown).

type AdapterStatus

type AdapterStatus struct {
	LastReportTime time.Time `json:"last_report_time" gorm:"not null"`
	CreatedTime    time.Time `json:"created_time" gorm:"not null"`
	Meta
	ResourceType       string         `json:"resource_type" gorm:"size:20;index:idx_resource;not null"`
	ResourceID         string         `json:"resource_id" gorm:"size:255;index:idx_resource;not null"`
	Adapter            string         `json:"adapter" gorm:"size:255;not null;uniqueIndex:idx_resource_adapter"`
	Conditions         datatypes.JSON `json:"conditions" gorm:"type:jsonb;not null"`
	Data               datatypes.JSON `json:"data,omitempty" gorm:"type:jsonb"`
	Metadata           datatypes.JSON `json:"metadata,omitempty" gorm:"type:jsonb"`
	ObservedGeneration int32          `json:"observed_generation" gorm:"not null"`
}

AdapterStatus database model

func (*AdapterStatus) BeforeCreate

func (as *AdapterStatus) BeforeCreate(tx *gorm.DB) error

func (*AdapterStatus) IsFinalized added in v0.3.0

func (as *AdapterStatus) IsFinalized() bool

type AdapterStatusIndex

type AdapterStatusIndex map[string]*AdapterStatus

type AdapterStatusList

type AdapterStatusList []*AdapterStatus

func (AdapterStatusList) Index

type AdapterStatusMetadata

type AdapterStatusMetadata struct {
	Attempt       *int32     `json:"attempt,omitempty"`
	CompletedTime *time.Time `json:"completed_time,omitempty"`
	Duration      *string    `json:"duration,omitempty"`
	JobName       *string    `json:"job_name,omitempty"`
	JobNamespace  *string    `json:"job_namespace,omitempty"`
	StartedTime   *time.Time `json:"started_time,omitempty"`
}

type Meta

type Meta struct {
	CreatedTime time.Time
	UpdatedTime time.Time
	ID          string
}

Meta is base model definition, embedded in all kinds

type Metadata

type Metadata struct {
	ID        string `json:"id"`
	HREF      string `json:"href"`
	Kind      string `json:"kind"`
	Version   string `json:"version"`
	BuildTime string `json:"build_time"`
}

Metadata api metadata.

type PagingMeta

type PagingMeta struct {
	Page  int64
	Size  int64
	Total int64
}

PagingMeta List Paging metadata

type ReferenceMap added in v0.3.1

type ReferenceMap = map[string][]openapi.ObjectReference

ReferenceMap is the API-level representation of resource references, keyed by ref type (e.g. "wif_config") with a list of object references per type.

type Resource added in v0.3.0

type Resource struct {
	OwnerID     *string    `json:"owner_id,omitempty" gorm:"size:255"`
	OwnerHref   *string    `json:"owner_href,omitempty" gorm:"size:500"`
	OwnerKind   *string    `json:"owner_kind,omitempty" gorm:"size:100"`
	DeletedBy   *string    `json:"deleted_by,omitempty" gorm:"size:255"`
	DeletedTime *time.Time `json:"deleted_time,omitempty"`
	Meta
	Kind       string              `json:"kind" gorm:"size:100;not null"`
	Name       string              `json:"name" gorm:"size:100;not null"`
	Href       string              `json:"href,omitempty" gorm:"size:500"`
	CreatedBy  string              `json:"created_by" gorm:"size:255;not null"`
	UpdatedBy  string              `json:"updated_by" gorm:"size:255;not null"`
	Labels     []ResourceLabel     `json:"-" gorm:"foreignKey:ResourceID;references:ID"`
	Spec       datatypes.JSON      `json:"spec" gorm:"type:jsonb;not null"`
	Conditions []ResourceCondition `json:"-" gorm:"foreignKey:ResourceID;references:ID"`
	References []ResourceReference `json:"-" gorm:"foreignKey:SourceID;references:ID"`
	Generation int32               `json:"generation" gorm:"default:1;not null"`
}

Resource is the generic GORM model backing all entity types managed by the entity registry — including Cluster, NodePool, Channel, Version, and WifConfig. Entity kinds are differentiated by the Kind field.

func (*Resource) BeforeCreate added in v0.3.0

func (r *Resource) BeforeCreate(tx *gorm.DB) error

func (*Resource) BeforeUpdate added in v0.3.0

func (r *Resource) BeforeUpdate(tx *gorm.DB) error

func (*Resource) IncrementGeneration added in v0.3.0

func (r *Resource) IncrementGeneration()

func (*Resource) MarkDeleted added in v0.3.0

func (r *Resource) MarkDeleted(by string, t time.Time)

func (*Resource) SetOwner added in v0.3.0

func (r *Resource) SetOwner(id, kind, href string)

func (Resource) TableName added in v0.3.0

func (r Resource) TableName() string

type ResourceCondition

type ResourceCondition struct {
	CreatedTime        time.Time               `json:"created_time" gorm:"not null"`
	LastUpdatedTime    time.Time               `json:"last_updated_time" gorm:"not null"`
	LastTransitionTime time.Time               `json:"last_transition_time" gorm:"not null"`
	Reason             *string                 `json:"reason,omitempty" gorm:"type:text"`
	Message            *string                 `json:"message,omitempty" gorm:"type:text"`
	ResourceID         string                  `json:"-" gorm:"primaryKey;size:255;not null"`
	Type               string                  `json:"type" gorm:"primaryKey;size:100;not null"`
	Status             ResourceConditionStatus `json:"status" gorm:"size:10;not null"`
	ObservedGeneration int32                   `json:"observed_generation" gorm:"default:0;not null"`
}

ResourceCondition is the GORM model for the resource_conditions table and the domain type for JSONB deserialization in resources. ResourceID is excluded from JSON to preserve JSONB backward compat.

func (ResourceCondition) TableName added in v0.3.1

func (ResourceCondition) TableName() string

type ResourceConditionStatus

type ResourceConditionStatus string

ResourceConditionStatus represents the status of a resource condition (True/False only) Domain equivalent of openapi.ResourceConditionStatus

const (
	ConditionTrue  ResourceConditionStatus = "True"  // String value matches openapi.TRUE
	ConditionFalse ResourceConditionStatus = "False" // String value matches openapi.FALSE
)

type ResourceLabel added in v0.3.1

type ResourceLabel struct {
	ResourceID string `json:"-" gorm:"primaryKey;size:255;not null"`
	Key        string `json:"key" gorm:"primaryKey;size:255;not null"`
	Value      string `json:"value" gorm:"size:255;not null"`
}

func (ResourceLabel) TableName added in v0.3.1

func (ResourceLabel) TableName() string

type ResourceList added in v0.3.0

type ResourceList []*Resource

type ResourcePatch added in v0.3.1

type ResourcePatch struct {
	Spec       map[string]interface{}
	Labels     map[string]string
	References ReferenceMap
}

type ResourceReference added in v0.3.1

type ResourceReference struct {
	SourceID   string `json:"source_id" gorm:"primaryKey;column:source_id;size:255"`
	RefType    string `json:"ref_type" gorm:"primaryKey;column:ref_type;size:255"`
	TargetID   string `json:"target_id" gorm:"primaryKey;column:target_id;size:255"`
	TargetKind string `json:"target_kind" gorm:"column:target_kind;size:100;not null"`
}

ResourceReference stores a single non-ownership association between two resources. Table: resource_references. Natural composite PK (source_id, ref_type, target_id).

func (ResourceReference) TableName added in v0.3.1

func (ResourceReference) TableName() string

type ResourceSummary added in v0.3.1

type ResourceSummary struct {
	Kind string
	Name string
}

ResourceSummary carries kind + name for error messages (e.g. FindReferencers 409).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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