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
2 changes: 1 addition & 1 deletion cmd/pro/provider/create/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func saveImportedWorkspaceConfig(
if err != nil {
return fmt.Errorf("load workspace config: %w", err)
}
workspaceConfig.Pro = &provider.ProMetadata{
workspaceConfig.Platform = &provider.PlatformMetadata{
InstanceName: instance.GetName(),
Project: project.ProjectFromNamespace(instance.GetNamespace()),
DisplayName: instance.Spec.DisplayName,
Expand Down
4 changes: 2 additions & 2 deletions cmd/pro/provider/watch/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (s *instanceStore) buildInstance(
func (s *instanceStore) importedInstance(
workspace *provider.Workspace,
) *WorkspaceInstance {
if !workspace.Imported || workspace.Pro == nil {
if !workspace.Imported || workspace.Platform == nil {
return nil
}

Expand All @@ -304,7 +304,7 @@ func (s *instanceStore) importedInstance(
}

l, err := s.informer.Lister().
DevsyWorkspaceInstances(project.ProjectFromNamespace(workspace.Pro.Project)).
DevsyWorkspaceInstances(project.ProjectFromNamespace(workspace.Platform.Project)).
List(selector)
if err != nil {
return nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/pro/workspace/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func (cmd *ImportCmd) writeNewWorkspaceDefinition(
Provider: provider2.WorkspaceProviderConfig{Name: providerName},
Context: devsyConfig.DefaultContext,
Imported: !cmd.Own,
Pro: &provider2.ProMetadata{
Platform: &provider2.PlatformMetadata{
InstanceName: instance.GetName(),
Project: project.ProjectFromNamespace(instance.Namespace),
DisplayName: instance.Spec.DisplayName,
Expand All @@ -248,7 +248,7 @@ func (cmd *ImportCmd) writeWorkspaceDefinition(
},
Context: devsyConfig.DefaultContext,
Imported: !cmd.Own,
Pro: &provider2.ProMetadata{
Platform: &provider2.PlatformMetadata{
InstanceName: instance.GetName(),
Project: instanceOpts[platform.ProjectEnv],
DisplayName: instance.Spec.DisplayName,
Expand Down
7 changes: 4 additions & 3 deletions cmd/workspace/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ func printPlainWorkspaces(workspaces []*provider.Workspace) {
tableEntries := [][]string{}
for _, entry := range workspaces {
name := entry.ID
if entry.IsPro() && entry.Pro.DisplayName != "" && entry.ID != entry.Pro.DisplayName {
name = fmt.Sprintf("%s (%s)", entry.Pro.DisplayName, entry.ID)
if entry.IsPlatform() && entry.Platform.DisplayName != "" &&
entry.ID != entry.Platform.DisplayName {
name = fmt.Sprintf("%s (%s)", entry.Platform.DisplayName, entry.ID)
}
tableEntries = append(tableEntries, []string{
name,
Expand All @@ -108,7 +109,7 @@ func printPlainWorkspaces(workspaces []*provider.Workspace) {
entry.IDE.Name,
time.Since(entry.LastUsedTimestamp.Time).Round(1 * time.Second).String(),
time.Since(entry.CreationTimestamp.Time).Round(1 * time.Second).String(),
fmt.Sprintf("%t", entry.IsPro()),
fmt.Sprintf("%t", entry.IsPlatform()),
})
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/workspace/troubleshoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (cmd *TroubleshootCmd) collectWorkspaceInfo(
info.addErr("workspace status", err)
}

if info.Workspace.Pro != nil {
if info.Workspace.Platform != nil {
info.WorkspaceTroubleshoot, err = collectWorkspaceProTroubleshoot(
ctx, info.Config, info.Workspace, info.DevsyProInstances,
)
Expand Down Expand Up @@ -165,7 +165,7 @@ func collectWorkspaceProTroubleshoot(
return nil, nil
}

return collectProWorkspaceInfo(ctx, devsyConfig, proInstance.Host, ws.UID, ws.Pro.Project)
return collectProWorkspaceInfo(ctx, devsyConfig, proInstance.Host, ws.UID, ws.Platform.Project)
}

// collectDaemonStatus returns the local daemon status when the client is a
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/clientimplementation/daemonclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,12 @@ func (c *client) initPlatformClient(ctx context.Context) (platformclient.Client,
}

func (c *client) getWorkspaceAddress() (ts.Addr, error) {
if c.workspace.Pro == nil || c.workspace.Pro.InstanceName == "" {
if c.workspace.Platform == nil || c.workspace.Platform.InstanceName == "" {
return ts.Addr{}, fmt.Errorf("workspace is not initialized")
}

return ts.NewAddr(
ts.GetWorkspaceHostname(c.workspace.Pro.InstanceName, c.workspace.Pro.Project),
ts.GetWorkspaceHostname(c.workspace.Platform.InstanceName, c.workspace.Platform.Project),
sshServer.DefaultUserPort,
), nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/clientimplementation/daemonclient/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (c *client) Create(
return err
}

c.workspace.Pro = &provider.ProMetadata{
c.workspace.Platform = &provider.PlatformMetadata{
InstanceName: instance.Name,
Project: project.ProjectFromNamespace(instance.Namespace),
DisplayName: instance.Spec.DisplayName,
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func ToOptionsWorkspace(workspace *Workspace) map[string]string {

addWorkspaceIdentityEnv(retVars, workspace)
addWorkspaceMachineEnv(retVars, workspace)
if workspace.Pro != nil && workspace.Pro.Project != "" {
retVars[config.EnvProject] = workspace.Pro.Project
if workspace.Platform != nil && workspace.Platform.Project != "" {
retVars[config.EnvProject] = workspace.Platform.Project
}
maps.Copy(retVars, GetBaseEnvironment(workspace.Context, workspace.Provider.Name))
return retVars
Expand Down
11 changes: 6 additions & 5 deletions pkg/provider/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ type Workspace struct {
// Origin is the place where this config file was loaded from
Origin string `json:"-"`

// Pro signals this workspace is remote and doesn't necessarily exist locally. It also has more metadata about the pro workspace
Pro *ProMetadata `json:"pro,omitempty"`
// Platform signals this workspace is remote and doesn't necessarily exist locally.
// It also has more metadata about the platform workspace
Platform *PlatformMetadata `json:"pro,omitempty"`

// Path to the file where the SSH config to access the workspace is stored
SSHConfigPath string `json:"sshConfigPath,omitempty"`
Expand All @@ -88,7 +89,7 @@ type Workspace struct {
SSHConfigIncludePath string `json:"sshConfigIncludePath,omitempty"`
}

type ProMetadata struct {
type PlatformMetadata struct {
// InstanceName is the platform CRD name for this workspace
InstanceName string `json:"instanceName,omitempty"`

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -550,6 +551,6 @@ func isPlausibleGitSource(s string) bool {
return !strings.Contains(u.Host, ":") || u.Port() != ""
}

func (w *Workspace) IsPro() bool {
return w.Pro != nil
func (w *Workspace) IsPlatform() bool {
return w.Platform != nil
}
6 changes: 3 additions & 3 deletions pkg/workspace/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func reconcilePlatformWorkspaces(
// legitimately gone and those where the host was temporarily unreachable.
cleanedLocalWorkspaces := []*providerpkg.Workspace{}
for _, localWorkspace := range localWorkspaces {
if localWorkspace.IsPro() &&
if localWorkspace.IsPlatform() &&
shouldDeleteLocalWorkspace(ctx, localWorkspace, platformWorkspaceResults) {
deleteLocalWorkspace(devsyConfig, localWorkspace)
continue
Expand Down Expand Up @@ -156,7 +156,7 @@ func loadLocalWorkspaceEntry(
return nil
}

if skipPlatform && workspaceConfig.IsPro() {
if skipPlatform && workspaceConfig.IsPlatform() {
return nil
}

Expand Down Expand Up @@ -316,7 +316,7 @@ func platformWorkspaceFromInstance(
},
LastUsedTimestamp: platformWorkspaceLastUsed(instance),
CreationTimestamp: platformWorkspaceCreationTimestamp(instance),
Pro: &providerpkg.ProMetadata{
Platform: &providerpkg.PlatformMetadata{
InstanceName: instance.GetName(),
Project: instance.GetLabels()[config.K8sProjectLabel],
DisplayName: instance.Spec.DisplayName,
Expand Down
2 changes: 1 addition & 1 deletion pkg/workspace/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func Rename(ctx context.Context, opts RenameOptions) error {
return fmt.Errorf("loading workspace config: %w", err)
}

if wsConfig.IsPro() {
if wsConfig.IsPlatform() {
return fmt.Errorf(
"cannot rename platform workspaces; they are managed by the platform",
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/workspace/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ func findWorkspace(
continue
}

if workspace.IsPro() {
if workspace.IsPlatform() {
workspace.Imported = true
if err := providerpkg.SaveWorkspaceConfig(workspace); err != nil {
return nil, fmt.Errorf("save workspace config: %w", err)
Expand Down Expand Up @@ -807,7 +807,7 @@ func selectPlatformWorkspace(
params selectWorkspaceParams,
) (platformWorkspaceSelection, error) {
for _, workspace := range workspaces {
if workspace.ID != selectedWorkspace.ID || !workspace.IsPro() {
if workspace.ID != selectedWorkspace.ID || !workspace.IsPlatform() {
continue
}
providerConfig, err := importSelectedPlatformWorkspace(devsyConfig, workspace, params)
Expand Down Expand Up @@ -855,8 +855,8 @@ func promptWorkspaceSelection(workspaces []*providerpkg.Workspace) (*providerpkg
options := make([]huh.Option[*providerpkg.Workspace], 0, len(workspaces))
for _, workspace := range workspaces {
key := workspace.ID
if workspace.IsPro() && workspace.Pro.DisplayName != "" {
key = fmt.Sprintf("%s (%s)", workspace.Pro.DisplayName, workspace.ID)
if workspace.IsPlatform() && workspace.Platform.DisplayName != "" {
key = fmt.Sprintf("%s (%s)", workspace.Platform.DisplayName, workspace.ID)
}
options = append(options, huh.NewOption(key, workspace))
}
Expand Down
Loading