mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: move docker-chat-sandbox under templates/x (#23777)
Adds the experimental `docker-chat-sandbox` example template under `examples/templates/x/`. It provisions a regular dev agent plus a chat-designated agent that runs inside bubblewrap with a read-only root, writable `/home/coder`, and outbound TCP restricted to the Coder control-plane endpoint via `iptables`. The chat agent still appears in dashboard and API responses, but the template reserves it for chatd-managed sessions rather than normal user interaction. `lint/examples` now walks nested template directories, so experimental templates can live under `examples/templates/x/` without treating `x/` itself as a template.
This commit is contained in:
@@ -49,17 +49,25 @@ func run(lint bool) error {
|
||||
|
||||
var paths []string
|
||||
if lint {
|
||||
files, err := fs.ReadDir(examplesFS, "templates")
|
||||
err := fs.WalkDir(examplesFS, "templates", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
if path == "templates" {
|
||||
return nil
|
||||
}
|
||||
if !isTemplateExampleDir(examplesFS, path) {
|
||||
return nil
|
||||
}
|
||||
paths = append(paths, path)
|
||||
return fs.SkipDir
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
if !f.IsDir() {
|
||||
continue
|
||||
}
|
||||
paths = append(paths, filepath.Join("templates", f.Name()))
|
||||
}
|
||||
} else {
|
||||
for _, comment := range src.Comments {
|
||||
for _, line := range comment.List {
|
||||
@@ -102,6 +110,18 @@ func run(lint bool) error {
|
||||
return enc.Encode(examples)
|
||||
}
|
||||
|
||||
func isTemplateExampleDir(examplesFS fs.FS, name string) bool {
|
||||
readmePath := path.Join(name, "README.md")
|
||||
mainTFPath := path.Join(name, "main.tf")
|
||||
if _, err := fs.Stat(examplesFS, readmePath); err != nil {
|
||||
return false
|
||||
}
|
||||
if _, err := fs.Stat(examplesFS, mainTFPath); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func parseTemplateExample(projectFS, examplesFS fs.FS, name string) (te *codersdk.TemplateExample, err error) {
|
||||
var errs []error
|
||||
defer func() {
|
||||
|
||||
Reference in New Issue
Block a user