Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: repo-sync #7

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.5

require (
github.com/ghodss/yaml v1.0.0
github.com/loft-sh/admin-apis v0.0.0-20240814093917-dc663916b354
github.com/loft-sh/agentapi/v4 v4.1.0-alpha.17
github.com/loft-sh/admin-apis v0.0.0-20241127134028-9cfb6b23ec44
github.com/loft-sh/agentapi/v4 v4.2.2-beta.0
github.com/loft-sh/apiserver v0.0.0-20241008120650-f17d504a4d0d
k8s.io/api v0.31.1
k8s.io/apimachinery v0.31.1
Expand Down Expand Up @@ -61,7 +61,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.4 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/loft-sh/admin-apis v0.0.0-20240814093917-dc663916b354 h1:aqT1UeosCYB+3DEzfxW0evhcYHxhoBVAEWtkXLXFimI=
github.com/loft-sh/admin-apis v0.0.0-20240814093917-dc663916b354/go.mod h1:MWczNwKvWssHo1KaeZKaWDdRLYSNbWqQBGsTLoCNd7U=
github.com/loft-sh/agentapi/v4 v4.1.0-alpha.17 h1:yoTwfLkurXmA7ENb8YWQePIVK42vZVSeV4unngNc8c8=
github.com/loft-sh/agentapi/v4 v4.1.0-alpha.17/go.mod h1:CXweRDab9ZcSzcaitULFagYGgSzW8Q12W3cBdKMjR8k=
github.com/loft-sh/admin-apis v0.0.0-20241127134028-9cfb6b23ec44 h1:Sq6qEsKSiZHYTzWbnFvnWrzMBFIC3XxFoXtnHdJE9P8=
github.com/loft-sh/admin-apis v0.0.0-20241127134028-9cfb6b23ec44/go.mod h1:MWczNwKvWssHo1KaeZKaWDdRLYSNbWqQBGsTLoCNd7U=
github.com/loft-sh/agentapi/v4 v4.2.2-beta.0 h1:5WNUioE4XMEelkmngHqWqWTLz9vonVJd64HJEi9zA8Q=
github.com/loft-sh/agentapi/v4 v4.2.2-beta.0/go.mod h1:np3oo4gi1fYJvhXAYLk+SY6bVy2iqsxoAf8ebZNMnXU=
github.com/loft-sh/apiserver v0.0.0-20241008120650-f17d504a4d0d h1:73wE8wtsnJm4bXtFbTDRG1EgN4LonpPdgzF3HFhP7kA=
github.com/loft-sh/apiserver v0.0.0-20241008120650-f17d504a4d0d/go.mod h1:jmxtfco3FHrInOVcVcUH0TjE76M6bsNgin5B+84D7IQ=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
Expand All @@ -135,8 +135,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA=
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/management/install/zz_generated.api.register.go

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

11 changes: 10 additions & 1 deletion pkg/apis/management/v1/cluster_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1

import (
agentstoragev1 "github.com/loft-sh/agentapi/v4/pkg/apis/loft/storage/v1"
storagev1 "github.com/loft-sh/api/v4/pkg/apis/storage/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -16,7 +17,7 @@ import (

// Cluster holds the cluster information
// +k8s:openapi-gen=true
// +resource:path=clusters,rest=ClusterREST
// +resource:path=clusters,rest=ClusterREST,statusRest=ClusterStatusREST
// +subresource:request=ClusterMemberAccess,path=memberaccess,kind=ClusterMemberAccess,rest=ClusterMemberAccessREST
// +subresource:request=ClusterReset,path=reset,kind=ClusterReset,rest=ClusterResetREST
// +subresource:request=ClusterDomain,path=domain,kind=ClusterDomain,rest=ClusterDomainREST
Expand Down Expand Up @@ -63,3 +64,11 @@ func (a *Cluster) GetAccess() []storagev1.Access {
func (a *Cluster) SetAccess(access []storagev1.Access) {
a.Spec.Access = access
}

func (a *Cluster) GetConditions() agentstoragev1.Conditions {
return a.Status.Conditions
}

func (a *Cluster) SetConditions(conditions agentstoragev1.Conditions) {
a.Status.Conditions = conditions
}
80 changes: 80 additions & 0 deletions pkg/apis/management/v1/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ type ConfigStatus struct {

// DisableLoftConfigEndpoint will disable setting config via the UI and config.management.loft.sh endpoint
DisableConfigEndpoint bool `json:"disableConfigEndpoint,omitempty"`

// Cloud holds the settings to be used exclusively in vCluster Cloud based
// environments and deployments.
Cloud *Cloud `json:"cloud,omitempty"`

// CostControl holds the settings related to the Cost Control ROI dashboard and its metrics gathering infrastructure
CostControl *CostControl `json:"costControl,omitempty"`
}

// Audit holds the audit configuration options for loft. Changing any options will require a loft restart
Expand Down Expand Up @@ -692,3 +699,76 @@ type AuthenticationOIDC struct {
// +optional
Type string `json:"type,omitempty"`
}

type Cloud struct {
// ReleaseChannel specifies the release channel for the cloud configuration.
// This can be used to determine which updates or versions are applied.
ReleaseChannel string `json:"releaseChannel,omitempty"`

// MaintenanceWindow specifies the maintenance window for the cloud configuration.
// This is a structured representation of the time window during which maintenance can occur.
MaintenanceWindow MaintenanceWindow `json:"maintenanceWindow,omitempty"`
}

type MaintenanceWindow struct {
// DayOfWeek specifies the day of the week for the maintenance window.
// It should be a string representing the day, e.g., "Monday", "Tuesday", etc.
DayOfWeek string `json:"dayOfWeek,omitempty"`

// TimeWindow specifies the time window for the maintenance.
// It should be a string representing the time range in 24-hour format, in UTC, e.g., "02:00-03:00".
TimeWindow string `json:"timeWindow,omitempty"`
}

type CostControl struct {
// Enabled specifies whether the ROI dashboard should be available in the UI, and if the metrics infrastructure
// that provides dashboard data is deployed
Enabled *bool `json:"enabled,omitempty"`

// Global are settings for globally managed components
Global CostControlGlobalConfig `json:"global,omitempty"`

// Cluster are settings for each cluster's managed components. These settings apply to all connected clusters
// unless overridden by modifying the Cluster's spec
Cluster CostControlClusterConfig `json:"cluster,omitempty"`

// Settings specify price-related settings that are taken into account for the ROI dashboard calculations.
Settings *CostControlSettings `json:"settings,omitempty"`
}

type CostControlGlobalConfig struct {
// Metrics these settings apply to metric infrastructure used to aggregate metrics across all connected clusters
Metrics *storagev1.Metrics `json:"metrics,omitempty"`
}

type CostControlClusterConfig struct {
// Metrics are settings applied to metric infrastructure in each connected cluster. These can be overridden in
// individual clusters by modifying the Cluster's spec
Metrics *storagev1.Metrics `json:"metrics,omitempty"`

// OpenCost are settings applied to OpenCost deployments in each connected cluster. These can be overridden in
// individual clusters by modifying the Cluster's spec
OpenCost *storagev1.OpenCost `json:"opencost,omitempty"`
}

type CostControlSettings struct {
// PriceCurrency specifies the currency.
PriceCurrency string `json:"priceCurrency,omitempty"`

// AvgCPUPricePerNode specifies the average CPU price per node.
AvgCPUPricePerNode *CostControlResourcePrice `json:"averageCPUPricePerNode,omitempty"`

// AvgRAMPricePerNode specifies the average RAM price per node.
AvgRAMPricePerNode *CostControlResourcePrice `json:"averageRAMPricePerNode,omitempty"`

// ControlPlanePricePerCluster specifies the price of one physical cluster.
ControlPlanePricePerCluster *CostControlResourcePrice `json:"controlPlanePricePerCluster,omitempty"`
}

type CostControlResourcePrice struct {
// Price specifies the price.
Price float64 `json:"price,omitempty"`

// TimePeriod specifies the time period for the price.
TimePeriod string `json:"timePeriod,omitempty"`
}
26 changes: 11 additions & 15 deletions pkg/apis/management/v1/devpodenvironmenttemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@ type DevPodEnvironmentTemplateSpec struct {
storagev1.DevPodEnvironmentTemplateSpec `json:",inline"`
}

// GitEnvironmentTemplate stores configuration of Git environment template source
type GitEnvironmentTemplate struct {
// Repository stores repository URL for Git environment spec source
Repository string `json:"repository"`

// Revision stores revision to checkout in repository
// +optional
Revision string `json:"revision,omitempty"`

// SubPath stores subpath within Repositor where environment spec is
// +optional
SubPath string `json:"subpath,omitempty"`
// DevPodEnvironmentTemplateStatus holds the status
type DevPodEnvironmentTemplateStatus struct{}

func (a *DevPodEnvironmentTemplate) GetVersions() []storagev1.VersionAccessor {
var retVersions []storagev1.VersionAccessor
for _, v := range a.Spec.Versions {
b := v
retVersions = append(retVersions, &b)
}

return retVersions
}

func (a *DevPodEnvironmentTemplate) GetOwner() *storagev1.UserOrTeam {
Expand All @@ -55,6 +54,3 @@ func (a *DevPodEnvironmentTemplate) GetAccess() []storagev1.Access {
func (a *DevPodEnvironmentTemplate) SetAccess(access []storagev1.Access) {
a.Spec.Access = access
}

// DevPodEnvironmentTemplateStatus holds the status
type DevPodEnvironmentTemplateStatus struct{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package v1

import (
storagev1 "github.com/loft-sh/api/v4/pkg/apis/storage/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +subresource-request
type DevPodWorkspaceInstanceTroubleshoot struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// State holds the workspaces state as given by 'devpod export'
// +optional
State string `json:"state,omitempty"`

// Workspace holds the workspace's instance object data
// +optional
Workspace *DevPodWorkspaceInstance `json:"workspace,omitempty"`

// Template holds the workspace instance's template used to create it.
// This is the raw template, not the rendered one.
// +optional
Template *storagev1.DevPodWorkspaceTemplate `json:"template,omitempty"`

// Pods is a list of pod objects that are linked to the workspace.
// +optional
Pods []corev1.Pod `json:"pods,omitempty"`

// PVCs is a list of PVC objects that are linked to the workspace.
// +optional
PVCs []corev1.PersistentVolumeClaim `json:"pvcs,omitempty"`

// Errors is a list of errors that occurred while trying to collect
// informations for troubleshooting.
// +optional
Errors []string `json:"errors,omitempty"`
}
2 changes: 2 additions & 0 deletions pkg/apis/management/v1/devpodworkspaceinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// +genclient:noStatus
// +genclient:method=GetState,verb=get,subresource=state,result=github.com/loft-sh/api/v4/pkg/apis/management/v1.DevPodWorkspaceInstanceState
// +genclient:method=SetState,verb=create,subresource=state,input=github.com/loft-sh/api/v4/pkg/apis/management/v1.DevPodWorkspaceInstanceState,result=github.com/loft-sh/api/v4/pkg/apis/management/v1.DevPodWorkspaceInstanceState
// +genclient:method=Troubleshoot,verb=get,subresource=troubleshoot,result=github.com/loft-sh/api/v4/pkg/apis/management/v1.DevPodWorkspaceInstanceTroubleshoot
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// DevPodWorkspaceInstance holds the DevPodWorkspaceInstance information
Expand All @@ -22,6 +23,7 @@ import (
// +subresource:request=DevPodStopOptions,path=stop,kind=DevPodStopOptions,rest=DevPodStopOptionsREST
// +subresource:request=DevPodStatusOptions,path=getstatus,kind=DevPodStatusOptions,rest=DevPodStatusOptionsREST
// +subresource:request=DevPodWorkspaceInstanceState,path=state,kind=DevPodWorkspaceInstanceState,rest=DevPodWorkspaceInstanceStateREST
// +subresource:request=DevPodWorkspaceInstanceTroubleshoot,path=troubleshoot,kind=DevPodWorkspaceInstanceTroubleshoot,rest=DevPodWorkspaceInstanceTroubleshootREST
type DevPodWorkspaceInstance struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
51 changes: 51 additions & 0 deletions pkg/apis/management/v1/devpodworkspacepreset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package v1

import (
storagev1 "github.com/loft-sh/api/v4/pkg/apis/storage/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// DevPodWorkspacePreset
// +k8s:openapi-gen=true
// +resource:path=devpodworkspacepresets,rest=DevPodWorkspacePresetREST
type DevPodWorkspacePreset struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec DevPodWorkspacePresetSpec `json:"spec,omitempty"`
Status DevPodWorkspacePresetStatus `json:"status,omitempty"`
}

// DevPodWorkspacePresetSpec holds the specification
type DevPodWorkspacePresetSpec struct {
storagev1.DevPodWorkspacePresetSpec `json:",inline"`
}

// DevPodWorkspacePresetSource
// +k8s:openapi-gen=true
type DevPodWorkspacePresetSource struct {
storagev1.DevPodWorkspacePresetSource `json:",inline"`
}

func (a *DevPodWorkspacePreset) GetOwner() *storagev1.UserOrTeam {
return a.Spec.Owner
}

func (a *DevPodWorkspacePreset) SetOwner(userOrTeam *storagev1.UserOrTeam) {
a.Spec.Owner = userOrTeam
}

func (a *DevPodWorkspacePreset) GetAccess() []storagev1.Access {
return a.Spec.Access
}

func (a *DevPodWorkspacePreset) SetAccess(access []storagev1.Access) {
a.Spec.Access = access
}

// DevPodWorkspacePresetStatus holds the status
type DevPodWorkspacePresetStatus struct{}
3 changes: 3 additions & 0 deletions pkg/apis/management/v1/project_templates_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type ProjectTemplates struct {
// DevPodEnvironmentTemplates holds all the allowed environment templates
DevPodEnvironmentTemplates []DevPodEnvironmentTemplate `json:"devPodEnvironmentTemplates,omitempty"`

// DevPodWorkspacePresets holds all the allowed workspace presets
DevPodWorkspacePresets []DevPodWorkspacePreset `json:"devPodWorkspacePresets,omitempty"`

// DefaultDevPodEnvironmentTemplate
DefaultDevPodEnvironmentTemplate string `json:"defaultDevPodEnvironmentTemplate,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package v1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// VirtualClusterExternalDatabase holds kube config request and response data for virtual clusters
// +subresource-request
type VirtualClusterExternalDatabase struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec VirtualClusterExternalDatabaseSpec `json:"spec,omitempty"`
Status VirtualClusterExternalDatabaseStatus `json:"status,omitempty"`
}

type VirtualClusterExternalDatabaseSpec struct {
// Connector specifies the secret that should be used to connect to an external database server. The connection is
// used to manage a user and database for the vCluster. A data source endpoint constructed from the created user and
// database is returned on status. The secret specified by connector should contain the following fields:
// endpoint - the endpoint where the database server can be accessed
// user - the database username
// password - the password for the database username
// port - the port to be used in conjunction with the endpoint to connect to the databse server. This is commonly
// 3306
// +optional
Connector string `json:"connector,omitempty"`
}

type VirtualClusterExternalDatabaseStatus struct {
// DataSource holds a datasource endpoint constructed from the vCluster's designated user and database. The user and
// database are created from the given connector.
DataSource string `json:"dataSource,omitempty"`
}
2 changes: 2 additions & 0 deletions pkg/apis/management/v1/virtualclusterinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// +genclient:noStatus
// +genclient:method=GetKubeConfig,verb=create,subresource=kubeconfig,input=github.com/loft-sh/api/v4/pkg/apis/management/v1.VirtualClusterInstanceKubeConfig,result=github.com/loft-sh/api/v4/pkg/apis/management/v1.VirtualClusterInstanceKubeConfig
// +genclient:method=GetAccessKey,verb=get,subresource=accesskey,result=github.com/loft-sh/api/v4/pkg/apis/management/v1.VirtualClusterAccessKey
// +genclient:method=GetExternalDatabase,verb=create,subresource=externaldatabase,input=github.com/loft-sh/api/v4/pkg/apis/management/v1.VirtualClusterExternalDatabase,result=github.com/loft-sh/api/v4/pkg/apis/management/v1.VirtualClusterExternalDatabase
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// VirtualClusterInstance holds the VirtualClusterInstance information
Expand All @@ -19,6 +20,7 @@ import (
// +subresource:request=VirtualClusterInstanceLog,path=log,kind=VirtualClusterInstanceLog,rest=VirtualClusterInstanceLogREST
// +subresource:request=VirtualClusterInstanceKubeConfig,path=kubeconfig,kind=VirtualClusterInstanceKubeConfig,rest=VirtualClusterInstanceKubeConfigREST
// +subresource:request=VirtualClusterAccessKey,path=accesskey,kind=VirtualClusterAccessKey,rest=VirtualClusterAccessKeyREST
// +subresource:request=VirtualClusterExternalDatabase,path=externaldatabase,kind=VirtualClusterExternalDatabase,rest=VirtualClusterExternalDatabaseREST
type VirtualClusterInstance struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
Loading