Skip to content
Merged
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 pkg/platform/annotations/annotations.go
Original file line number Diff line number Diff line change
@@ -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"
Comment thread
skevetter marked this conversation as resolved.
Resolved
2 changes: 1 addition & 1 deletion pkg/platform/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pkg/platform/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Expand Down Expand Up @@ -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,
)
}
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/platform/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ 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"`

// LastInstallContext is the last install context
// +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"`

Expand Down
32 changes: 16 additions & 16 deletions pkg/platform/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
},
Expand All @@ -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,
})
Expand All @@ -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,
Expand Down Expand Up @@ -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
}
Expand All @@ -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()
Expand All @@ -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 := ""
Expand All @@ -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).
Expand Down
11 changes: 6 additions & 5 deletions pkg/platform/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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 {
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pkg/platform/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down
Loading