File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -3,17 +3,29 @@ package agentcontainers
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "strings"
6
7
7
8
"cdr.dev/slog"
8
9
9
10
"github.com/coder/coder/v2/codersdk"
10
11
)
11
12
13
+ const devcontainerUpScriptTemplate = `
14
+ if ! which devcontainer > /dev/null 2>&1; then
15
+ echo "ERROR: Unable to start devcontainer, @devcontainers/cli is not installed."
16
+ exit 1
17
+ fi
18
+ devcontainer up %s
19
+ `
20
+
21
+ // DevcontainerStartupScript returns a script that starts a devcontainer.
12
22
func DevcontainerStartupScript (dc codersdk.WorkspaceAgentDevcontainer , script codersdk.WorkspaceAgentScript ) codersdk.WorkspaceAgentScript {
13
- cmd := fmt .Sprintf ("devcontainer up --workspace-folder %q" , dc .WorkspaceFolder )
23
+ var args []string
24
+ args = append (args , fmt .Sprintf ("--workspace-folder %q" , dc .WorkspaceFolder ))
14
25
if dc .ConfigPath != "" {
15
- cmd = fmt .Sprintf ("%s --config %q" , cmd , dc .ConfigPath )
26
+ args = append ( args , fmt .Sprintf ("--config %q" , dc .ConfigPath ) )
16
27
}
28
+ cmd := fmt .Sprintf (devcontainerUpScriptTemplate , strings .Join (args , " " ))
17
29
script .RunOnStart = false
18
30
script .Script = cmd
19
31
return script
You can’t perform that action at this time.
0 commit comments