api

package
v0.0.0-...-460f0ae Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorType = "Error"

ErrorType is the name of the type used to report errors.

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 GetOpenAPISpec

func GetOpenAPISpec() ([]byte, error)

GetOpenAPISpec returns the embedded OpenAPI YAML file contents

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 with some details about the non existing resource.

func SendPanic

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

SendPanic sends a panic error response to the client, but it doesn't end the process.

func SendUnauthorized

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

Types

type AdapterCondition

type AdapterCondition struct {
	Type               string          `json:"type"`
	Status             ConditionStatus `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 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 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:63;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 fields (expanded to database columns)
	StatusPhase              string         `json:"status_phase" gorm:"default:'NotReady'"`
	StatusLastTransitionTime *time.Time     `json:"status_last_transition_time,omitempty"`
	StatusObservedGeneration int32          `json:"status_observed_generation" gorm:"default:0"`
	StatusLastUpdatedTime    *time.Time     `json:"status_last_updated_time,omitempty"`
	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 ConditionStatus

type ConditionStatus string

ConditionStatus represents the status of a condition Domain equivalent of openapi.ConditionStatus

const (
	ConditionTrue    ConditionStatus = "True"    // String value matches openapi.TRUE
	ConditionFalse   ConditionStatus = "False"   // String value matches openapi.FALSE
	ConditionUnknown ConditionStatus = "Unknown" // String value matches openapi.UNKNOWN
)

type Error

type Error struct {
	Type   string `json:"type,omitempty"`
	ID     string `json:"id,omitempty"`
	HREF   string `json:"href,omitempty"`
	Code   string `json:"code,omitempty"`
	Reason string `json:"reason,omitempty"`
}

Error represents an error reported by the API.

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:255;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 fields (expanded)
	StatusPhase              string         `json:"status_phase" gorm:"default:'NotReady'"`
	StatusObservedGeneration int32          `json:"status_observed_generation" gorm:"default:0"`
	StatusLastTransitionTime *time.Time     `json:"status_last_transition_time,omitempty"`
	StatusLastUpdatedTime    *time.Time     `json:"status_last_updated_time,omitempty"`
	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             ConditionStatus `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 ResourcePhase

type ResourcePhase string

ResourcePhase represents the lifecycle phase of a resource Domain equivalent of openapi.ResourcePhase

const (
	PhaseNotReady ResourcePhase = "NotReady" // String value matches openapi.NOT_READY
	PhaseReady    ResourcePhase = "Ready"    // String value matches openapi.READY
	PhaseFailed   ResourcePhase = "Failed"   // String value matches openapi.FAILED
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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