From 68d6d04817f9661740d8926752ee8312993e34ae Mon Sep 17 00:00:00 2001 From: Samuel K Date: Sun, 18 Oct 2026 13:03:42 -0600 Subject: [PATCH] refactor(platform): rename loft to devsy in pkg/platform --- pkg/platform/annotations/annotations.go | 6 ++--- pkg/platform/client.go | 2 +- pkg/platform/client/client.go | 6 ++--- pkg/platform/client/config.go | 8 +++---- pkg/platform/deploy.go | 32 ++++++++++++------------- pkg/platform/instance.go | 11 +++++---- pkg/platform/kubeconfig.go | 8 +++---- 7 files changed, 37 insertions(+), 36 deletions(-) diff --git a/pkg/platform/annotations/annotations.go b/pkg/platform/annotations/annotations.go index d08c790c72..c70cb844ed 100644 --- a/pkg/platform/annotations/annotations.go +++ b/pkg/platform/annotations/annotations.go @@ -1,5 +1,5 @@ package annotations -// LoftDirectClusterEndpoint is a cluster annotation that tells clients to use this endpoint instead of -// the default loft server address to connect to this cluster. -const LoftDirectClusterEndpoint = "devsy.sh/direct-cluster-endpoint" +// DirectClusterEndpoint is a cluster annotation that tells clients to use this endpoint instead of +// the default devsy server address to connect to this cluster. +const DirectClusterEndpoint = "devsy.sh/direct-cluster-endpoint" diff --git a/pkg/platform/client.go b/pkg/platform/client.go index df2de0eef7..c9e6c6739a 100644 --- a/pkg/platform/client.go +++ b/pkg/platform/client.go @@ -30,7 +30,7 @@ func InitClientFromProvider( ) (client.Client, error) { configPath, err := DevsyConfigPath(devsyConfig.DefaultContext, providerName) if err != nil { - return nil, fmt.Errorf("loft config path: %w", err) + return nil, fmt.Errorf("devsy config path: %w", err) } return client.InitClientFromPath(ctx, configPath) diff --git a/pkg/platform/client/client.go b/pkg/platform/client/client.go index 64e1d0c797..6f77bb7246 100644 --- a/pkg/platform/client/client.go +++ b/pkg/platform/client/client.go @@ -231,7 +231,7 @@ type keyStruct struct { func verifyHost(host string) error { if !strings.HasPrefix(host, "https") { return fmt.Errorf( - "cannot log into a non https loft instance %q, make sure you have TLS enabled", + "cannot log into a non https devsy instance %q, make sure you have TLS enabled", host, ) } @@ -422,7 +422,7 @@ func (c *client) verifyConnection() error { var authErr x509.UnknownAuthorityError if errors.As(urlError.Err, &authErr) { return fmt.Errorf( - "unsafe login endpoint %q, if you wish to login into an insecure loft endpoint run with the '--insecure' flag", + "unsafe login endpoint %q, if you wish to login into an insecure devsy endpoint run with the '--insecure' flag", c.config.Host, ) } @@ -431,7 +431,7 @@ func (c *client) verifyConnection() error { return fmt.Errorf("error logging in: %w", err) } -// VerifyVersion checks if the Loft version is compatible with this CLI version. +// VerifyVersion checks if the Devsy version is compatible with this CLI version. func VerifyVersion(baseClient Client) error { v, err := baseClient.Version() if err != nil { diff --git a/pkg/platform/client/config.go b/pkg/platform/client/config.go index 6371c114e9..2355a7f34b 100644 --- a/pkg/platform/client/config.go +++ b/pkg/platform/client/config.go @@ -10,7 +10,7 @@ import ( type Config struct { metav1.TypeMeta `json:",inline"` - // host is the http endpoint of how to access loft + // host is the http endpoint of how to access devsy // +optional Host string `json:"host,omitempty"` @@ -18,15 +18,15 @@ type Config struct { // +optional LastInstallContext string `json:"lastInstallContext,omitempty"` - // insecure specifies if the loft instance is insecure + // insecure specifies if the devsy instance is insecure // +optional Insecure bool `json:"insecure,omitempty"` - // access key is the access key for the given loft host + // access key is the access key for the given devsy host // +optional AccessKey string `json:"accesskey,omitempty"` - // virtual cluster access key is the access key for the given loft host to create virtual clusters + // virtual cluster access key is the access key for the given devsy host to create virtual clusters // +optional VirtualClusterAccessKey string `json:"virtualClusterAccessKey,omitempty"` diff --git a/pkg/platform/deploy.go b/pkg/platform/deploy.go index 192aa8fae2..1064d17c3f 100644 --- a/pkg/platform/deploy.go +++ b/pkg/platform/deploy.go @@ -32,7 +32,7 @@ func WaitForPodReady( kubeClient kubernetes.Interface, namespace string, ) (*corev1.Pod, error) { - // wait until we have a running loft pod + // wait until we have a running devsy pod now := time.Now() pod := &corev1.Pod{} err := wait.PollUntilContextTimeout( @@ -41,12 +41,12 @@ func WaitForPodReady( Timeout(), true, func(ctx context.Context) (bool, error) { - loftPod, found, err := pollLoftPodReady(ctx, kubeClient, namespace, &now) + devsyPod, found, err := pollDevsyPodReady(ctx, kubeClient, namespace, &now) if err != nil { return false, err } - if loftPod != nil { - pod = loftPod + if devsyPod != nil { + pod = devsyPod } return found, nil }, @@ -58,25 +58,25 @@ func WaitForPodReady( return pod, nil } -func pollLoftPodReady( +func pollDevsyPodReady( ctx context.Context, kubeClient kubernetes.Interface, namespace string, now *time.Time, ) (*corev1.Pod, bool, error) { - loftPod := latestLoftPod(ctx, kubeClient, namespace, now) - if loftPod == nil { + devsyPod := latestDevsyPod(ctx, kubeClient, namespace, now) + if devsyPod == nil { return nil, false, nil } found := false - for i := range loftPod.Status.ContainerStatuses { - containerStatus := loftPod.Status.ContainerStatuses[i] + for i := range devsyPod.Status.ContainerStatuses { + containerStatus := devsyPod.Status.ContainerStatuses[i] ready, err := evalContainerStatus(evalContainerStatusParams{ ctx: ctx, kubeClient: kubeClient, namespace: namespace, - loftPod: loftPod, + devsyPod: devsyPod, containerStatus: containerStatus, now: now, }) @@ -91,10 +91,10 @@ func pollLoftPodReady( } } - return loftPod, found, nil + return devsyPod, found, nil } -func latestLoftPod( +func latestDevsyPod( ctx context.Context, kubeClient kubernetes.Interface, namespace string, @@ -126,7 +126,7 @@ type evalContainerStatusParams struct { ctx context.Context kubeClient kubernetes.Interface namespace string - loftPod *corev1.Pod + devsyPod *corev1.Pod containerStatus corev1.ContainerStatus now *time.Time } @@ -138,7 +138,7 @@ func evalContainerStatus(params evalContainerStatusParams) (bool, error) { return true, nil case containerStatus.State.Terminated != nil || (containerStatus.State.Waiting != nil && CriticalStatus[containerStatus.State.Waiting.Reason]): - return false, loftPodFailureError(params) + return false, devsyPodFailureError(params) case containerStatus.State.Waiting != nil && time.Now().After(params.now.Add(time.Second*10)): logContainerWaiting(containerStatus) *params.now = time.Now() @@ -147,7 +147,7 @@ func evalContainerStatus(params evalContainerStatusParams) (bool, error) { return false, nil } -func loftPodFailureError(params evalContainerStatusParams) error { +func devsyPodFailureError(params evalContainerStatusParams) error { containerStatus := params.containerStatus reason := "" message := "" @@ -161,7 +161,7 @@ func loftPodFailureError(params evalContainerStatusParams) error { out, err := params.kubeClient.CoreV1(). Pods(params.namespace). - GetLogs(params.loftPod.Name, &corev1.PodLogOptions{ + GetLogs(params.devsyPod.Name, &corev1.PodLogOptions{ Container: "manager", }). Do(params.ctx). diff --git a/pkg/platform/instance.go b/pkg/platform/instance.go index fa4c825f9e..5b4fea7324 100644 --- a/pkg/platform/instance.go +++ b/pkg/platform/instance.go @@ -193,9 +193,10 @@ func DialInstance( } log.Debugf("Connect to workspace using host: %s", host) - loftURL := "wss://" + host + "/kubernetes/management/apis/management.devsy.sh/v1/namespaces/" + workspace.Namespace + "/devsyworkspaceinstances/" + workspace.Name + "/" + subResource + devsyURL := "wss://" + host + "/kubernetes/management/apis/management.devsy.sh/v1/namespaces/" + + workspace.Namespace + "/devsyworkspaceinstances/" + workspace.Name + "/" + subResource if len(values) > 0 { - loftURL += "?" + values.Encode() + devsyURL += "?" + values.Encode() } dialer := websocket.Dialer{ @@ -204,7 +205,7 @@ func DialInstance( HandshakeTimeout: 45 * time.Second, } - conn, response, err := dialer.Dial(loftURL, map[string][]string{ + conn, response, err := dialer.Dial(devsyURL, map[string][]string{ "Authorization": {"Bearer " + restConfig.BearerToken}, }) if err != nil { @@ -213,11 +214,11 @@ func DialInstance( headers, _ := json.Marshal(response.Header) return nil, fmt.Errorf( "%s: error dialing websocket %s (code %d): headers - %s, error -: %w", - string(out), loftURL, response.StatusCode, string(headers), err, + string(out), devsyURL, response.StatusCode, string(headers), err, ) } - return nil, fmt.Errorf("error dialing websocket %s: %w", loftURL, err) + return nil, fmt.Errorf("error dialing websocket %s: %w", devsyURL, err) } return conn, nil diff --git a/pkg/platform/kubeconfig.go b/pkg/platform/kubeconfig.go index a45336493c..7feaa68bff 100644 --- a/pkg/platform/kubeconfig.go +++ b/pkg/platform/kubeconfig.go @@ -130,7 +130,7 @@ func kubeConfigForSpaceInstance( ttl := int64(configTTL.Seconds()) // direct cluster access? - if hostCluster.GetAnnotations()[annotations.LoftDirectClusterEndpoint] != "" { + if hostCluster.GetAnnotations()[annotations.DirectClusterEndpoint] != "" { return directClusterEndpointKubeConfigForSpace(directClusterEndpointForSpaceParams{ ctx: ctx, managementClient: managementClient, @@ -188,7 +188,7 @@ func directClusterEndpointKubeConfigForSpace( return nil, fmt.Errorf("create direct cluster endpoint token: %w", err) } - directClusterEndpoint := p.hostCluster.GetAnnotations()[annotations.LoftDirectClusterEndpoint] + directClusterEndpoint := p.hostCluster.GetAnnotations()[annotations.DirectClusterEndpoint] host := fmt.Sprintf( "https://%s/kubernetes/project/%s/space/%s", directClusterEndpoint, @@ -373,7 +373,7 @@ func directVirtualClusterKubeConfig( } // direct cluster access? - if hostCluster.GetAnnotations()[annotations.LoftDirectClusterEndpoint] != "" { + if hostCluster.GetAnnotations()[annotations.DirectClusterEndpoint] != "" { cfg, err = directClusterEndpointKubeConfig(p.req, hostCluster) return cfg, true, err } @@ -432,7 +432,7 @@ func directClusterEndpointKubeConfig( return nil, fmt.Errorf("create direct cluster endpoint token: %w", err) } - directClusterEndpoint := hostCluster.GetAnnotations()[annotations.LoftDirectClusterEndpoint] + directClusterEndpoint := hostCluster.GetAnnotations()[annotations.DirectClusterEndpoint] host := fmt.Sprintf( "https://%s/kubernetes/project/%s/virtualcluster/%s", directClusterEndpoint,