Skip to content

sandboxer: refactor Layout from struct to interface - #153

Merged
dungdm93 merged 4 commits into
mainfrom
layout-refactor
Sep 17, 2026
Merged

dungdm93 merged 4 commits into
mainfrom
layout-refactor

Conversation

@dungdm93

@dungdm93 dungdm93 commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Overview

Replace sandboxer.Layout from a plain struct with fields to a Go interface with methods. This decouples consumers from any specific layout implementation and makes it straightforward to supply custom layouts (e.g. in tests or future sandbox backends).

Design

Before: Layout was a struct with public string fields (Workspace, Temp, Actions, Tools, Runtimes). All sandboxes returned *Layout.

After: Layout is an interface exposing those five paths as methods. A concrete StandardLayout(base string) type implements it by joining the base directory with each well-known subdirectory name. Sandboxes return Layout (interface value).

type Layout interface {
    Workspace() string
    Temp()      string
    Actions()   string
    Tools()     string
    Runtimes()  string
}

type StandardLayout string   // implements Layout via path.Join

container.DefaultLayout becomes a package-level StandardLayout value rather than a factory function, eliminating the DefaultLayout("") call pattern.

Changes

  • sandboxer/sandbox.go — define Layout interface and StandardLayout concrete type
  • host, incus, container sandbox implementations — adopt StandardLayout, return Layout interface
  • All consumers (executor, command, runtime, wire) — update to call interface methods
  • mock/sandboxer/sandbox.go — regenerated; adds MockLayout for test use
  • Tests — updated to use MockLayout (custom paths) or StandardLayout (derived paths) instead of struct literals

@dungdm93 dungdm93 changed the title sandboxer: refactor Layout from struct to interface sandboxer: refactor Layout from struct to interface Sep 17, 2026
@dungdm93
dungdm93 merged commit fb5b9e8 into main Sep 17, 2026
2 checks passed
@dungdm93
dungdm93 deleted the layout-refactor branch September 17, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant