Skip to content

Editor

The editor resource provides a browser-based code editor tab that allows users to view and edit files. It supports multiple workspaces that can access files from the local filesystem or remote containers, enabling file manipulation within the lab environment.

As a lab author, you can use editor resources to provide file editing capabilities:

  • Configuration Management: Allow users to edit application config files, server settings, and deployment configurations
  • Code Development: Provide an integrated development environment for writing, modifying, and reviewing source code
  • Multi-Environment Access: Access files from both the sandbox filesystem and across multiple containers in the same editor

Editor resources provide familiar file editing experiences within the lab interface, supporting hands-on learning with real file systems.

resource "editor" "name" {
workspace "config" {
directory = "/app/config"
}
}
resource "editor" "name" {
workspace "local_files" {
directory = "assets/templates"
}
workspace "container_config" {
target = resource.container.app_server
directory = "/etc/app"
}
workspace "source_code" {
target = resource.container.dev_env
directory = "/workspace/src"
}
}
FieldRequiredTypeDescription
workspaceblockWorkspace definitions (repeatable)

editor → workspace

Defines a file workspace that appears as a folder tree in the editor.

FieldRequiredTypeDescription
namelabelWorkspace name (shown in editor sidebar)
directorystringPath to the directory to expose
targetreference to containerContainer to access files from. Defaults to local filesystem.
Field Type Description
title string DEPRECATED: Use the title field on the tab in your layout instead
  • Directory paths: Relative paths are resolved relative to the config file location for local workspaces
  • Target references: When specified, can only reference container resources
  • Workspace names: Must be unique within the editor
  • Directory access: Target containers must have the specified directories
resource "editor" "config_editor" {
workspace "templates" {
directory = "assets/config-templates"
}
workspace "scripts" {
directory = "files/setup-scripts"
}
}
resource "editor" "app_editor" {
workspace "nginx_config" {
target = resource.container.web_server
directory = "/etc/nginx/conf.d"
}
workspace "app_logs" {
target = resource.container.web_server
directory = "/var/log/nginx"
}
}
resource "editor" "dev_environment" {
workspace "source" {
target = resource.container.dev_container
directory = "/workspace/app"
}
workspace "tests" {
target = resource.container.dev_container
directory = "/workspace/tests"
}
workspace "docs" {
target = resource.container.dev_container
directory = "/workspace/docs"
}
}
resource "editor" "hybrid_editor" {
workspace "local_assets" {
directory = "files/static"
}
workspace "app_config" {
target = resource.container.application
directory = "/app/config"
}
workspace "database_config" {
target = resource.container.postgres
directory = "/etc/postgresql"
}
}

Editors must be referenced in layout tabs:

resource "layout" "with_editor" {
column {
width = "40"
instructions {}
}
column {
width = "60"
tab "terminal" {
target = resource.terminal.main
active = true
}
tab "code_editor" {
target = resource.editor.config_editor
title = "Configuration Files"
}
}
}

When accessing files in containers:

Terminal window
# Ensure the target container has proper permissions
RUN mkdir -p /app/config && chmod 755 /app/config
RUN chown -R user:user /app/config

For read-only access, files can be mounted as volumes:

resource "container" "app" {
image {
name = "myapp:latest"
}
volume {
source = "./config"
destination = "/app/config"
type = "bind"
read_only = true
}
}
  1. Logical Workspaces: Group related files into meaningful workspaces
  2. Clear Names: Use descriptive workspace names that indicate content purpose
  3. Permission Management: Ensure containers have appropriate file permissions
  4. Directory Structure: Organize files in logical hierarchies within workspaces
  5. Read-Only Content: Use read-only volumes for reference materials that shouldn’t be modified