api

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildTime = "unknown"

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

View Source
var Version = "unknown"

Version is the application version set at compile time via ldflags

Functions

func NewID

func NewID() string

NewID generates a new unique identifier using KSUID with lowercase Base32 encoding. The resulting 32-character lowercase string is compatible with Kubernetes DNS-1123 subdomain naming requirements, making it suitable for use as Kubernetes resource names and labels. The KSUID provides time-based ordering (second precision) and global uniqueness without requiring a central server.

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 SendUnauthorized

func SendUnauthorized(w http.ResponseWriter, r *http.Request, message string)

SendUnauthorized sends a 401 response in RFC 9457 Problem Details format.

Types

type AdapterCondition

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

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"
)

type AdapterStatus

type AdapterStatus struct {
	Meta // Contains ID, CreatedTime, UpdatedTime, DeletedAt

	// Polymorphic association
	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 information
	Adapter            string `json:"adapter" gorm:"size:255;not null;uniqueIndex:idx_resource_adapter"`
	ObservedGeneration int32  `json:"observed_generation" gorm:"not null"`

	// API-managed timestamps
	LastReportTime *time.Time `json:"last_report_time" gorm:"not null"` // Updated on every POST
	CreatedTime    *time.Time `json:"created_time" gorm:"not null"`     // Set on first creation

	// Stored as JSON
	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"`
}

AdapterStatus database model

func (*AdapterStatus) BeforeCreate

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

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 Cluster

type Cluster struct {
	Meta // Contains ID, CreatedTime, UpdatedTime, DeletedTime

	// Core fields
	Kind   string         `json:"kind" gorm:"default:'Cluster'"`
	Name   string         `json:"name" gorm:"uniqueIndex;size:53;not null"`
	Spec   datatypes.JSON `json:"spec" gorm:"type:jsonb;not null"`
	Labels datatypes.JSON `json:"labels,omitempty" gorm:"type:jsonb"`
	Href   string         `json:"href,omitempty" gorm:"size:500"`

	// Version control
	Generation int32 `json:"generation" gorm:"default:1;not null"`

	// Status (conditions-only model with synthetic Available/Ready conditions)
	StatusConditions datatypes.JSON `json:"status_conditions" gorm:"type:jsonb"`

	// Audit fields
	CreatedBy string `json:"created_by" gorm:"size:255;not null"`
	UpdatedBy string `json:"updated_by" gorm:"size:255;not null"`
}

Cluster database model

func (*Cluster) BeforeCreate

func (c *Cluster) BeforeCreate(tx *gorm.DB) error

func (*Cluster) BeforeUpdate

func (c *Cluster) BeforeUpdate(tx *gorm.DB) error

type ClusterIndex

type ClusterIndex map[string]*Cluster

type ClusterList

type ClusterList []*Cluster

func (ClusterList) Index

func (l ClusterList) Index() ClusterIndex

type ClusterPatchRequest

type ClusterPatchRequest struct {
	Spec   *map[string]interface{} `json:"spec,omitempty"`
	Labels *map[string]string      `json:"labels,omitempty"`
}

type Meta

type Meta struct {
	ID          string
	CreatedTime time.Time
	UpdatedTime time.Time
	DeletedAt   gorm.DeletedAt `gorm:"index"`
}

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 NodePool

type NodePool struct {
	Meta // Contains ID, CreatedTime, UpdatedTime, DeletedAt

	// Core fields
	Kind   string         `json:"kind" gorm:"default:'NodePool'"`
	Name   string         `json:"name" gorm:"size:15;not null"`
	Spec   datatypes.JSON `json:"spec" gorm:"type:jsonb;not null"`
	Labels datatypes.JSON `json:"labels,omitempty" gorm:"type:jsonb"`
	Href   string         `json:"href,omitempty" gorm:"size:500"`

	// Version control
	Generation int32 `json:"generation" gorm:"default:1;not null"`

	// Owner references (expanded)
	OwnerID   string `json:"owner_id" gorm:"size:255;not null;index"`
	OwnerKind string `json:"owner_kind" gorm:"size:50;not null"`
	OwnerHref string `json:"owner_href,omitempty" gorm:"size:500"`

	// Foreign key relationship
	Cluster *Cluster `gorm:"foreignKey:OwnerID;references:ID"`

	// Status (conditions-only model with synthetic Available/Ready conditions)
	StatusConditions datatypes.JSON `json:"status_conditions" gorm:"type:jsonb"`

	// Audit fields
	CreatedBy string `json:"created_by" gorm:"size:255;not null"`
	UpdatedBy string `json:"updated_by" gorm:"size:255;not null"`
}

NodePool database model

func (*NodePool) BeforeCreate

func (np *NodePool) BeforeCreate(tx *gorm.DB) error

func (*NodePool) BeforeUpdate

func (np *NodePool) BeforeUpdate(tx *gorm.DB) error

type NodePoolIndex

type NodePoolIndex map[string]*NodePool

type NodePoolList

type NodePoolList []*NodePool

func (NodePoolList) Index

func (l NodePoolList) Index() NodePoolIndex

type NodePoolPatchRequest

type NodePoolPatchRequest struct {
	Spec   *map[string]interface{} `json:"spec,omitempty"`
	Labels *map[string]string      `json:"labels,omitempty"`
}

type PagingMeta

type PagingMeta struct {
	Page  int
	Size  int64
	Total int64
}

PagingMeta List Paging metadata

type ResourceCondition

type ResourceCondition struct {
	ObservedGeneration int32                   `json:"observed_generation"`
	CreatedTime        time.Time               `json:"created_time"`
	LastUpdatedTime    time.Time               `json:"last_updated_time"`
	Type               string                  `json:"type"`
	Status             ResourceConditionStatus `json:"status"`
	Reason             *string                 `json:"reason,omitempty"`
	Message            *string                 `json:"message,omitempty"`
	LastTransitionTime time.Time               `json:"last_transition_time"`
}

ResourceCondition represents a condition of a resource Domain equivalent of openapi.ResourceCondition JSON tags match database JSONB structure

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
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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