@@ -37,7 +37,6 @@ devcontainer up %s
37
37
// important if e.g. a Coder module to install @devcontainer/cli is used.
38
38
func ExtractAndInitializeDevcontainerScripts (
39
39
logger slog.Logger ,
40
- expandPath func (string ) (string , error ),
41
40
devcontainers []codersdk.WorkspaceAgentDevcontainer ,
42
41
scripts []codersdk.WorkspaceAgentScript ,
43
42
) (filteredScripts []codersdk.WorkspaceAgentScript , devcontainerScripts []codersdk.WorkspaceAgentScript ) {
@@ -47,7 +46,6 @@ ScriptLoop:
47
46
// The devcontainer scripts match the devcontainer ID for
48
47
// identification.
49
48
if script .ID == dc .ID {
50
- dc = expandDevcontainerPaths (logger , expandPath , dc )
51
49
devcontainerScripts = append (devcontainerScripts , devcontainerStartupScript (dc , script ))
52
50
continue ScriptLoop
53
51
}
@@ -75,6 +73,17 @@ func devcontainerStartupScript(dc codersdk.WorkspaceAgentDevcontainer, script co
75
73
return script
76
74
}
77
75
76
+ // ExpandAllDevcontainerPaths expands all devcontainer paths in the given
77
+ // devcontainers. This is required by the devcontainer CLI, which requires
78
+ // absolute paths for the workspace folder and config path.
79
+ func ExpandAllDevcontainerPaths (logger slog.Logger , expandPath func (string ) (string , error ), devcontainers []codersdk.WorkspaceAgentDevcontainer ) []codersdk.WorkspaceAgentDevcontainer {
80
+ expanded := make ([]codersdk.WorkspaceAgentDevcontainer , 0 , len (devcontainers ))
81
+ for _ , dc := range devcontainers {
82
+ expanded = append (expanded , expandDevcontainerPaths (logger , expandPath , dc ))
83
+ }
84
+ return expanded
85
+ }
86
+
78
87
func expandDevcontainerPaths (logger slog.Logger , expandPath func (string ) (string , error ), dc codersdk.WorkspaceAgentDevcontainer ) codersdk.WorkspaceAgentDevcontainer {
79
88
logger = logger .With (slog .F ("devcontainer" , dc .Name ), slog .F ("workspace_folder" , dc .WorkspaceFolder ), slog .F ("config_path" , dc .ConfigPath ))
80
89
0 commit comments