Skip to content

Commit

Permalink
Migrate QdrantCloudRegions CRD (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
bashofmann authored Aug 30, 2024
1 parent 20d8144 commit 0b80b66
Show file tree
Hide file tree
Showing 6 changed files with 2,224 additions and 0 deletions.
137 changes: 137 additions & 0 deletions api/v1/region_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package v1

import (
helmapi "github.com/fluxcd/helm-controller/api/v2beta2"
srcapi "github.com/fluxcd/source-controller/api/v1beta2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
KindQdrantCloudRegion = "QdrantCloudRegion"
ResourceQdrantCloudRegion = "qdrantcloudregions"
)

// QdrantCloudRegionSpec defines the desired state of QdrantCloudRegion
type QdrantCloudRegionSpec struct {
// Id specifies the unique identifier of the region
Id string `json:"id,omitempty"`
// HelmRepositories specifies the list of helm repositories to be created to the region
// +optional
HelmRepositories []HelmRepository `json:"helmRepositories,omitempty"`
// HelmReleases specifies the list of helm releases to be created to the region
// +optional
HelmReleases []HelmRelease `json:"helmReleases,omitempty"`
}

type HelmRepository struct {
// MarkedForDeletionAt specifies the time when the helm repository was marked for deletion
// +optional
MarkedForDeletionAt *string `json:"markedForDeletionAt,omitempty"`
// Object specifies the helm repository object
// +kubebuilder:validation:EmbeddedResource
Object *srcapi.HelmRepository `json:"object,omitempty"`
}

type HelmRelease struct {
// MarkedForDeletionAt specifies the time when the helm release was marked for deletion
// +optional
MarkedForDeletionAt *string `json:"markedForDeletionAt,omitempty"`
// Object specifies the helm release object
// +kubebuilder:validation:EmbeddedResource
Object *helmapi.HelmRelease `json:"object,omitempty"`
}

type RegionPhase string

const (
RegionPhaseReady RegionPhase = "Ready"
RegionPhaseNotReady RegionPhase = "NotReady"
FailedToSync RegionPhase = "FailedToSync"
)

type QdrantCloudRegionStatus struct {
// Phase specifies the current phase of the region
// +optional
Phase RegionPhase `json:"phase,omitempty"`
// KubernetesVersion specifies the version of the Kubernetes cluster
// +optional
KubernetesVersion string `json:"k8sVersion,omitempty"`
// NumberOfNodes specifies the number of nodes in the Kubernetes cluster
// +optional
NumberOfNodes int `json:"numberOfNodes,omitempty"`
// Capabilities specifies the capabilities of the Kubernetes cluster
// +optional
Capabilities *RegionCapabilities `json:"capabilities,omitempty"`
// HelmRepositories specifies the status of the helm repositories
// +optional
HelmRepositories []ComponentStatus `json:"helmRepositories,omitempty"`
// HelmReleases specifies the status of the helm releases
// +optional
HelmReleases []ComponentStatus `json:"helmReleases,omitempty"`
// Message specifies the info explaining the current phase of the region
// +optional
Message string `json:"message,omitempty"`
}

type RegionCapabilities struct {
// VolumeSnapshot specifies whether the Kubernetes cluster supports volume snapshot
// +optional
VolumeSnapshot *bool `json:"volumeSnapshot,omitempty"`
// VolumeExpansion specifies whether the Kubernetes cluster supports volume expansion
// +optional
VolumeExpansion *bool `json:"volumeExpansion,omitempty"`
}

type ComponentPhase string

const (
ComponentPhaseReady ComponentPhase = "Ready"
ComponentPhaseNotReady ComponentPhase = "NotReady"
ComponentPhaseUnknown ComponentPhase = "Unknown"
ComponentPhaseNotFound ComponentPhase = "NotFound"
)

type ComponentStatus struct {
// Name specifies the name of the component
Name string `json:"name"`
// Namespace specifies the namespace of the component
Namespace string `json:"namespace,omitempty"`
// Version specifies the version of the component
// +optional
Version string `json:"version,omitempty"`
// Phase specifies the current phase of the component
Phase ComponentPhase `json:"phase,omitempty"`
// Message specifies the info explaining the current phase of the component
// +optional
Message string `json:"message,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:resource:path=qdrantcloudregions,scope=Cluster,singular=qdrantcloudregion,shortName=region;regions
// +kubebuilder:printcolumn:name="K8s Version",type=string,JSONPath=`.status.k8sVersion`
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

// QdrantCloudRegion is the Schema for the qdrantcloudregions API
type QdrantCloudRegion struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec QdrantCloudRegionSpec `json:"spec,omitempty"`
Status QdrantCloudRegionStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// QdrantCloudRegionList contains a list of QdrantCloudRegion
type QdrantCloudRegionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []QdrantCloudRegion `json:"items"`
}

func init() {
SchemeBuilder.Register(&QdrantCloudRegion{}, &QdrantCloudRegionList{})
}
210 changes: 210 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0b80b66

Please sign in to comment.